libshevek
|
shevek::istring is a C++ version of scanf. More...
#include <iostring.hh>
Public Member Functions | |
istring () | |
Create a new istring with no data. | |
istring (Glib::ustring const &str) | |
Create a new istring with data. | |
void | init (Glib::ustring const &str) |
Set new data to an existing istring. | |
void | push () |
Push the current position to the stack so it can be restored later. | |
int | pop (bool keep=false) |
Pop the last pushed position from the stack. | |
void | reset () |
Set the current position to 0, but don't change the stack. | |
Glib::ustring | rest () const |
Get remaining string. | |
void | skip (Glib::ustring::size_type p) |
Skip some characters. | |
bool | operator() (Glib::ustring const &format) |
Read a constant string from the input. | |
template<typename T1 > | |
bool | operator() (Glib::ustring const &format, T1 &arg1) |
Read a string containing one argument from the input. | |
template<typename T1 , typename T2 > | |
bool | operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2) |
Read a string containing two arguments from the input. | |
template<typename T1 , typename T2 , typename T3 > | |
bool | operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3) |
Read a string containing three arguments from the input. | |
template<typename T1 , typename T2 , typename T3 , typename T4 > | |
bool | operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4) |
Read a string containing four arguments from the input. | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 > | |
bool | operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5) |
Read a string containing five arguments from the input. | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > | |
bool | operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6) |
Read a string containing six arguments from the input. | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 > | |
bool | operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6, T7 &arg7) |
Read a string containing seven arguments from the input. | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 > | |
bool | operator() (Glib::ustring const &format, T1 &arg1, T2 &arg2, T3 &arg3, T4 &arg4, T5 &arg5, T6 &arg6, T7 &arg7, T8 &arg8) |
Read a string containing eight arguments from the input. |
Static Public Member Functions | |
template<typename T > | |
static T | direct (Glib::ustring const &data, Glib::ustring const &format, T def=T()) |
Read a variable from given data and return it. |
shevek::istring is a C++ version of scanf.
It uses templates to allow expanding it to user-defined types, but it still uses a format string to make it better translatable.
|
inlinestatic |
Read a variable from given data and return it.
This allows using a shevek::istring in an expression without the need to create a new variable for it. If the input doesn't match the format, def is returned.
int shevek::istring::pop | ( | bool | keep = false | ) |
Pop the last pushed position from the stack.
If keep is true or not given, the current position is restored to the last position. If it is false, the current position is not changed.