X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/a0481d50f6da9cac5efd3502c3657b3fc461ec0d..c90e905d76aed75379d220478e97fda0d34ec59b:/Server/include/plaqui/server/string.h?ds=sidebyside diff --git a/Server/include/plaqui/server/string.h b/Server/include/plaqui/server/string.h index 41e83ac..96e2bb8 100644 --- a/Server/include/plaqui/server/string.h +++ b/Server/include/plaqui/server/string.h @@ -36,6 +36,21 @@ namespace PlaQui { namespace Server { + /** + * Convierte de un tipo a otro (de p1 a p2) a través de un stringstream. + * + * \param p1 Parámetro origen. + * \param p2 Parámetro destino, al que se quiere convertir. + * + * \return Referencia a p2. + */ + template < class T1, class T2 > static T2& to(const T1& p1, T2& p2) { + std::stringstream ss(p1); + ss << p1; + ss >> p2; + return p2; + } + /// Conexión. class String: public std::string { @@ -75,7 +90,7 @@ namespace Server { /** * Elmina caracteres al inicio y fin de un string. * - * \param c Lista de caracteres a eliminar. + * \param clist Lista de caracteres a eliminar. */ String& trim(const String& clist = SPACE_CHARS);