Facet class to specify parsing of a JLANG::JString object.
More...
#include <JStringFacet.hh>
|
static int | getIndex () |
| Get index for stream associated facet data.
|
|
|
static std::locale::id | id |
|
|
virtual istreambuf_iterator | do_get (const istreambuf_iterator __begin, const istreambuf_iterator __end, const std::ios_base &format, std::ios_base::iostate &result, std::string &buffer) const |
| Get string.
|
|
virtual ostreambuf_iterator | do_put (ostreambuf_iterator out, const std::ios_base &format, const char c, const std::string &buffer) const |
| Put string.
|
|
virtual istreambuf_iterator | do_ignore (const istreambuf_iterator __begin, const istreambuf_iterator __end) const |
| Ignore characters until next end of line.
|
|
virtual istreambuf_iterator | do_getline (const istreambuf_iterator __begin, const istreambuf_iterator __end, std::ios_base::iostate &result, std::string &buffer) const |
| Read string.
|
|
Facet class to specify parsing of a JLANG::JString object.
This class extends the std::locale::facet class.
Definition at line 26 of file JStringFacet.hh.
◆ istreambuf_iterator
◆ ostreambuf_iterator
◆ JStringFacet() [1/2]
JLANG::JStringFacet::JStringFacet |
( |
std::size_t | refs = 0 | ) |
|
|
inline |
Constructor.
- Parameters
-
Definition at line 44 of file JStringFacet.hh.
44 :
45 std::locale::facet(refs)
46 {}
◆ JStringFacet() [2/2]
◆ clone()
◆ get()
Get string.
- Parameters
-
__begin | begin position of input stream |
__end | end position of input stream |
format | format |
result | status after input operation |
buffer | output string |
- Returns
- position of input stream
Definition at line 70 of file JStringFacet.hh.
75 {
76 return do_get(__begin, __end, format, result, buffer);
77 }
virtual istreambuf_iterator do_get(const istreambuf_iterator __begin, const istreambuf_iterator __end, const std::ios_base &format, std::ios_base::iostate &result, std::string &buffer) const
Get string.
◆ put()
Put string.
- Parameters
-
out | begin position of output stream |
format | format |
c | fill character |
buffer | input string |
- Returns
- position of output stream buffer
Definition at line 89 of file JStringFacet.hh.
93 {
94 return do_put(out, format, c, buffer);
95 }
virtual ostreambuf_iterator do_put(ostreambuf_iterator out, const std::ios_base &format, const char c, const std::string &buffer) const
Put string.
◆ ignore()
std::istream & JLANG::JStringFacet::ignore |
( |
std::istream & | in | ) |
const |
|
inline |
Ignore characters until next end of line.
- Parameters
-
- Returns
- input stream
Definition at line 104 of file JStringFacet.hh.
105 {
107 in.setstate(std::ios_base::eofbit);
108 }
109
110 return in;
111 }
std::istreambuf_iterator< char, std::char_traits< char > > istreambuf_iterator
virtual istreambuf_iterator do_ignore(const istreambuf_iterator __begin, const istreambuf_iterator __end) const
Ignore characters until next end of line.
◆ getline()
std::istream & JLANG::JStringFacet::getline |
( |
std::istream & | in, |
|
|
std::string & | buffer ) const |
|
inline |
Read characters until next end of line.
- Parameters
-
in | input stream |
buffer | output string |
- Returns
- input stream
Definition at line 121 of file JStringFacet.hh.
123 {
125
126 ios_base::iostate state = in.rdstate();
127
129 in.setstate(std::ios_base::eofbit);
130 }
131
132 if (state != ios_base::goodbit && state != ios_base::eofbit) {
133 in.setstate(state);
134 }
135
136 return in;
137 }
virtual istreambuf_iterator do_getline(const istreambuf_iterator __begin, const istreambuf_iterator __end, std::ios_base::iostate &result, std::string &buffer) const
Read string.
◆ getIndex()
static int JLANG::JStringFacet::getIndex |
( |
| ) |
|
|
inlinestatic |
Get index for stream associated facet data.
- Returns
- index
Definition at line 145 of file JStringFacet.hh.
146 {
147 static int i = std::ios_base::xalloc();
148
149 return i;
150 }
◆ do_get()
Get string.
- Parameters
-
__begin | begin position of input stream |
__end | end position of input stream |
format | format |
result | status after input operation |
buffer | output string |
- Returns
- position of input stream
Reimplemented in JLANG::JCppFacet, and JLANG::JEquationFacet.
Definition at line 164 of file JStringFacet.hh.
169 {
171
172 result = (ios_base::iostate) 0;
173
174 streamsize
n = format.width();
175
176 if (n == 0) {
177 n = numeric_limits<streamsize>::max();
178 }
179
181
182 if (i == __end) {
183
184 result |= ios_base::failbit;
185 result |= ios_base::eofbit;
186
187 } else {
188
189 buffer.clear();
190
191 buffer.push_back(*i);
192
193 for (++i, --n; i != __end &&
n != 0; ++i, --
n) {
194 buffer.push_back(*i);
195 }
196
197 if (i == __end) {
198 result |= ios_base::eofbit;
199 }
200 }
201
202 return i;
203 }
◆ do_put()
Put string.
- Parameters
-
out | begin position of output stream |
format | format |
c | fill character |
buffer | input string |
- Returns
- current position of output stream
Reimplemented in JLANG::JCppFacet, and JLANG::JEquationFacet.
Definition at line 215 of file JStringFacet.hh.
219 {
221
222 if (format.flags() & ios_base::right) {
223 for (streamsize i = buffer.size(); i < format.width(); ++i, ++out) {
224 *out = c;
225 }
226 }
227
228 for (string::const_iterator i = buffer.begin(); i != buffer.end(); ++i, ++out) {
229 *out = *i;
230 }
231
232 if (format.flags() & ios_base::left) {
233 for (streamsize i = buffer.size(); i < format.width(); ++i, ++out) {
234 *out = c;
235 }
236 }
237
238 return out;
239 }
◆ do_ignore()
Ignore characters until next end of line.
- Parameters
-
__begin | begin position of input stream |
__end | end position of input stream |
- Returns
- position of input stream
Reimplemented in JLANG::JCppFacet.
Definition at line 249 of file JStringFacet.hh.
251 {
253
254 while (i != __end && *i != '\n') {
255 ++i;
256 }
257
258 while (i != __end && *i == '\n') {
259 ++i;
260 }
261
262 return i;
263 }
◆ do_getline()
Read string.
- Parameters
-
__begin | begin position of input stream |
__end | end position of input stream |
result | status after input operation |
buffer | output string |
- Returns
- position of input stream
Reimplemented in JLANG::JEquationFacet.
Definition at line 275 of file JStringFacet.hh.
279 {
281
283
284 if (i == __end) {
285
286 result |= ios_base::failbit;
287 result |= ios_base::eofbit;
288
289 } else {
290
291 buffer.clear();
292
293 for ( ; i != __end && *i != '\n'; ++i) {
294 buffer.push_back(*i);
295 }
296
297 if (i != __end) {
298 ++i;
299 }
300 }
301
302 return i;
303 }
◆ operator=()
void JLANG::JStringFacet::operator= |
( |
const JStringFacet & | | ) |
|
|
private |
◆ id
std::locale::id JLANG::JStringFacet::id |
|
static |
The documentation for this class was generated from the following files: