1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/String.cc
17 #include "zypp/base/String.h"
19 ///////////////////////////////////////////////////////////////////
21 { /////////////////////////////////////////////////////////////////
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
26 /******************************************************************
28 ** FUNCTION NAME : form
29 ** FUNCTION TYPE : std::string
31 std::string form( const char * format, ... )
36 SafeBuf() : _buf( 0 ) {}
37 ~SafeBuf() { if ( _buf ) free( _buf ); }
38 std::string asString() const
39 { return _buf ? std::string(_buf) : std::string(); }
44 va_start( ap, format );
45 vasprintf( &safe._buf, format, ap );
48 return safe.asString();
51 /******************************************************************
53 ** FUNCTION NAME : toLower
54 ** FUNCTION TYPE : std::string
56 std::string toLower( const std::string & s )
62 for ( std::string::size_type i = 0; i < ret.length(); ++i )
64 if ( isupper( ret[i] ) )
65 ret[i] = static_cast<char>(tolower( ret[i] ));
70 /******************************************************************
72 ** FUNCTION NAME : toUpper
73 ** FUNCTION TYPE : std::string
75 std::string toUpper( const std::string & s )
81 for ( std::string::size_type i = 0; i < ret.length(); ++i )
83 if ( islower( ret[i] ) )
84 ret[i] = static_cast<char>(toupper( ret[i] ));
90 /////////////////////////////////////////////////////////////////
92 ///////////////////////////////////////////////////////////////////
93 ////////////////////////////////////////////////////////////////
95 //////////////////////////////////////////////////////////////////