Loading src/TNL/String.h +127 −133 Original line number Diff line number Diff line Loading @@ -25,56 +25,42 @@ class String; template< typename T > String convertToString( const T& value ); //! Class for managing strings ///// // \brief Class for managing strings class String { //! Pointer to char ended with zero char* string; //! Length of the allocated piece of memory int length; public: //! Basic constructor String(); //! Constructor from const char* String( const char* str ); ///// /// \brief Basic constructor String(); ////// /// Constructor with char pointer /// ///// /// \brief Constructor with char pointer. /// Constructor with char pointer. /// @param prefix_cut_off says length of the prefix that is going to be omitted and /// @param sufix_cut_off says the same about sufix. /// @param sufix_cut_off says the same about suffix. String( const char* c, int prefix_cut_off, int prefix_cut_off = 0, int sufix_cut_off = 0 ); static String getType(); //! Copy constructor String( const String& str ); ////// /// Templated constructor /// /// It must be explicit otherwise it is called recursively from inside of its /// definition ( in operator << ). It leads to stack overflow and segmentation fault. //! Convert anything to a string template< typename T > explicit String( const T& value ) String( T value ) : string( nullptr ), length( 0 ) { std::stringstream str; str << value; setString( str.str().data() ); setString( convertToString( value ).getString() ); } String( const bool b ); //! Destructor ~String(); static String getType(); //! Return length of the string int getLength() const; int getSize() const; Loading Loading @@ -160,6 +146,14 @@ public: bool getLine( std::istream& stream ); friend std::ostream& operator<<( std::ostream& stream, const String& str ); protected: //! Pointer to char ended with zero char* string; //! Length of the allocated piece of memory int length; }; String operator+( char string1, const String& string2 ); Loading Loading
src/TNL/String.h +127 −133 Original line number Diff line number Diff line Loading @@ -25,56 +25,42 @@ class String; template< typename T > String convertToString( const T& value ); //! Class for managing strings ///// // \brief Class for managing strings class String { //! Pointer to char ended with zero char* string; //! Length of the allocated piece of memory int length; public: //! Basic constructor String(); //! Constructor from const char* String( const char* str ); ///// /// \brief Basic constructor String(); ////// /// Constructor with char pointer /// ///// /// \brief Constructor with char pointer. /// Constructor with char pointer. /// @param prefix_cut_off says length of the prefix that is going to be omitted and /// @param sufix_cut_off says the same about sufix. /// @param sufix_cut_off says the same about suffix. String( const char* c, int prefix_cut_off, int prefix_cut_off = 0, int sufix_cut_off = 0 ); static String getType(); //! Copy constructor String( const String& str ); ////// /// Templated constructor /// /// It must be explicit otherwise it is called recursively from inside of its /// definition ( in operator << ). It leads to stack overflow and segmentation fault. //! Convert anything to a string template< typename T > explicit String( const T& value ) String( T value ) : string( nullptr ), length( 0 ) { std::stringstream str; str << value; setString( str.str().data() ); setString( convertToString( value ).getString() ); } String( const bool b ); //! Destructor ~String(); static String getType(); //! Return length of the string int getLength() const; int getSize() const; Loading Loading @@ -160,6 +146,14 @@ public: bool getLine( std::istream& stream ); friend std::ostream& operator<<( std::ostream& stream, const String& str ); protected: //! Pointer to char ended with zero char* string; //! Length of the allocated piece of memory int length; }; String operator+( char string1, const String& string2 ); Loading