Skip to content
Skip to link menu
Trinity API Reference
Trinity API Reference
tdeabc
tdeabc
tdeabc
vcard
RToken.cpp
1
/*
2
3
libvcard - vCard parsing library for vCard version 3.0
4
5
Copyright (C) 1999 Rik Hemsley rik@kde.org
6
7
Permission is hereby granted, free of charge, to any person obtaining a copy
8
of this software and associated documentation files (the "Software"), to
9
deal in the Software without restriction, including without limitation the
10
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
sell copies of the Software, and to permit persons to whom the Software is
12
furnished to do so, subject to the following conditions:
13
14
The above copyright notice and this permission notice shall be included in
15
all copies or substantial portions of the Software.
16
17
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*/
24
25
#include <string.h>
26
#include <stddef.h>
27
#include <tqcstring.h>
28
#include <tqstrlist.h>
29
30
namespace
VCARD
31
{
32
33
TQ_UINT32
34
RTokenise(
const
char
* str,
const
char
* delim, TQStrList & l)
35
{
36
// FIXME no stderr !
37
l.clear();
38
39
if
(!delim || !str || strlen(delim) == 0 || strlen(str) == 0)
return
0;
40
41
char
* len = (
char
*)(str + strlen(str));
// End of string.
42
43
char
* rstart =
new
char
[strlen(str) + 1];
44
char
* r = rstart;
45
46
47
const
char
* i = str;
// Cursor.
48
49
while
(i <= len) {
50
51
if
(*i ==
'\\'
) {
// Escaped chars go straight through.
52
*r++ = *i++;
53
if
(i <= len)
54
*r++ = *i++;
55
continue
;
56
}
57
58
if
(strchr(delim, *i) != 0) {
59
// We hit a delimiter. If we have some text, make a new token.
60
// This has the effect that multiple delimiters are collapsed.
61
// cs: We mustn't collapse multiple delimiters, otherwise we
62
// lose empty fields.
63
*r =
'\0'
;
64
// if (r != rstart) {
65
l.append(rstart);
66
// }
67
r = rstart;
68
++i;
69
continue
;
70
}
71
72
*r++ = *i++;
73
}
74
75
// Catch last token
76
// if (r != rstart) {
77
*r =
'\0'
;
78
l.append(rstart);
79
// }
80
81
r = 0;
82
83
delete
[] rstart;
84
85
return
l.count();
86
}
87
88
}
tdeabc
Skip menu "tdeabc"
Main Page
Namespace List
Class Hierarchy
Alphabetical List
Class List
File List
Namespace Members
Class Members
Related Pages
tdeabc
Skip menu "tdeabc"
arts
dcop
dnssd
interfaces
kspeech
interface
library
tdetexteditor
kate
kded
kdoctools
kimgio
kjs
libtdemid
libtdescreensaver
tdeabc
tdecmshell
tdecore
tdefx
tdehtml
tdeinit
tdeio
bookmarks
httpfilter
kpasswdserver
kssl
tdefile
tdeio
tdeioexec
tdeioslave
http
tdemdi
tdemdi
tdenewstuff
tdeparts
tdeprint
tderandr
tderesources
tdespell2
tdesu
tdeui
tdeunittest
tdeutils
tdewallet