Add String ToLower, ToUpper, change Trim

fixes #9704 #9944
This commit is contained in:
Jean Flach 2015-08-27 15:50:14 +02:00
parent f2a055c85a
commit 5bbc8cacbd
2 changed files with 22 additions and 6 deletions

View File

@ -21,7 +21,6 @@
#include "base/value.hpp" #include "base/value.hpp"
#include "base/primitivetype.hpp" #include "base/primitivetype.hpp"
#include "base/dictionary.hpp" #include "base/dictionary.hpp"
#include <boost/algorithm/string/trim.hpp>
#include <ostream> #include <ostream>
using namespace icinga; using namespace icinga;
@ -36,7 +35,3 @@ String& String::operator+=(const Value& rhs)
return *this; return *this;
} }
void String::Trim(void)
{
boost::algorithm::trim(m_Data);
}

View File

@ -22,6 +22,8 @@
#include "base/i2-base.hpp" #include "base/i2-base.hpp"
#include "base/object.hpp" #include "base/object.hpp"
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/range/iterator.hpp> #include <boost/range/iterator.hpp>
#include <string.h> #include <string.h>
#include <functional> #include <functional>
@ -211,7 +213,26 @@ public:
m_Data.replace(first, second, str); m_Data.replace(first, second, str);
} }
void Trim(void); inline String Trim(void) const
{
String t = m_Data;
boost::algorithm::trim(t);
return t;
}
inline String ToLower(void) const
{
String t = m_Data;
boost::algorithm::to_lower(t);
return t;
}
inline String ToUpper(void) const
{
String t = m_Data;
boost::algorithm::to_upper(t);
return t;
}
inline bool Contains(const String& str) const inline bool Contains(const String& str) const
{ {