X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/f27c218d18ebf7198e07249aca1eed625da914fd..d664a4c16bb56138b53e8d6dba92e199bd3ea6c7:/Server/include/plaqui/server/string.h diff --git a/Server/include/plaqui/server/string.h b/Server/include/plaqui/server/string.h index ecd253a..41e83ac 100644 --- a/Server/include/plaqui/server/string.h +++ b/Server/include/plaqui/server/string.h @@ -29,6 +29,7 @@ #define PLAQUI_STRING_H #include +#include #include namespace PlaQui { @@ -104,6 +105,29 @@ namespace Server { static String join(const std::vector& v, const std::string& sep); + /** + * Convierte un string a otro tipo. + * + * \param p Parametro del tipo al que se quiere convertir. + */ + template < class T > T& to(T& p) const { + std::stringstream ss(*this); + ss >> p; + return p; + } + + /** + * Convierte un tipo a string. + * + * \param p Parametro del tipo que se quiere convertir a string. + */ + template < class T > String& from(const T& p) { + std::stringstream ss; + ss << p; + ss >> (*this); + return *this; + } + }; }