summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_c/token.h
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/parse/parse_c/token.h')
-rw-r--r--bitbake/lib/bb/parse/parse_c/token.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/bitbake/lib/bb/parse/parse_c/token.h b/bitbake/lib/bb/parse/parse_c/token.h
new file mode 100644
index 0000000000..2351fda6b5
--- /dev/null
+++ b/bitbake/lib/bb/parse/parse_c/token.h
@@ -0,0 +1,83 @@
1/*
2Copyright (C) 2005 Holger Hans Peter Freyther
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22*/
23
24#ifndef TOKEN_H
25#define TOKEN_H
26
27#define PURE_METHOD
28
29struct token_t {
30 const char* string()const PURE_METHOD;
31
32 static char* concatString(const char* l, const char* r);
33 void assignString(const char* str);
34 void copyString(const char* str);
35
36 void release_this();
37
38private:
39 char *m_string;
40 size_t m_stringLen;
41};
42
43inline const char* token_t::string()const
44{
45 return m_string;
46}
47
48/*
49 * append str to the current string
50 */
51inline char* token_t::concatString(const char* l, const char* r)
52{
53 size_t cb = (l ? strlen (l) : 0) + strlen (r) + 1;
54 r_sz = new char[cb];
55 *r_sz = 0;
56 if (l) strcat (r_sz, l);
57 strcat (r_sz, r);
58
59 return r_sz;
60}
61
62inline void token_t::assignString(const char* str)
63{
64 m_string = str;
65 m_stringLen = str ? strlen(str) : 0;
66}
67
68inline void token_t::copyString(const char* str)
69{
70 if( str ) {
71 m_stringLen = strlen(str);
72 m_string = new char[m_stringLen+1];
73 strcpy(m_string, str)
74 }
75}
76
77inline void token_t::release_this()
78{
79 delete m_string;
80 m_string = 0;
81}
82
83#endif