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
#define str
Definition: scanner.cc:997
bool is_ascii
Definition: YCPString.h:43
DEF_COMMON(String, Value)
string toString() const
Definition: YCPString.cc:111
bool isEmpty() const
Definition: YCPString.cc:49
YCPValueType
Value Type Defines constants for the Value types. The Value type specifies the class the YCPValueRep ...
Definition: YCPValue.h:36
std::ostream & toStream(std::ostream &str) const
Definition: YCPString.cc:148
wstring wvalue() const
Definition: YCPString.cc:63
bool isAscii() const
Definition: YCPString.h:77
YCPString(const string &s)
Definition: YCPString.h:137
Wrapper for YCPStringRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPStringRep with the arrow operator. See YCPStringRep.
Definition: YCPString.h:133
YCPValueRep representing a character string of arbitrary length. Whatever internal representation is ...
Definition: YCPString.h:39
YCPOrder
Definition: YCPValue.h:57
YCPString(const wstring &s)
Definition: YCPString.h:138
#define CONST_ELEMENT
Definition: YCPString.h:125
YCPValueType valuetype() const
Definition: YCPString.cc:137
Abstract base class of all YCP values. Abstract base class of all YCP elements that can be used as pr...
Definition: YCPValue.h:71
std::ostream & toXml(std::ostream &str, int indent) const
Definition: YCPString.cc:155
const char * value_cstr() const
Definition: YCPString.cc:104
Wrapper for YCPValueRep This class realizes an automatic memory management via YCPElement. Access the functionality of YCPValueRep with the arrow operator. See YCPValueRep.
Definition: YCPValue.h:275
string v
Definition: YCPString.h:42
bool isEmpty() const
Definition: YCPString.h:141
An istream that remembers some data about the bytecode.
Definition: Bytecode.h:42
YCPStringRep(const string &s)
Definition: YCPString.cc:33
const string & value() const
Definition: YCPString.cc:56
YCPOrder compare(const YCPString &v, bool rl=false) const
Definition: YCPString.cc:71

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