Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
This module provides classes making easier the use of character string. There is basically two classes: String and CString. Other classes provides more services like StringBuffer. More...
Classes | |
class | Char |
class | String |
class | CString |
class | StringSplit |
class | StringBuffer |
class | Char |
class | Iter |
class | Formatter |
Variables | |
AutoStringStartup | autostr |
AutoStringStartup & | _ = autostr |
This module provides classes making easier the use of character string. There is basically two classes: String and CString. Other classes provides more services like StringBuffer.
Notice that typedefs "string" and "cstring" are only scalar-type-like shortcuts to String and CString classes.
The CString is a simple wrapper around the original C "char *" null-terminated C string. It provides an interface very similar to the String class as possible. The operator "&" may be used to get the hidden "const char *" buffer. When CString operation requires memory allocation, a String object is instead returned as this class has automatic memory management facilities. The CString is either useful to interact with the OS, or to handle constant litteral strings.
The String provides a lot of facilities to handle strings as any other scalar type:
The string classes implements the concept concept::Array<char>.
The following operators are also available:
Some automatic conversions are also available:
Finally, there some methods to perform tests or retrieval of strings:
And some methods to build strings:
String building is very costly because it requires a memory copy of both involved strings. Usually, a string building operation involves many concatenation. The StringBuffer class may be used to reduce this cost.
The string is built in a large buffer that is expanded (inducing a copy operation) less often than the original String class. To makes things easier, this class provides also the same interface as IO io::Output class. To get the completed string, one has only to call the toString() method as in the example below.
To make things even easier, the ELM library provides an auto-builder and frier of string buffer called elm::_ that avoids the need to declare the string buffer. The previous example uses below this feature:
Other classes provide several facilities:
AutoStringStartup & _ = autostr |
#include <include/elm/string/AutoString.h>
This little object make easier the construction of strings. There is no more to explictely construct a string buffer, concatenates items and buid the string to pass it to a parameter. Just perform the concatenation on the autostr object and all work is done automatically as in the example below.
As the autostr keyword is a bit long, you may replaced it by "_".
Referenced by BiDiList< T, E, A >::BackIter::BackIter(), XOMElementSerializer::beginCompound(), XOMElementSerializer::beginObject(), BiDiList< T, E, A >::clear(), System::createRandomFile(), Debug::debugPrefix(), Debug::debugPrefixFunction(), Debug::debugPrefixWrapped(), Path::DirIter::DirIter(), BiDiList< T, E, A >::first(), XOMUnserializer::flush(), Class< T, B, I >::instantiate(), TreeBag< T, C, A >::Iter::Iter(), Saver::key(), BiDiList< T, E, A >::last(), File::load(), GroupedGC::mark(), SimpleGC::mark(), BiDiList< T, E, A >::Iter::next(), TreeBag< T, C, A >::Iter::next(), BiDiList< T, E, A >::BackIter::next(), XOMUnserializer::onEnum(), XOMElementSerializer::onPointer(), XOMElementSerializer::onValue(), XOMUnserializer::onValue(), System::openRandomFile(), Manager::parse(), Parser::parse(), Plugger::plugFile(), EnumOption< T >::process(), IDAttribute::process(), RefAttribute< T >::process(), BiDiList< T, E, A >::remove(), BiDiList< T, E, A >::removeAfter(), BiDiList< T, E, A >::removeBefore(), BiDiList< T, E, A >::removeFirst(), BiDiList< T, E, A >::removeLast(), and elm::single().
AutoStringStartup autostr |