1
////////////////////////////////////////////////////////////////////////////////
2
/*! @file Strings.h Символьные строки.
3
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
4
- Copyright(C) 1994-2010, Viktor E. Bursian, St.Petersburg, Russia.
5
Viktor.Bursian@mail.ioffe.ru
6
*///////////////////////////////////////////////////////////////////////////////
9
//#include "RANet_global.h"
14
//------------------------------------------------------------------------------
16
ANNOUNCE_CLASS(sString) // the most universal class for strings
18
std::ostream & operator << (std::ostream & ,rcsString);
19
std::istream & operator >> (std::istream & ,rsString);
21
//using namespace std::rel_ops; NEVER EVER USE using IN HEADERS!!!
23
class RANet_EXPORT sString
26
static sString from_real (real number
27
,unsigned short int digits_after_dot);
36
size_t Length () const;
37
char operator [] (size_t) const; //first char index==0
38
/*!< @todo{completeness} op[] must return char& ? */
39
// operator literal () const;
40
operator ptr_to_const_char () const;
41
sString Substr (size_t from ,size_t length) const;
42
sString Tail (size_t from) const;
43
size_t Pos (literal) const;
44
size_t Pos (rcsString) const;
45
rsString operator = (rcsString);
46
rsString operator = (literal);
47
sString operator + (rcsString) const;
48
sString operator + (literal) const;
49
rsString operator += (rcsString);
50
rsString operator += (literal);
51
rsString operator += (const char);
52
rsString operator << (const int);
53
rsString operator << (const unsigned int);
54
rsString operator << (const long int);
55
rsString operator << (const unsigned long int);
56
rsString operator << (real);
57
rsString operator << (const double);
58
rsString operator >> (int &);
59
rsString operator >> (real &);
60
bool operator == (rcsString) const;
61
bool operator == (literal) const;
62
bool operator != (rcsString) const;
63
bool operator != (literal) const;
64
bool operator < (rcsString) const;
65
/*!< @todo{completeness} ==(char) <,>,<=,>= >>int/float */
66
sString UpperCase () const;
67
sString Trim () const;
68
sString TrimSyntactic (literal Delimiters
69
= DefaultDelimiters) const;
70
sString Translate (char O ,char N) const;
71
virtual void Read (std::istream &);
72
virtual void Write (std::ostream &) const;
73
// virtual void InputTextLine (std::istream &);
75
void SetValue (literal);
80
// size_t CurrentSpace;
83
static literal EmptyLiteral;
84
static literal DefaultDelimiters;
86
// friend std::ostream & operator << (std::ostream & ,rcsString);
87
// friend std::istream & operator >> (std::istream & ,rsString);
91
inline sString::sString ()
99
inline bool sString::Empty () const
101
return Body ? (CurrentLength == 0) : true ;
105
inline size_t sString::Length () const
107
return Body ? CurrentLength : 0 ;
111
//inline sString::operator literal () const
112
inline sString::operator ptr_to_const_char () const
114
return Body ? Body : EmptyLiteral ;
118
inline size_t sString::Pos (rcsString S) const
120
return Pos( (literal)S );
124
inline rsString sString::operator = (literal V)
126
SetValue(V); return *this;
130
inline sString sString::operator + (rcsString S) const
132
return operator+(literal(S));
136
inline rsString sString::operator += (rcsString S)
138
return operator+=(literal(S));//! @todo{bomb} что за нах!
142
inline bool sString::operator != (rcsString S) const
144
return !( operator==(S) );
148
inline bool sString::operator != (literal L) const
150
return !( operator==(L) );
154
//inline rsStream operator << (rsStream S ,rcsLongString L)
155
//for unknown reason this does not allow to use a field member of a class
158
inline std::ostream & operator<< (std::ostream & a_stream ,rcsString a_string)
160
a_string.Write(a_stream);
164
inline std::istream & operator>> (std::istream & a__stream ,rsString a_string)
166
a_string.Read(a__stream);
170
//------------------------------------------------------------------------------