[DEV] continue removing stl

This commit is contained in:
Edouard DUPIN 2017-08-28 00:04:57 +02:00
parent f583c09c56
commit 1ecd94c470
15 changed files with 86 additions and 86 deletions

View File

@ -7,8 +7,8 @@
*/
#pragma once
#include <vector>
#include <map>
#include <etk/Vector.hpp>
#include <etk/Map.hpp>
#include <eproperty/InterfaceData.hpp>
namespace eproperty {

View File

@ -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<std::string, std::string> eproperty::InterfaceData::getAll(bool _notIfDefault) const {
std::map<std::string, std::string> out;
etk::Map<etk::String, etk::String> eproperty::InterfaceData::getAll(bool _notIfDefault) const {
etk::Map<etk::String, etk::String> 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;

View File

@ -7,8 +7,8 @@
*/
#pragma once
#include <vector>
#include <map>
#include <etk/Vector.hpp>
#include <etk/Map.hpp>
namespace eproperty {
class Property;
@ -18,7 +18,7 @@ namespace eproperty {
*/
class InterfaceData {
private:
std::vector<eproperty::Property*> m_list; //!< list of availlable Propertys (no need to free)
etk::Vector<eproperty::Property*> 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<std::string, std::string> getAll(bool _notIfDefault=true) const;
etk::Map<etk::String, etk::String> 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;
};
}

View File

@ -8,7 +8,7 @@
#pragma once
#include <eproperty/PropertyType.hpp>
#include <map>
#include <etk/Map.hpp>
#include <typeinfo>
namespace eproperty {
@ -17,7 +17,7 @@ namespace eproperty {
*/
template<class TYPE> class List : public PropertyType<TYPE> {
private:
std::map<std::string, TYPE> m_list; //!< pointer on the list of all elements.
etk::Map<etk::String, TYPE> 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<class CLASS_TYPE>
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<TYPE>(_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<TYPE>::m_value) {
@ -130,17 +130,17 @@ namespace eproperty {
}
#endif
}
std::string getInfo() const override {
std::string list = "List default=" + getValueSpecific(eproperty::PropertyType<TYPE>::m_default) + " in : [";
etk::String getInfo() const override {
etk::String list = "List default=" + getValueSpecific(eproperty::PropertyType<TYPE>::m_default) + " in : [";
for (auto &it : m_list) {
list += it.first + "/";
}
return list + "]";
}
std::vector<std::string> getListValue() const override {
std::vector<std::string> out;
etk::Vector<etk::String> getListValue() const override {
etk::Vector<etk::String> 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<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::List<TYPE>& _obj) {
template<typename TYPE> etk::Stream& operator <<(etk::Stream& _os, const eproperty::List<TYPE>& _obj) {
_os << _obj.get();
return _os;
}

View File

@ -11,7 +11,7 @@
#include <eproperty/Property.hpp>
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;
}

View File

@ -8,7 +8,7 @@
#pragma once
#include <eproperty/Interface.hpp>
#include <string>
#include <etk/String.hpp>
#include <typeinfo>
#include <functional>
@ -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<std::string> getListValue() const {
return std::vector<std::string>();
virtual etk::Vector<etk::String> getListValue() const {
return etk::Vector<etk::String>();
}
public:
/**

View File

@ -30,9 +30,9 @@ namespace eproperty {
*/
template<class CLASS_TYPE>
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<TYPE>& operator= (const TYPE& _newVal) = delete;
};
//! @not_in_doc
template<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::PropertyType<TYPE>& _obj) {
template<typename TYPE> etk::Stream& operator <<(etk::Stream& _os, const eproperty::PropertyType<TYPE>& _obj) {
_os << _obj.get();
return _os;
}

View File

@ -33,11 +33,11 @@ namespace eproperty {
*/
template<class CLASS_TYPE>
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<TYPE>(_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<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::Range<TYPE>& _obj) {
template<typename TYPE> etk::Stream& operator <<(etk::Stream& _os, const eproperty::Range<TYPE>& _obj) {
_os << _obj.get();
return _os;
}

View File

@ -29,9 +29,9 @@ namespace eproperty {
*/
template<class CLASS_TYPE>
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<TYPE>(_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<typename TYPE> std::ostream& operator <<(std::ostream& _os, const eproperty::Value<TYPE>& _obj) {
template<typename TYPE> etk::Stream& operator <<(etk::Stream& _os, const eproperty::Value<TYPE>& _obj) {
_os << _obj.get();
return _os;
}

View File

@ -23,12 +23,12 @@ eproperty::Range<TYPE>::Range(const TYPE& _defaultValue,
}
template<class TYPE>
std::string eproperty::Range<TYPE>::getPropertyType() const {
etk::String eproperty::Range<TYPE>::getPropertyType() const {
return "eproperty::Range";
}
template<class TYPE>
void eproperty::Range<TYPE>::setString(const std::string& _newVal) {
void eproperty::Range<TYPE>::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<TYPE>::setString(const std::string& _newVal) {
}
template<class TYPE>
std::string eproperty::Range<TYPE>::getInfo() const {
etk::String eproperty::Range<TYPE>::getInfo() const {
return eproperty::Value<TYPE>::getType() + " default=" + eproperty::Value<TYPE>::getDefault();
}
@ -48,7 +48,7 @@ void eproperty::Range<TYPE>::set(const TYPE& _newVal) {
eproperty::Value<TYPE>::notifyChange();
}
} else {
TYPE newVal = std::avg(m_min, _newVal, m_max);
TYPE newVal = etk::avg(m_min, _newVal, m_max);
if (newVal != eproperty::Value<TYPE>::m_value) {
eproperty::Value<TYPE>::m_value = newVal;
eproperty::Value<TYPE>::notifyChange();
@ -63,7 +63,7 @@ void eproperty::Range<TYPE>::setDirectCheck(const TYPE& _newVal) {
eproperty::Value<TYPE>::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<TYPE>::m_value) {
eproperty::Value<TYPE>::m_value = newVal;
}

View File

@ -14,9 +14,9 @@
// void generic properties
template class eproperty::Value<bool>;
template class eproperty::Value<std::string>;
template class eproperty::Value<etk::String>;
#if __CPP_VERSION__ >= 2011
template class eproperty::Value<std::u32string>;
template class eproperty::Value<etk::UString>;
#endif
template class eproperty::Value<int64_t>;
template class eproperty::Value<int32_t>;

View File

@ -17,12 +17,12 @@ eproperty::Value<TYPE>::Value(const TYPE& _defaultValue) :
}
template<class TYPE>
std::string eproperty::Value<TYPE>::getValueSpecific(const TYPE& _valueRequested) const {
return etk::to_string(_valueRequested);
etk::String eproperty::Value<TYPE>::getValueSpecific(const TYPE& _valueRequested) const {
return etk::toString(_valueRequested);
}
template<class TYPE>
void eproperty::Value<TYPE>::setString(const std::string& _newVal) {
void eproperty::Value<TYPE>::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<TYPE>::m_value, _newVal);
// TODO : Do it better ...

View File

@ -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

View File

@ -38,7 +38,7 @@ class sampleClassGroup : public eproperty::Interface {
//! [eproperty_sample_declare_class_with_interface]
public:
//! [eproperty_sample_declare_class_property_value]
eproperty::Value<std::string> propertyValue; //!< Simple property Value with type string
eproperty::Value<etk::String> propertyValue; //!< Simple property Value with type string
//! [eproperty_sample_declare_class_property_value]
//! [eproperty_sample_declare_class_property_list]
eproperty::List<enum simpleEnum> 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<std::string> propertyValue;
eproperty::Value<etk::String> propertyValue;
eproperty::List<enum simpleEnum> propertyList;
eproperty::Range<int32_t> propertyRange;
sampleClassSolo():

View File

@ -16,7 +16,7 @@ int main(int _argc, const char *_argv[]) {
::testing::InitGoogleTest(&_argc, const_cast<char **>(_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 : ");