1 #ifndef __JLANG__JSTRING__
2 #define __JLANG__JSTRING__
20 namespace JPP {
using namespace JLANG; }
49 explicit JString(
const std::string& buffer) :
70 explicit JString(
const char* buffer,
const std::string::size_type length) :
71 std::string(buffer, length)
93 template<
class ...Args>
127 istringstream is(*
this);
129 ios_base::iostate state;
131 facet.
get(is, istreambuf_iterator<char>(), is, state, *
this);
146 return this->size() >= prefix.size() && this->substr(0, prefix.size()) == prefix;
158 return this->size() >= suffix.size() && this->substr(this->size() - suffix.size()) == suffix;
171 const char replacement,
172 const std::size_t max = std::numeric_limits<std::size_t>::max())
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;
191 const std::string& replacement,
192 const std::size_t max = std::numeric_limits<std::size_t>::max())
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);
213 const std::size_t max = std::numeric_limits<std::size_t>::max())
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));
274 for (
iterator i = begin(); i != end(); ++i) {
289 for (
iterator i = begin(); i != end(); ++i) {
305 std::ostringstream os;
323 std::ostringstream os;
343 std::istringstream is(input);
363 istringstream is(*
this);
371 this->
assign(istreambuf_iterator<char>(is),
372 istreambuf_iterator<char>());
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);
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);
447 template<
class T,
class ...Args>
452 const size_t pos = this->find(
'%');
454 if (pos != string::npos) {
482 istream::sentry sentry(in,
true);
486 const locale&
loc = in.getloc();
488 if (has_facet<JStringFacet>(
loc)) {
490 use_facet<JStringFacet>(
loc).getline(in,
object);
494 getline(in,
static_cast<string&
>(
object));
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
TString replace(const TString &target, const TRegexp ®exp, const T &replacement)
Replace regular expression in input by given replacement.
Facet class to specify parsing of a JLANG::JString object.
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.
Wrapper class around STL string class.
static JString valueOf(const T &input)
Convert value to string.
JString & trim(const char c)
Trim string.
JString(const char *buffer, const std::string::size_type length)
Constructor.
JString & assign(T &output)
Assign (part of) string to value.
JString & replace(const char target, const char replacement, const std::size_t max=std::numeric_limits< std::size_t >::max())
Replace characters.
JString()
Default constructor.
bool startsWith(const std::string &prefix) const
Test if this string starts with the specified prefix.
JString(const char *format, const Args &...args)
Constructor.
JString & compile(const JStringFacet &facet)
Compile token with given facet.
JString & replace(const std::string &target, const std::string &replacement, const std::size_t max=std::numeric_limits< std::size_t >::max())
Replace character sequences.
bool endsWith(const std::string &suffix) const
Test if this string ends with the specified suffix.
friend std::istream & operator>>(std::istream &in, JString &object)
Read string from input stream.
JString & trim()
Trim string.
JString(const char c)
Constructor.
JString trim(const std::string &target)
Trim string.
JString & toUpper()
Convert all character to upper case.
static const T & toValue(const JString &input)
Convert string to value.
JString(const JString &buffer, const JStringFacet &facet)
Constructor.
static JString valueOf(const int input)
Convert enumeration type to string.
void __set__() const
Termination method for formatting string.
void __set__(const T &value, const Args &...args)
Recursive method for formatting string.
friend std::ostream & operator<<(std::ostream &out, const JString &object)
Write string to output stream.
JString & toLower()
Convert all character to lower case.
JString & replace(const std::string &target, const T &value, const std::size_t max=std::numeric_limits< std::size_t >::max())
Replace character sequence.
JString(const T &value)
Constructor.
JString(const std::string &buffer)
Constructor.
Auxiliary classes and methods for language specific functionality.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
std::string trim(const std::string &buffer)
Trim string.
JAssignSequence< typename JContainer_t::value_type > assign(JContainer_t &out)
Helper method to assign sequence of Comma Separated Values to output container.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).