File: NameComponent.cpp

package info (click to toggle)
kdepim 4%3A2.2.2-5.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 14,908 kB
  • ctags: 14,522
  • sloc: cpp: 82,512; ansic: 30,637; sh: 10,838; yacc: 5,139; perl: 3,070; makefile: 1,447; python: 1,359; lex: 342; awk: 100
file content (114 lines) | stat: -rw-r--r-- 2,176 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
	libldif - LDAP LDIF parsing library

	Copyright (C) 1998 Rik Hemsley rik@kde.org
	
	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <qstrlist.h>

#include "RToken.h"
#include "ldif.h"

using namespace LDIF;


NameComponent::NameComponent()
	:	Entity()
{
	attrTypeAndValueList_.setAutoDelete(true);
}

NameComponent::NameComponent(const NameComponent & x)
	:	Entity					(x),
		attrTypeAndValueList_	(x.attrTypeAndValueList_)
{
	attrTypeAndValueList_.setAutoDelete(true);
}

NameComponent::NameComponent(const QCString & s)
	:	Entity(s)
{
	attrTypeAndValueList_.setAutoDelete(true);
}

	NameComponent &
NameComponent::operator = (NameComponent & x)
{
	if (*this == x) return *this;

	x.parse();
	attrTypeAndValueList_ = x.attrTypeAndValueList_;

	Entity::operator = (x);
	return *this;
}

	NameComponent &
NameComponent::operator = (const QCString & s)
{
	Entity::operator = (s);
	return *this;
}

	bool
NameComponent::operator == (NameComponent & x)
{
	x.parse();
	// TODO
	return false;
}

NameComponent::~NameComponent()
{
}

	void
NameComponent::_parse()
{
	QStrList l;
	
	RTokenise(strRep_, "+", l);
	
	QStrListIterator it(l);
	
	for (; it.current(); ++it) {
		
		AttrTypeAndValue * tv = new AttrTypeAndValue(it.current());
		
		attrTypeAndValueList_.append(tv);
		
	}
}

	void
NameComponent::_assemble()
{
	AttrTypeAndValueIterator it(attrTypeAndValueList_);
	
	bool firstTime = false;
	
	for (; it.current(); ++it) {
		
		if (!firstTime) {
			strRep_ += '+';
			firstTime = false;
		}
		
		strRep_ += it.current()->asString();
	}
}