Commit 793e8c13 authored by Bryan Berthou's avatar Bryan Berthou
Browse files

refs#16

In ElementaryUtils :
- Remove fromStringTo[...] conversion method from StringUtils cause of casting problem.
- Propagate change in LoggerManager
parent 83a2201d
......@@ -7,8 +7,6 @@
* @author <contibutor> http://stackoverflow.com/questions/12261915/howto-throw-stdexceptions-with-variable-messages/12262626#12262626
* @date 16 September 2014
* @version 1.0
*
* @class Formatter
*/
#include <iomanip>
......@@ -17,6 +15,10 @@
namespace ElemUtils {
/** @class Formatter
*
* @brief
*/
class Formatter {
public:
Formatter() {
......
#ifndef STRING_UTILS_H
#define STRING_UTILS_H
/*!
* \file StringUtils.h
* \brief Manipulations et traitements sur les chaines de caracteres
* \author Bryan BERTHOU
* \version 0.1
* \date Creation : 28/04/2009
* \date Derniere maj : /09/2014
/**
* @file StringUtils.h
* @author Bryan BERTHOU
* @version 0.1
* @date Creation : 28/04/2009
* @date Derniere maj : 30/06/2016
*/
//#include <map>
#include <string>
#include <utility>
#include <vector>
......@@ -19,8 +17,10 @@
namespace ElemUtils {
/*!
* \class StringUtils
/**
* @class StringUtils
*
* @brief Manipulations et traitements sur les chaines de caracteres
*/
class StringUtils {
......@@ -55,30 +55,6 @@ public:
static bool equalsIgnoreCase(const std::string &chaine,
const std::string &chaine2, const bool &toUpperCase = true);
// /*!
// * \fn static std::string fromIntToString( int _nombre )
// * \brief Convertie un nombre en chaine de caracteres
// * \param _nombre : nombre a convertir en chaine de caracteres
// * \return std::string
// */
// static std::string fromIntToString(int number);
/*!
* \fn static int fromStringToInt( std::string _chaine )
* \brief Convertie une chaine de caracteres en entier
* \param _chaine : chaine a convertir en entier
* \return int
*/
static int fromStringToInt(std::string chaine);
//static unsigned int fromStringToUnsignedInt(const std::string & chaine);
static float fromStringToFloat(std::string chaine);
static double fromStringToDouble(const std::string & str);
static bool fromStringToBool(std::string chaine);
static bool contains(const std::string & str,
const std::string & searchString);
......
......@@ -9,6 +9,7 @@
#include "../../../include/ElementaryUtils/file_utils/FileUtils.h"
#include "../../../include/ElementaryUtils/logger/LoggerMessage.h"
#include "../../../include/ElementaryUtils/parameters/GenericType.h"
#include "../../../include/ElementaryUtils/parser/IniFileParser.h"
#include "../../../include/ElementaryUtils/PropertiesManager.h"
#include "../../../include/ElementaryUtils/string_utils/Formatter.h"
......@@ -68,7 +69,7 @@ void LoggerManager::parseConfigurationFile(const std::string &filePath) {
for (it = data.begin(); it != data.end(); it++) {
if (StringUtils::equalsIgnoreCase(it->first, ENABLE_NAME)) {
m_active = StringUtils::fromStringToBool(it->second);
m_active = GenericType(it->second).toBoolean();
}
// retrieve default level value
else if (StringUtils::equalsIgnoreCase(it->first, DEFAULT_LEVEL_NAME)) {
......
......@@ -45,42 +45,6 @@ void StringUtils::to_lowerCase(std::string* chaine) {
std::transform(chaine->begin(), chaine->end(), chaine->begin(), tolower);
}
//std::string StringUtils::fromIntToString(int number) {
// std::ostringstream oss;
// oss << number;
//
// return oss.str();
//}
int StringUtils::fromStringToInt(std::string chaine) {
return atoi(chaine.c_str());
}
//unsigned int StringUtils::fromStringToUnsignedInt(const std::string & chaine) {
// return stoul(chaine.c_str());
//}
float StringUtils::fromStringToFloat(std::string chaine) {
return static_cast<float>(atof(chaine.c_str()));
}
double StringUtils::fromStringToDouble(const std::string & str) {
//return *reinterpret_cast<double*>(str);
// std::stringstream stream;
// stream << str;
// double d = 0.;
// stream >> d;
// return d;
//TODO http://stackoverflow.com/questions/22543349/what-is-wrong-with-the-following-code-it-converts-double-to-string-without-usin
// deprecated
// return atof(str.c_str());
return strtod(str.c_str(), NULL);
}
std::pair<std::string, std::vector<char> > StringUtils::fromStringToArrayOfChar(
const std::string &string) {
......@@ -112,11 +76,6 @@ std::pair<std::string, std::vector<char> > StringUtils::fromStringToArrayOfChar(
return result;
}
bool StringUtils::fromStringToBool(std::string chaine) {
to_upperCase(chaine);
return (chaine == "TRUE") ? true : false;
}
bool StringUtils::contains(const std::string & str,
const std::string & searchString) {
return (str.find(searchString) != std::string::npos) ? true : false;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment