]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Server/include/plaqui/server/string.h
Se agrega generacion de XML para dar el estado actual de la planta simulada.
[z.facultad/75.42/plaqui.git] / Server / include / plaqui / server / string.h
index 292055fd92895dbff668158ecb18b22009e8a9a7..41e83acd70ef5b3bd7f5095e41ae259587901a52 100644 (file)
 #define PLAQUI_STRING_H
 
 #include <string>
 #define PLAQUI_STRING_H
 
 #include <string>
+#include <sstream>
+#include <vector>
 
 
-namespace Plaqui {
+namespace PlaQui {
+
+namespace Server {
 
        /// Conexión.
        class String: public std::string {
 
        /// Conexión.
        class String: public std::string {
@@ -43,7 +47,12 @@ namespace Plaqui {
                        /**
                         * Destructor.
                         */
                        /**
                         * Destructor.
                         */
-                       virtual ~String(void) {}
+                       virtual ~String(void);
+
+                       /**
+                        * Constructor.
+                        */
+                       String(void);
 
                        /**
                         * Constructor.
 
                        /**
                         * Constructor.
@@ -52,6 +61,17 @@ namespace Plaqui {
                         */
                        String(const std::string& str);
 
                         */
                        String(const std::string& str);
 
+                       /**
+                        * Constructor a partir de un vector.
+                        * Convierte el vector en string uniendo sus componentes a traves
+                        * del separador.
+                        *
+                        * \param v   Vector.
+                        * \param sep Separador.
+                        */
+                       String(const std::vector<std::string>& v,
+                                       const std::string& sep);
+
                        /**
                         * Elmina caracteres al inicio y fin de un string.
                         *
                        /**
                         * Elmina caracteres al inicio y fin de un string.
                         *
@@ -69,8 +89,49 @@ namespace Plaqui {
                         */
                        String& to_lower(void);
 
                         */
                        String& to_lower(void);
 
+                       /**
+                        * Fracciona una cadena convirtiendola en un vector.
+                        *
+                        * \param sep Caracter usado como separador.
+                        */
+                       std::vector<std::string> split(char sep) const;
+
+                       /**
+                        * Concatena los elementos de un vector.
+                        *
+                        * \param v   Vector.
+                        * \param sep Separador.
+                        */
+                       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;
+                       }
+
        };
 
 }
 
        };
 
 }
 
+}
+
 #endif // PLAQUI_STRING_H 
 #endif // PLAQUI_STRING_H