]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Server/include/plaqui/server/string.h
Se implementa una señal entre Thread con Glib::Dispatch .. no se si soluciona el...
[z.facultad/75.42/plaqui.git] / Server / include / plaqui / server / string.h
index ecd253a8bc53e251aadcb34ab35fbee9112dbe4c..41e83acd70ef5b3bd7f5095e41ae259587901a52 100644 (file)
@@ -29,6 +29,7 @@
 #define PLAQUI_STRING_H
 
 #include <string>
 #define PLAQUI_STRING_H
 
 #include <string>
+#include <sstream>
 #include <vector>
 
 namespace PlaQui {
 #include <vector>
 
 namespace PlaQui {
@@ -104,6 +105,29 @@ namespace Server {
                        static String join(const std::vector<std::string>& v,
                                        const std::string& sep);
 
                        static String join(const std::vector<std::string>& 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;
+                       }
+
        };
 
 }
        };
 
 }