ARTS 2.5.0 (git: 9ee3ac6c)
my_basic_string< charT > Class Template Reference

The implementation for String, the ARTS string class. More...

#include <mystring.h>

Inheritance diagram for my_basic_string< charT >:

Public Types

typedef Index size_type
 

Public Member Functions

 my_basic_string ()=default
 
 my_basic_string (Index n, char c=' ')
 Constructor setting size. More...
 
 my_basic_string (const std::basic_string< charT > &A, Index pos=0, Index numpos=my_basic_string< charT >::npos)
 Construnctor from a basic_string. More...
 
 my_basic_string (const char A[])
 Constructor from a C-style char array. More...
 
 my_basic_string (const std::string_view &sv)
 Constructor from a std::string_view. More...
 
void insert_substr (const my_basic_string< charT > &searchstr, const my_basic_string< charT > &insstr)
 Insert string before all occurrences of the substring. More...
 
void split (Array< my_basic_string< charT > > &aos, const my_basic_string< charT > &delim) const
 Split string into substrings. More...
 
void toupper ()
 Convert to upper case. More...
 
my_basic_string toupper () const
 
void tolower ()
 Convert to lower case. More...
 
my_basic_string tolower () const
 
void trim ()
 Trim leading and trailing whitespace. More...
 
Index nelem () const
 Number of elements. More...
 
char operator[] (Index n) const
 Constant index operator. More...
 
char & operator[] (Index n)
 Non-constant index operator. More...
 

Static Public Attributes

static const Index npos = static_cast<Index>(std::basic_string<charT>::npos)
 Define npos: More...
 

Detailed Description

template<class charT>
class my_basic_string< charT >

The implementation for String, the ARTS string class.

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 55 of file mystring.h.

Member Typedef Documentation

◆ size_type

template<class charT >
typedef Index my_basic_string< charT >::size_type

Definition at line 109 of file mystring.h.

Constructor & Destructor Documentation

◆ my_basic_string() [1/5]

template<class charT >
my_basic_string< charT >::my_basic_string ( )
default

◆ my_basic_string() [2/5]

template<class charT >
my_basic_string< charT >::my_basic_string ( Index  n,
char  c = ' ' 
)
inlineexplicit

Constructor setting size.

You may give as a second argument a character with which to fill the new string. Per default this is zero.

Parameters
nNumber of characters
cOptional fill character

Definition at line 124 of file mystring.h.

◆ my_basic_string() [3/5]

template<class charT >
my_basic_string< charT >::my_basic_string ( const std::basic_string< charT > &  A,
Index  pos = 0,
Index  numpos = my_basic_string<charT>::npos 
)
inline

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.

Parameters
AThe original string
posStart position (0 means from the beginning)
numposHow many characters to copy

Definition at line 141 of file mystring.h.

References ARTS_ASSERT.

◆ my_basic_string() [4/5]

template<class charT >
my_basic_string< charT >::my_basic_string ( const char  A[])
inline

Constructor from a C-style char array.

Definition at line 175 of file mystring.h.

◆ my_basic_string() [5/5]

template<class charT >
my_basic_string< charT >::my_basic_string ( const std::string_view &  sv)
inline

Constructor from a std::string_view.

Definition at line 181 of file mystring.h.

Member Function Documentation

◆ insert_substr()

template<class charT >
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.

Parameters
[in]searchstrString to search for.
[in]insstrString to insert.

Definition at line 191 of file mystring.h.

Referenced by write_method_header_documentation().

◆ nelem()

◆ operator[]() [1/2]

template<class charT >
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.

Parameters
[in]nIndex

Definition at line 279 of file mystring.h.

References ARTS_ASSERT, and Absorption::nelem().

◆ operator[]() [2/2]

template<class charT >
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.

Parameters
[in]nIndex

Definition at line 266 of file mystring.h.

References ARTS_ASSERT, and Absorption::nelem().

◆ split()

template<class charT >
void my_basic_string< charT >::split ( Array< my_basic_string< charT > > &  aos,
const my_basic_string< charT > &  delim 
) const
inline

Split string into substrings.

Parameters
[out]aosArrayOfString containing the returned substrings.
[in]delimDelimiter string.

Definition at line 213 of file mystring.h.

References my_basic_string< charT >::nelem(), and Absorption::nelem().

Referenced by get_dirname(), operator>>(), parse_a5_hitran(), parse_atmcompact_scattype(), parse_atmcompact_speciesname(), parse_atmcompact_speciestype(), parse_f51_hitran(), parse_partfield_name(), and ScatSpeciesScatAndMetaRead().

◆ tolower() [1/2]

template<class charT >
void my_basic_string< charT >::tolower ( )
inline

Convert to lower case.

Definition at line 86 of file mystring.h.

References Zeeman::end(), my_basic_string< charT >::tolower(), and transform().

Referenced by my_basic_string< charT >::tolower().

◆ tolower() [2/2]

template<class charT >
my_basic_string my_basic_string< charT >::tolower ( ) const
inline

Definition at line 90 of file mystring.h.

References my_basic_string< charT >::tolower().

◆ toupper() [1/2]

template<class charT >
void my_basic_string< charT >::toupper ( )
inline

◆ toupper() [2/2]

template<class charT >
my_basic_string my_basic_string< charT >::toupper ( ) const
inline

Definition at line 79 of file mystring.h.

References my_basic_string< charT >::toupper().

◆ trim()

template<class charT >
void my_basic_string< charT >::trim

Trim leading and trailing whitespace.

Definition at line 232 of file mystring.h.

References my_basic_string< charT >::nelem().

Referenced by parse_a5_hitran(), parse_f51_hitran(), and Absorption::ReadFromArtscat4Stream().

Member Data Documentation

◆ npos

template<class charT >
const Index my_basic_string< charT >::npos = static_cast<Index>(std::basic_string<charT>::npos)
static

Define npos:

Definition at line 107 of file mystring.h.

Referenced by ArrayOfSpeciesTag::ArrayOfSpeciesTag(), and replace_all().


The documentation for this class was generated from the following file: