#include <mystring.h>
Public Types | |
typedef Index | size_type |
Public Member Functions | |
my_basic_string () | |
Default constructor. | |
my_basic_string (Index n, char c=' ') | |
Constructor setting size. | |
my_basic_string (const basic_string< charT > &A, Index pos=0, Index numpos=my_basic_string< charT >::npos) | |
Construnctor from another my_basic_string. | |
my_basic_string (const char A[]) | |
Constructor from a C-style char array. | |
my_basic_string & | operator= (const my_basic_string< charT > &A) |
Assignment from another my_basic_string. | |
void | insert_substr (const my_basic_string< charT > searchstr, const my_basic_string< charT > insstr) |
Insert string before all occurrences of the substring. | |
Index | nelem () const |
Number of elements. | |
char | operator[] (Index n) const |
Constant index operator. | |
char & | operator[] (Index n) |
Non-constant index operator. | |
Static Public Attributes | |
static const Index | npos = static_cast<Index>(basic_string<charT>::npos) |
Define npos:. |
This adds some additional functionality to the standard stl string class, notably:
a) Range checking by assert
b) nelem() member function, return the size of the String of type Index.
The type string is just a typedef for basic_string<char>. Therefore, to make everything work correctly, we have to derive our own class from basic_string, not from string directly.
Definition at line 60 of file mystring.h.
typedef Index my_basic_string< charT >::size_type |
Definition at line 93 of file mystring.h.
my_basic_string< charT >::my_basic_string | ( | ) | [inline] |
my_basic_string< charT >::my_basic_string | ( | Index | n, | |
char | c = ' ' | |||
) | [inline, explicit] |
Constructor setting size.
You may give as a second argument a character with which to fill the new string. Per default this is zero.
n | Number of characters | |
c | Optional fill character |
Definition at line 115 of file mystring.h.
my_basic_string< charT >::my_basic_string | ( | const basic_string< charT > & | A, | |
Index | pos = 0 , |
|||
Index | numpos = my_basic_string<charT>::npos | |||
) | [inline] |
Construnctor from another my_basic_string.
Construnctor from a basic_string. This is important for handling of expressions like this to work correctly:
String a = b+'.'+c
As for basic_string, this constructor can also be used to initialize the new string from a subrange of the original string.
A | The original string | |
pos | Start position (0 means from the beginning) | |
numpos | How many characters to copy |
Definition at line 137 of file mystring.h.
my_basic_string< charT >::my_basic_string | ( | const char | A[] | ) | [inline] |
my_basic_string< charT > & my_basic_string< charT >::operator= | ( | const my_basic_string< charT > & | A | ) | [inline] |
Assignment from another my_basic_string.
The two partners do not have to have the same size. Size of the target string is adjusted automatically, just as string does it.
Definition at line 182 of file mystring.h.
void my_basic_string< charT >::insert_substr | ( | const my_basic_string< charT > | searchstr, | |
const my_basic_string< charT > | insstr | |||
) | [inline] |
Insert string before all occurrences of the substring.
[in] | searchstr | String to search for. |
[in] | insstr | String to insert. |
Definition at line 194 of file mystring.h.
Referenced by write_method_header_documentation().
Index my_basic_string< charT >::nelem | ( | ) | const [inline] |
Number of elements.
Definition at line 213 of file mystring.h.
Referenced by get_wsv_group_ids(), main(), operator<<(), my_basic_string< charT >::operator[](), ParticleTypeAdd(), LineRecord::ReadFromArtsStream(), LineRecord::ReadFromHitran2004Stream(), LineRecord::ReadFromHitranStream(), LineRecord::ReadFromJplStream(), LineRecord::ReadFromMytran2Stream(), species_index_from_species_name(), SpeciesTag::SpeciesTag(), write_method_header(), and xml_read_from_stream().
char my_basic_string< charT >::operator[] | ( | Index | n | ) | const [inline] |
Constant index operator.
We redifine this here so that we can have range checking by assert.
[in] | n | Index |
Definition at line 227 of file mystring.h.
References my_basic_string< charT >::nelem().
char & my_basic_string< charT >::operator[] | ( | Index | n | ) | [inline] |
Non-constant index operator.
We redifine this here so that we can have range checking by assert.
[in] | n | Index |
Definition at line 241 of file mystring.h.
References my_basic_string< charT >::nelem().
const Index my_basic_string< charT >::npos = static_cast<Index>(basic_string<charT>::npos) [static] |
Define npos:.
Definition at line 91 of file mystring.h.
Referenced by array_species_tag_from_string(), get_parameters(), get_short_wsv_description(), main(), ArtsXMLTag::read_from_stream(), replace_all(), and SpeciesTag::SpeciesTag().