yast2-core
YCPString.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | |
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
8 | |
9 | core system |
10 | (C) SuSE GmbH |
11 \----------------------------------------------------------------------/
12 
13  File: YCPString.h
14 
15  Author: Mathias Kettner <kettner@suse.de>
16  Maintainer: Thomas Roelz <tom@suse.de>
17 
18 /-*/
19 // -*- c++ -*-
20 
21 #ifndef YCPString_h
22 #define YCPString_h
23 
24 
25 #include "YCPValue.h"
26 #include <y2util/Ustring.h>
27 
28 
39 class YCPStringRep : public YCPValueRep
40 {
41 
42  string v;
43  bool is_ascii;
44 
45 protected:
46 
47  friend class YCPString;
48 
56  YCPStringRep(const string& s);
57 
65  YCPStringRep(const wstring& s);
66 
67 public:
68 
72  bool isEmpty() const;
73 
77  bool isAscii() const { return is_ascii; }
78 
82  const string& value() const;
83 
87  wstring wvalue() const;
88 
97  YCPOrder compare(const YCPString &v, bool rl = false) const;
98 
102  const char *value_cstr() const;
103 
110  string toString() const;
111 
115  std::ostream & toStream (std::ostream & str) const;
116  std::ostream & toXml (std::ostream & str, int indent ) const;
117 
121  YCPValueType valuetype() const;
122 };
123 
124 
125 #define CONST_ELEMENT (static_cast<const YCPStringRep*>(element))
126 
133 class YCPString : public YCPValue
134 {
135  DEF_COMMON(String, Value);
136 public:
137  YCPString(const string& s) : YCPValue(new YCPStringRep(s)) {}
138  YCPString(const wstring& s) : YCPValue(new YCPStringRep(s)) {}
140 
141  bool isEmpty() const { return CONST_ELEMENT->isEmpty(); }
142 };
143 
144 #undef CONST_ELEMENT
145 
146 #endif // YCPString_h

Generated on a sunny day for yast2-core by doxygen 1.8.2