Wrapper class around STL string class.
More...
#include <JString.hh>
Wrapper class around STL string class.
Definition at line 28 of file JString.hh.
◆ JString() [1/7]
JLANG::JString::JString |
( |
| ) |
|
|
inline |
Default constructor.
Definition at line 40 of file JString.hh.
◆ JString() [2/7]
JLANG::JString::JString |
( |
const std::string & |
buffer | ) |
|
|
inlineexplicit |
Constructor.
- Parameters
-
Definition at line 50 of file JString.hh.
◆ JString() [3/7]
JLANG::JString::JString |
( |
const char |
c | ) |
|
|
inlineexplicit |
Constructor.
- Parameters
-
Definition at line 60 of file JString.hh.
◆ JString() [4/7]
JLANG::JString::JString |
( |
const char * |
buffer, |
|
|
const std::string::size_type |
length |
|
) |
| |
|
inlineexplicit |
Constructor.
- Parameters
-
buffer | string |
length | length |
Definition at line 71 of file JString.hh.
72 std::string(buffer, length)
◆ JString() [5/7]
template<class T >
JLANG::JString::JString |
( |
const T & |
value | ) |
|
|
inline |
Constructor.
- Parameters
-
Definition at line 82 of file JString.hh.
◆ JString() [6/7]
Constructor.
This constructor compiles (see below) the input string.
- Parameters
-
buffer | input string |
facet | facet |
Definition at line 94 of file JString.hh.
◆ JString() [7/7]
JLANG::JString::JString |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
|
inline |
Constructor.
Composes a string with the same text that would be printed if format was used on printf.
- Parameters
-
Definition at line 108 of file JString.hh.
114 for (
int size = 1024; ; size <<= 1) {
118 va_start(args, format);
120 const int length = vsnprintf(buffer, size, format, args);
124 this->
assign(buffer, buffer + length);
◆ compile()
Compile token with given facet.
This method uses the given facet to parse the input string. The result is then compatible with the definition of a token and may be empty.
- Parameters
-
- Returns
- this string
Definition at line 142 of file JString.hh.
146 istringstream is(*
this);
148 ios_base::iostate state;
150 facet.
get(is, istreambuf_iterator<char>(), is, state, *
this);
◆ startsWith()
bool JLANG::JString::startsWith |
( |
const std::string & |
prefix | ) |
const |
|
inline |
Test if this string starts with the specified prefix.
- Parameters
-
- Returns
- true if this string starts with prefix; else false
Definition at line 163 of file JString.hh.
165 return this->size() >= prefix.size() && this->substr(0, prefix.size()) == prefix;
◆ endsWith()
bool JLANG::JString::endsWith |
( |
const std::string & |
suffix | ) |
const |
|
inline |
Test if this string ends with the specified suffix.
- Parameters
-
- Returns
- true if this string ends with suffix; else false
Definition at line 175 of file JString.hh.
177 return this->size() >= suffix.size() && this->substr(this->size() - suffix.size()) == suffix;
◆ replace() [1/3]
JString& JLANG::JString::replace |
( |
const char |
target, |
|
|
const char |
replacement, |
|
|
const std::size_t |
max = std::numeric_limits<std::size_t>::max() |
|
) |
| |
|
inline |
Replace characters.
- Parameters
-
target | target character |
replacement | replacement character |
max | maximum number of replacements |
- Returns
- this string
Definition at line 189 of file JString.hh.
193 for (std::size_t i = this->find(target),
n = max; i != std::string::npos &&
n != 0; i = find(target,i), --
n) {
194 (*this)[i] = replacement;
◆ replace() [2/3]
JString& JLANG::JString::replace |
( |
const std::string & |
target, |
|
|
const std::string & |
replacement, |
|
|
const std::size_t |
max = std::numeric_limits<std::size_t>::max() |
|
) |
| |
|
inline |
Replace character sequences.
- Parameters
-
target | target string |
replacement | replacement string |
max | maximum number of replacements |
- Returns
- this string
Definition at line 209 of file JString.hh.
213 for (std::size_t i = this->find(target),
n = max; i != std::string::npos &&
n != 0; i = this->find(target,i), --
n) {
214 replace(this->begin() + i, this->begin() + i + target.length(), replacement);
◆ replace() [3/3]
template<class T >
JString& JLANG::JString::replace |
( |
const std::string & |
target, |
|
|
const T & |
value, |
|
|
const std::size_t |
max = std::numeric_limits<std::size_t>::max() |
|
) |
| |
|
inline |
Replace character sequence.
- Parameters
-
target | target string |
value | value |
max | maximum number of replacements |
- Returns
- this string
Definition at line 230 of file JString.hh.
234 for (std::size_t i = this->find(target),
n = max; i != std::string::npos &&
n != 0; i = this->find(target,i), --
n) {
235 replace(this->begin() + i, this->begin() + i + target.length(),
JString(value));
◆ trim() [1/3]
Trim string.
Returns the modified string, with leading and trailing white spaces omitted.
- Returns
- this string
Definition at line 248 of file JString.hh.
◆ trim() [2/3]
JString& JLANG::JString::trim |
( |
const char |
c | ) |
|
|
inline |
Trim string.
Returns the modified string, with leading and trailing target characters omitted.
- Parameters
-
- Returns
- this string
Definition at line 263 of file JString.hh.
◆ trim() [3/3]
JString JLANG::JString::trim |
( |
const std::string & |
target | ) |
|
|
inline |
Trim string.
Returns the modified string, with leading and trailing target characters omitted.
- Parameters
-
target | character(s) to strip |
- Returns
- this string
Definition at line 278 of file JString.hh.
◆ toUpper()
JString& JLANG::JString::toUpper |
( |
| ) |
|
|
inline |
Convert all character to upper case.
- Returns
- this string
Definition at line 291 of file JString.hh.
293 for (
iterator i = begin(); i != end(); ++i) {
◆ toLower()
JString& JLANG::JString::toLower |
( |
| ) |
|
|
inline |
Convert all character to lower case.
- Returns
- this string
Definition at line 306 of file JString.hh.
308 for (
iterator i = begin(); i != end(); ++i) {
◆ valueOf() [1/2]
static JString JLANG::JString::valueOf |
( |
const int |
input | ) |
|
|
inlinestatic |
Convert enumeration type to string.
- Parameters
-
- Returns
- string
Definition at line 322 of file JString.hh.
324 std::ostringstream os;
◆ valueOf() [2/2]
template<class T >
static JString JLANG::JString::valueOf |
( |
const T & |
input | ) |
|
|
inlinestatic |
Convert value to string.
- Parameters
-
- Returns
- string
Definition at line 340 of file JString.hh.
342 std::ostringstream os;
◆ toValue()
template<class T >
static const T& JLANG::JString::toValue |
( |
const JString & |
input | ) |
|
|
inlinestatic |
Convert string to value.
- Parameters
-
- Returns
- value
Definition at line 358 of file JString.hh.
362 std::istringstream is(input);
◆ assign()
template<class T >
JString& JLANG::JString::assign |
( |
T & |
output | ) |
|
|
inline |
Assign (part of) string to value.
- Parameters
-
- Returns
- remaining string
Definition at line 378 of file JString.hh.
382 istringstream is(*
this);
390 this->
assign(istreambuf_iterator<char>(is),
391 istreambuf_iterator<char>());
◆ operator>>
std::istream& operator>> |
( |
std::istream & |
in, |
|
|
JString & |
object |
|
) |
| |
|
friend |
Read string from input stream.
- Parameters
-
in | input stream |
object | string |
- Returns
- input stream
Definition at line 404 of file JString.hh.
408 istream::sentry sentry(in);
412 const locale&
loc = in.getloc();
414 if (has_facet<JStringFacet>(
loc)) {
416 ios_base::iostate state;
418 use_facet<JStringFacet>(
loc).get(in, istreambuf_iterator<char>(), in, state,
object);
420 if (state != ios_base::goodbit && state != ios_base::eofbit) {
426 in >> static_cast<string&>(
object);
◆ operator<<
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const JString & |
object |
|
) |
| |
|
friend |
Write string to output stream.
- Parameters
-
out | output stream |
object | string |
- Returns
- output stream
Definition at line 441 of file JString.hh.
445 const locale&
loc = out.getloc();
447 if (has_facet<JStringFacet>(
loc)) {
449 use_facet<JStringFacet>(
loc).put(out, out, out.fill(), object);
453 out << static_cast<const string&>(
object);
The documentation for this class was generated from the following file:
istreambuf_iterator 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.