From 1ecd94c4708d811903b3bb5585fdc694821408fc Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 28 Aug 2017 00:04:57 +0200 Subject: [PATCH] [DEV] continue removing stl --- eproperty/Interface.hpp | 4 ++-- eproperty/InterfaceData.cpp | 24 ++++++++++++------------ eproperty/InterfaceData.hpp | 14 +++++++------- eproperty/List.hpp | 34 +++++++++++++++++----------------- eproperty/Property.cpp | 4 ++-- eproperty/Property.hpp | 24 ++++++++++++------------ eproperty/PropertyType.hpp | 18 +++++++++--------- eproperty/Range.hpp | 12 ++++++------ eproperty/Value.hpp | 10 +++++----- eproperty/details/Range.hxx | 10 +++++----- eproperty/details/Value.cpp | 4 ++-- eproperty/details/Value.hxx | 6 +++--- lutin_eproperty.py | 2 +- sample/sampleAll.cpp | 4 ++-- test/main.cpp | 2 +- 15 files changed, 86 insertions(+), 86 deletions(-) diff --git a/eproperty/Interface.hpp b/eproperty/Interface.hpp index eab8210..7d70540 100644 --- a/eproperty/Interface.hpp +++ b/eproperty/Interface.hpp @@ -7,8 +7,8 @@ */ #pragma once -#include -#include +#include +#include #include namespace eproperty { diff --git a/eproperty/InterfaceData.cpp b/eproperty/InterfaceData.cpp index 4095140..851ba1d 100644 --- a/eproperty/InterfaceData.cpp +++ b/eproperty/InterfaceData.cpp @@ -31,7 +31,7 @@ void eproperty::InterfaceData::add(eproperty::Property* _pointerOnProperty) { EPROPERTY_CRITICAL("2 property can not have the same name ... ==> generate runtime error"); } } - m_list.push_back(_pointerOnProperty); + m_list.pushBack(_pointerOnProperty); } void eproperty::InterfaceData::clean() { @@ -41,7 +41,7 @@ void eproperty::InterfaceData::clean() { // Note no lock is needed at this level, because the lock is done is the upper elements ... // the property set might be done with a pool of property, allone, the overhed is bigger ... -bool eproperty::InterfaceData::set(const std::string& _property, const std::string& _value) { +bool eproperty::InterfaceData::set(const etk::String& _property, const etk::String& _value) { for (auto &it : m_list) { if( it != nullptr && it->getName() == _property) { @@ -53,7 +53,7 @@ bool eproperty::InterfaceData::set(const std::string& _property, const std::stri return false; } -std::string eproperty::InterfaceData::get(const std::string& _property) const { +etk::String eproperty::InterfaceData::get(const etk::String& _property) const { for (auto &it : m_list) { if( it != nullptr && it->getName() == _property) { @@ -67,9 +67,9 @@ void eproperty::InterfaceData::display(bool _changeOnly) const { EPROPERTY_INFO(" Object propertys:"); for (auto &it : m_list) { if(it != nullptr) { - std::string paramName = it->getName(); - std::string paramVal = it->getString(); - std::string paramInfo = it->getInfo(); + etk::String paramName = it->getName(); + etk::String paramVal = it->getString(); + etk::String paramInfo = it->getInfo(); if ( _changeOnly == false || it->isDefault() == false) { EPROPERTY_INFO(" | param='" << paramName << "' value=" << paramVal << " (" << paramInfo << ")"); @@ -80,15 +80,15 @@ void eproperty::InterfaceData::display(bool _changeOnly) const { } } -std::map eproperty::InterfaceData::getAll(bool _notIfDefault) const { - std::map out; +etk::Map eproperty::InterfaceData::getAll(bool _notIfDefault) const { + etk::Map out; for (auto &it : m_list) { if(it != nullptr) { - std::string paramName = it->getName(); - std::string paramVal = it->getString(); + etk::String paramName = it->getName(); + etk::String paramVal = it->getString(); if ( _notIfDefault == false || it->isDefault() == false) { - out.insert(std::make_pair(paramName, paramVal)); + out.insert(etk::makePair(paramName, paramVal)); } } } @@ -108,7 +108,7 @@ eproperty::Property* eproperty::InterfaceData::getRaw(const size_t& _id) const { return m_list[_id]; } -eproperty::Property* eproperty::InterfaceData::getRaw(const std::string _name) const { +eproperty::Property* eproperty::InterfaceData::getRaw(const etk::String _name) const { for (auto &it : m_list) { if(it->getName() == _name) { return it; diff --git a/eproperty/InterfaceData.hpp b/eproperty/InterfaceData.hpp index 461268b..0885f60 100644 --- a/eproperty/InterfaceData.hpp +++ b/eproperty/InterfaceData.hpp @@ -7,8 +7,8 @@ */ #pragma once -#include -#include +#include +#include namespace eproperty { class Property; @@ -18,7 +18,7 @@ namespace eproperty { */ class InterfaceData { private: - std::vector m_list; //!< list of availlable Propertys (no need to free) + etk::Vector m_list; //!< list of availlable Propertys (no need to free) public: /** * @brief Constructor. @@ -46,13 +46,13 @@ namespace eproperty { * @return true Property update. * @return false Property not update. */ - bool set(const std::string& _property, const std::string& _value); + bool set(const etk::String& _property, const etk::String& _value); /** * @brief Get a specific value of the property reference name. * @param[in] _property The property string name. * @return The value of the property (string). */ - std::string get(const std::string& _property) const; + etk::String get(const etk::String& _property) const; /** * @brief Display all the property value with there name. * @param[in] _changeOnly check at true if the user want to display only property that are not at default value. @@ -63,7 +63,7 @@ namespace eproperty { * @param[in] _notIfDefault if true the parameter value with default value are not extracted. * @return map on the propertys */ - std::map getAll(bool _notIfDefault=true) const; + etk::Map getAll(bool _notIfDefault=true) const; public: /** * @brief Get count of propertys. @@ -81,7 +81,7 @@ namespace eproperty { * @param[in] _name name of the property. * @return pointer on the property. */ - eproperty::Property* getRaw(const std::string _name) const; + eproperty::Property* getRaw(const etk::String _name) const; }; } diff --git a/eproperty/List.hpp b/eproperty/List.hpp index 60e92c2..365dc86 100644 --- a/eproperty/List.hpp +++ b/eproperty/List.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include namespace eproperty { @@ -17,7 +17,7 @@ namespace eproperty { */ template class List : public PropertyType { private: - std::map m_list; //!< pointer on the list of all elements. + etk::Map m_list; //!< pointer on the list of all elements. public: /** * @brief Create a parameter with List of element parameter (nullptr if none). @@ -29,9 +29,9 @@ namespace eproperty { */ template List(CLASS_TYPE* _owner, - const std::string& _name, + const etk::String& _name, const TYPE& _defaultValue, - const std::string& _description="", + const etk::String& _description="", void (CLASS_TYPE::*_setObs)()=nullptr) : eproperty::PropertyType(_owner, _name, _defaultValue, _description, _setObs) { @@ -54,19 +54,19 @@ namespace eproperty { * @param[in] _name String of the value * @param[in] _description Description of the parameter value */ - void add(const TYPE& _value, const std::string& _name, const std::string& _description = "") { + void add(const TYPE& _value, const etk::String& _name, const etk::String& _description = "") { auto it = m_list.find(_name); if (it != m_list.end()) { it->second = _value; return; } - m_list.insert(std::make_pair(_name, _value)); + m_list.insert(etk::makePair(_name, _value)); } /** * @brief Remove a value of the element availlable * @param[in] _name Name of the value to remove */ - void remove(const std::string& _name) { + void remove(const etk::String& _name) { auto it = m_list.find(_name); bool firstValue = false; bool firstDefault = false; @@ -98,7 +98,7 @@ namespace eproperty { * @param[in] _nameOld Old property name to replace * @param[in] _nameNew New name of the property */ - void rename(const std::string& _nameOld, const std::string& _nameNew) { + void rename(const etk::String& _nameOld, const etk::String& _nameNew) { //get old value TYPE value; auto it = m_list.find(_nameOld); @@ -111,10 +111,10 @@ namespace eproperty { remove(_nameOld); add(value, _nameNew); } - std::string getPropertyType() const override { + etk::String getPropertyType() const override { return "eproperty::List"; } - void setString(const std::string& _newVal) override { + void setString(const etk::String& _newVal) override { auto it = m_list.find(_newVal); if (it != m_list.end()) { if (it->second != eproperty::PropertyType::m_value) { @@ -130,17 +130,17 @@ namespace eproperty { } #endif } - std::string getInfo() const override { - std::string list = "List default=" + getValueSpecific(eproperty::PropertyType::m_default) + " in : ["; + etk::String getInfo() const override { + etk::String list = "List default=" + getValueSpecific(eproperty::PropertyType::m_default) + " in : ["; for (auto &it : m_list) { list += it.first + "/"; } return list + "]"; } - std::vector getListValue() const override { - std::vector out; + etk::Vector getListValue() const override { + etk::Vector out; for (auto &it : m_list) { - out.push_back(it.first); + out.pushBack(it.first); } return out; } @@ -179,7 +179,7 @@ namespace eproperty { * @param[in] _intValue value that might be converted in string. * @return the description string coresponding to this ID. */ - std::string getValueSpecific(const TYPE& _valueRequested) const override { + etk::String getValueSpecific(const TYPE& _valueRequested) const override { for (auto &it : m_list) { if (it.second == _valueRequested) { return it.first; @@ -189,7 +189,7 @@ namespace eproperty { } }; //! @not_in_doc - template std::ostream& operator <<(std::ostream& _os, const eproperty::List& _obj) { + template etk::Stream& operator <<(etk::Stream& _os, const eproperty::List& _obj) { _os << _obj.get(); return _os; } diff --git a/eproperty/Property.cpp b/eproperty/Property.cpp index aeb50e7..10c93cf 100644 --- a/eproperty/Property.cpp +++ b/eproperty/Property.cpp @@ -11,7 +11,7 @@ #include -eproperty::Property::Property(eproperty::Interface* _paramInterfaceLink, const std::string& _name) : +eproperty::Property::Property(eproperty::Interface* _paramInterfaceLink, const etk::String& _name) : m_interfaceLink(_paramInterfaceLink), m_setObserver(), m_name(_name) { @@ -32,7 +32,7 @@ void eproperty::Property::setObserver(eproperty::Property::Observer _setObs) { m_setObserver = _setObs; } -std::string eproperty::Property::getName() const { +etk::String eproperty::Property::getName() const { return m_name; } diff --git a/eproperty/Property.hpp b/eproperty/Property.hpp index 092e2cb..884df63 100644 --- a/eproperty/Property.hpp +++ b/eproperty/Property.hpp @@ -8,7 +8,7 @@ #pragma once #include -#include +#include #include #include @@ -26,14 +26,14 @@ namespace eproperty { private: eproperty::Interface* m_interfaceLink; //!< Base interface class to group all the property Observer m_setObserver; //!< Observer of the changing value - std::string m_name; //!< Name of the property + etk::String m_name; //!< Name of the property public: /** * @brief Basic property elements * @param[in] _paramInterfaceLink Link on the esignal::Interface class to register parameter (can be nullptr) * @param[in] _name Name of the parameter (must be unique if _paramInterfaceLink is define) */ - Property(eproperty::Interface* _paramInterfaceLink, const std::string& _name); + Property(eproperty::Interface* _paramInterfaceLink, const etk::String& _name); /** * @brief Basic property elements */ @@ -58,37 +58,37 @@ namespace eproperty { * @brief Get the name of the Property. * @return The name of the Property */ - virtual std::string getName() const; + virtual etk::String getName() const; /** * @brief Description of the Propertys. * @return Descriptive information of the Property (for remote UI). */ - virtual std::string getInfo() const = 0; + virtual etk::String getInfo() const = 0; /** * @brief Get the Property type of the class in string mode. * @return The string type of the Property. */ - virtual std::string getPropertyType() const = 0; + virtual etk::String getPropertyType() const = 0; /** * @brief Get the type of the Property in string mode. * @return The string type of the Property. */ - virtual std::string getType() const = 0; + virtual etk::String getType() const = 0; /** * @brief Get the string of the current value of the Property. * @return The string description of the value. */ - virtual std::string getString() const = 0; + virtual etk::String getString() const = 0; /** * @brief Get the string of the default value of the Property. * @return the string decription of the default value. */ - virtual std::string getDefault() const = 0; + virtual etk::String getDefault() const = 0; /** * @brief Set a new value of the Property (with string interface). * @param[in] _newVal New value of the Propertys. */ - virtual void setString(const std::string& _newVal) = 0; + virtual void setString(const etk::String& _newVal) = 0; /** * @brief Check if the value is the default * @return true : the vakue is the default one, false otherwise. @@ -102,8 +102,8 @@ namespace eproperty { * @brief Specific for eproperty::List to get all the possible values * @return Descriptive information of the Property (for remote UI). */ - virtual std::vector getListValue() const { - return std::vector(); + virtual etk::Vector getListValue() const { + return etk::Vector(); } public: /** diff --git a/eproperty/PropertyType.hpp b/eproperty/PropertyType.hpp index 7c069ca..f990010 100644 --- a/eproperty/PropertyType.hpp +++ b/eproperty/PropertyType.hpp @@ -30,9 +30,9 @@ namespace eproperty { */ template PropertyType(CLASS_TYPE* _owner, - const std::string& _name, + const etk::String& _name, const TYPE& _defaultValue, - const std::string& _description = "", + const etk::String& _description = "", void (CLASS_TYPE::*_setObs)()=nullptr) : Property(_owner, _name), m_value(_defaultValue), @@ -54,19 +54,19 @@ namespace eproperty { * @brief Destructor. */ virtual ~PropertyType() = default; - std::string getPropertyType() const override { + etk::String getPropertyType() const override { return "eproperty::Value"; } - std::string getType() const override { + etk::String getType() const override { return typeid(TYPE).name(); } - std::string getString() const override { + etk::String getString() const override { return getValueSpecific(m_value); } - std::string getDefault() const override { + etk::String getDefault() const override { return getValueSpecific(m_default); } - std::string getInfo() const override { + etk::String getInfo() const override { return getType() + " default=" + getDefault(); } bool isDefault() const override { @@ -134,7 +134,7 @@ namespace eproperty { * @param[in] _valueRequested Value to convert in string * @return convertion of the value in string. */ - virtual std::string getValueSpecific(const TYPE& _valueRequested) const = 0; + virtual etk::String getValueSpecific(const TYPE& _valueRequested) const = 0; public: /** * @brief Const cast the property in the Type of the data @@ -165,7 +165,7 @@ namespace eproperty { PropertyType& operator= (const TYPE& _newVal) = delete; }; //! @not_in_doc - template std::ostream& operator <<(std::ostream& _os, const eproperty::PropertyType& _obj) { + template etk::Stream& operator <<(etk::Stream& _os, const eproperty::PropertyType& _obj) { _os << _obj.get(); return _os; } diff --git a/eproperty/Range.hpp b/eproperty/Range.hpp index 52d83a2..cb899df 100644 --- a/eproperty/Range.hpp +++ b/eproperty/Range.hpp @@ -33,11 +33,11 @@ namespace eproperty { */ template Range(CLASS_TYPE* _owner, - const std::string& _name, + const etk::String& _name, const TYPE& _defaultValue, const TYPE& _min, const TYPE& _max, - const std::string& _description = "", + const etk::String& _description = "", void (CLASS_TYPE::*_setObs)()=nullptr) : eproperty::Value(_owner, _name, _defaultValue, _description, _setObs), m_min(_min), @@ -59,15 +59,15 @@ namespace eproperty { * @brief Destructor. */ virtual ~Range() = default; - std::string getPropertyType() const override; - void setString(const std::string& _newVal) override; - std::string getInfo() const override; + etk::String getPropertyType() const override; + void setString(const etk::String& _newVal) override; + etk::String getInfo() const override; public: void set(const TYPE& _newVal) override; void setDirectCheck(const TYPE& _newVal) override; }; //! @not_in_doc - template std::ostream& operator <<(std::ostream& _os, const eproperty::Range& _obj) { + template etk::Stream& operator <<(etk::Stream& _os, const eproperty::Range& _obj) { _os << _obj.get(); return _os; } diff --git a/eproperty/Value.hpp b/eproperty/Value.hpp index ea60e0b..dbeb31c 100644 --- a/eproperty/Value.hpp +++ b/eproperty/Value.hpp @@ -29,9 +29,9 @@ namespace eproperty { */ template Value(CLASS_TYPE* _owner, - const std::string& _name, + const etk::String& _name, const TYPE& _defaultValue, - const std::string& _description = "", + const etk::String& _description = "", void (CLASS_TYPE::*_setObs)()=nullptr) : eproperty::PropertyType(_owner, _name, _defaultValue, _description, _setObs) { @@ -42,11 +42,11 @@ namespace eproperty { */ Value(const TYPE& _defaultValue); public: - std::string getValueSpecific(const TYPE& _valueRequested) const override; - void setString(const std::string& _newVal) override; + etk::String getValueSpecific(const TYPE& _valueRequested) const override; + void setString(const etk::String& _newVal) override; }; //! @not_in_doc - template std::ostream& operator <<(std::ostream& _os, const eproperty::Value& _obj) { + template etk::Stream& operator <<(etk::Stream& _os, const eproperty::Value& _obj) { _os << _obj.get(); return _os; } diff --git a/eproperty/details/Range.hxx b/eproperty/details/Range.hxx index 080abba..66d829b 100644 --- a/eproperty/details/Range.hxx +++ b/eproperty/details/Range.hxx @@ -23,12 +23,12 @@ eproperty::Range::Range(const TYPE& _defaultValue, } template -std::string eproperty::Range::getPropertyType() const { +etk::String eproperty::Range::getPropertyType() const { return "eproperty::Range"; } template -void eproperty::Range::setString(const std::string& _newVal) { +void eproperty::Range::setString(const etk::String& _newVal) { TYPE val; // when you want to set an element in parameter you will implement the function template std::from_string etk::from_string(val, _newVal); @@ -36,7 +36,7 @@ void eproperty::Range::setString(const std::string& _newVal) { } template -std::string eproperty::Range::getInfo() const { +etk::String eproperty::Range::getInfo() const { return eproperty::Value::getType() + " default=" + eproperty::Value::getDefault(); } @@ -48,7 +48,7 @@ void eproperty::Range::set(const TYPE& _newVal) { eproperty::Value::notifyChange(); } } else { - TYPE newVal = std::avg(m_min, _newVal, m_max); + TYPE newVal = etk::avg(m_min, _newVal, m_max); if (newVal != eproperty::Value::m_value) { eproperty::Value::m_value = newVal; eproperty::Value::notifyChange(); @@ -63,7 +63,7 @@ void eproperty::Range::setDirectCheck(const TYPE& _newVal) { eproperty::Value::m_value = _newVal; } } else { - TYPE newVal = std::avg(m_min, _newVal, m_max); + TYPE newVal = etk::avg(m_min, _newVal, m_max); if (newVal != eproperty::Value::m_value) { eproperty::Value::m_value = newVal; } diff --git a/eproperty/details/Value.cpp b/eproperty/details/Value.cpp index c069416..eaf8c2f 100644 --- a/eproperty/details/Value.cpp +++ b/eproperty/details/Value.cpp @@ -14,9 +14,9 @@ // void generic properties template class eproperty::Value; -template class eproperty::Value; +template class eproperty::Value; #if __CPP_VERSION__ >= 2011 - template class eproperty::Value; + template class eproperty::Value; #endif template class eproperty::Value; template class eproperty::Value; diff --git a/eproperty/details/Value.hxx b/eproperty/details/Value.hxx index 669ea47..7356152 100644 --- a/eproperty/details/Value.hxx +++ b/eproperty/details/Value.hxx @@ -17,12 +17,12 @@ eproperty::Value::Value(const TYPE& _defaultValue) : } template -std::string eproperty::Value::getValueSpecific(const TYPE& _valueRequested) const { - return etk::to_string(_valueRequested); +etk::String eproperty::Value::getValueSpecific(const TYPE& _valueRequested) const { + return etk::toString(_valueRequested); } template -void eproperty::Value::setString(const std::string& _newVal) { +void eproperty::Value::setString(const etk::String& _newVal) { // when you want to set an element in parameter you will implement the function template std::from_string etk::from_string(eproperty::PropertyType::m_value, _newVal); // TODO : Do it better ... diff --git a/lutin_eproperty.py b/lutin_eproperty.py index 03ec4bf..068030d 100644 --- a/lutin_eproperty.py +++ b/lutin_eproperty.py @@ -51,7 +51,7 @@ def configure(target, my_module): ]) my_module.add_path(".") my_module.add_flag('c++', [ - "-DEPROPERTY_VERSION=\"\\\"" + tools.version_to_string(get_version()) + "\\\"\"" + "-DEPROPERTY_VERSION=\"\\\"" + tools.version_toString(get_version()) + "\\\"\"" ]) return True diff --git a/sample/sampleAll.cpp b/sample/sampleAll.cpp index 291fb78..3932a7b 100644 --- a/sample/sampleAll.cpp +++ b/sample/sampleAll.cpp @@ -38,7 +38,7 @@ class sampleClassGroup : public eproperty::Interface { //! [eproperty_sample_declare_class_with_interface] public: //! [eproperty_sample_declare_class_property_value] - eproperty::Value propertyValue; //!< Simple property Value with type string + eproperty::Value propertyValue; //!< Simple property Value with type string //! [eproperty_sample_declare_class_property_value] //! [eproperty_sample_declare_class_property_list] eproperty::List propertyList; //!< Simple property List with type enumeration @@ -101,7 +101,7 @@ class sampleClassGroup : public eproperty::Interface { //! [eproperty_sample_class_without_interface] class sampleClassSolo { public: - eproperty::Value propertyValue; + eproperty::Value propertyValue; eproperty::List propertyList; eproperty::Range propertyRange; sampleClassSolo(): diff --git a/test/main.cpp b/test/main.cpp index 578536e..99a5770 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -16,7 +16,7 @@ int main(int _argc, const char *_argv[]) { ::testing::InitGoogleTest(&_argc, const_cast(_argv)); etk::init(_argc, _argv); for (int32_t iii=0; iii<_argc ; ++iii) { - std::string data = _argv[iii]; + etk::String data = _argv[iii]; if ( data == "-h" || data == "--help") { TEST_PRINT("eproperty-test - help : ");