Wrapper class around STL string class.
More...
#include <JString.hh>
|
template<class T , class ... Args> |
void | __set__ (const T &value, const Args &...args) |
| Recursive method for formatting string. More...
|
|
void | __set__ () const |
| Termination method for formatting string. More...
|
|
Wrapper class around STL string class.
Definition at line 27 of file JString.hh.
◆ JString() [1/7]
JLANG::JString::JString |
( |
| ) |
|
|
inline |
Default constructor.
Definition at line 39 of file JString.hh.
◆ JString() [2/7]
JLANG::JString::JString |
( |
const std::string & |
buffer | ) |
|
|
inlineexplicit |
Constructor.
- Parameters
-
Definition at line 49 of file JString.hh.
◆ JString() [3/7]
JLANG::JString::JString |
( |
const char |
c | ) |
|
|
inlineexplicit |
Constructor.
- Parameters
-
Definition at line 59 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 70 of file JString.hh.
71 std::string(buffer, length)
◆ JString() [5/7]
template<class T >
JLANG::JString::JString |
( |
const T & |
value | ) |
|
|
inline |
Constructor.
- Parameters
-
Definition at line 81 of file JString.hh.
static JString valueOf(const int input)
Convert enumeration type to string.
◆ JString() [6/7]
template<class ... Args>
JLANG::JString::JString |
( |
const char * |
format, |
|
|
const Args &... |
args |
|
) |
| |
|
inline |
Constructor.
Each '' in the format string will be replaced by the corresponding argument.
- Parameters
-
Definition at line 94 of file JString.hh.
void __set__() const
Termination method for formatting string.
◆ JString() [7/7]
Constructor.
This constructor compiles (see below) the input string.
- Parameters
-
buffer | input string |
facet | facet |
Definition at line 108 of file JString.hh.
JString & compile(const JStringFacet &facet)
Compile token with given facet.
◆ 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 123 of file JString.hh.
127 istringstream is(*
this);
129 ios_base::iostate state;
131 facet.
get(is, istreambuf_iterator<char>(), is, state, *
this);
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.
◆ 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 144 of file JString.hh.
146 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 156 of file JString.hh.
158 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 170 of file JString.hh.
174 for (std::size_t i = this->find(target),
n = max; i != std::string::npos &&
n != 0; i = find(target,i), --
n) {
175 (*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 190 of file JString.hh.
194 for (std::size_t i = this->find(target),
n = max; i != std::string::npos &&
n != 0; i = this->find(target,i), --
n) {
195 replace(this->begin() + i, this->begin() + i + target.length(), replacement);
JString & replace(const char target, const char replacement, const std::size_t max=std::numeric_limits< std::size_t >::max())
Replace characters.
◆ 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 211 of file JString.hh.
215 for (std::size_t i = this->find(target),
n = max; i != std::string::npos &&
n != 0; i = this->find(target,i), --
n) {
216 replace(this->begin() + i, this->begin() + i + target.length(),
JString(value));
Wrapper class around STL string class.
◆ trim() [1/3]
Trim string.
Returns the modified string, with leading and trailing white spaces omitted.
- Returns
- this string
Definition at line 229 of file JString.hh.
std::string trim(const std::string &buffer)
Trim string.
◆ 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 244 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 259 of file JString.hh.
◆ toUpper()
JString& JLANG::JString::toUpper |
( |
| ) |
|
|
inline |
Convert all character to upper case.
- Returns
- this string
Definition at line 272 of file JString.hh.
274 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 287 of file JString.hh.
289 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 303 of file JString.hh.
305 std::ostringstream os;
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
JString()
Default constructor.
◆ 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 321 of file JString.hh.
323 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 339 of file JString.hh.
343 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 359 of file JString.hh.
363 istringstream is(*
this);
371 this->
assign(istreambuf_iterator<char>(is),
372 istreambuf_iterator<char>());
JString & assign(T &output)
Assign (part of) string to value.
◆ __set__() [1/2]
template<class T , class ... Args>
void JLANG::JString::__set__ |
( |
const T & |
value, |
|
|
const Args &... |
args |
|
) |
| |
|
inlineprivate |
Recursive method for formatting string.
- Parameters
-
value | next value |
args | remaining values |
Definition at line 448 of file JString.hh.
452 const size_t pos = this->find(
'%');
454 if (pos != string::npos) {
◆ __set__() [2/2]
void JLANG::JString::__set__ |
( |
| ) |
const |
|
inlineprivate |
Termination method for formatting string.
Definition at line 466 of file JString.hh.
◆ 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 385 of file JString.hh.
389 istream::sentry sentry(in);
393 const locale&
loc = in.getloc();
395 if (has_facet<JStringFacet>(
loc)) {
397 ios_base::iostate state;
399 use_facet<JStringFacet>(
loc).get(in, istreambuf_iterator<char>(), in, state,
object);
401 if (state != ios_base::goodbit && state != ios_base::eofbit) {
407 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 422 of file JString.hh.
426 const locale&
loc = out.getloc();
428 if (has_facet<JStringFacet>(
loc)) {
430 use_facet<JStringFacet>(
loc).put(out, out, out.fill(),
object);
434 out << static_cast<const string&>(
object);
The documentation for this class was generated from the following file: