Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
String.h
1 /*
2  * xom::String class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2006-09, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef ELM_XOM_STRING_H
22 #define ELM_XOM_STRING_H
23 
24 #include <elm/string.h>
25 #include <elm/io.h>
26 
27 namespace elm { namespace xom {
28 
32 typedef unsigned char char_t;
33 
34 // String class
35 class String: public CString {
36 public:
37 
38  // Constructors
39  inline String(void) { }
40  inline String(const char *str): CString(str) { }
41  inline String(const char_t *str): CString((const char *)str) { }
42  inline String(const CString& str): CString(str) { }
43  inline String(const String& str): CString(str) { }
44 
45  // Buffer management
46  void copy(void);
47  void free(void);
48 
49  // Other operations
50  void escape(io::OutStream& out) const;
51  inline void escape(io::Output& out) const { escape(out.stream()); }
52  inline elm::string escape(void) const { StringBuffer buf; escape(buf.stream()); return buf.toString(); }
53 
54  // Operators
55  inline String& operator=(const String& str) { buf = str.buf; return *this; }
56  inline operator char_t *(void) const { return (char_t *)buf; }
57 };
59  { out << cstring(str); return out; }
60 
61 } } // elm::xom
62 
63 #endif // ELM_XOM_STRING_H
elm::xom::String::String
String(const CString &str)
Definition: String.h:42
elm::xom::String::escape
void escape(io::Output &out) const
Definition: String.h:51
elm::xom::operator<<
io::Output & operator<<(io::Output &out, String str)
Definition: String.h:58
elm::t::out
typename type_info< T >::out_t out
Definition: type_info.h:284
elm::StringBuffer
Definition: StringBuffer.h:18
elm::xom::String::escape
elm::string escape(void) const
Definition: String.h:52
elm::xom::char_t
unsigned char char_t
Definition: String.h:32
elm::xom::String
Definition: String.h:35
elm::xom::String::free
void free(void)
Definition: xom_String.cpp:45
elm::CString::buf
const char * buf
Definition: CString.h:19
elm::cstring
CString cstring
Definition: CString.h:62
elm::xom::String::operator=
String & operator=(const String &str)
Definition: String.h:55
elm::xom::String::String
String(const char *str)
Definition: String.h:40
void
elm::CString
Definition: CString.h:17
elm::xom::String::String
String(const String &str)
Definition: String.h:43
elm
Definition: adapter.h:26
elm::xom::String::copy
void copy(void)
Definition: xom_String.cpp:37
elm::io::OutStream
Definition: OutStream.h:30
elm::String
Definition: String.h:30
elm::str
string str(const char *s)
Definition: String.h:150
elm::io::Output
Definition: Output.h:179
elm::xom::String::String
String(void)
Definition: String.h:39
elm::xom::String::String
String(const char_t *str)
Definition: String.h:41