From 22107f21473f56e7f25f92c0afcff58d17a74218 Mon Sep 17 00:00:00 2001 From: srn Date: Mon, 6 Feb 2006 08:25:13 +0000 Subject: [PATCH] Added method getProperties --- src/SALOMEDS/SALOMEDS_IParameters.cxx | 32 ++++++++++++++++++++------- src/SALOMEDS/SALOMEDS_IParameters.hxx | 7 +++++- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/SALOMEDS/SALOMEDS_IParameters.cxx b/src/SALOMEDS/SALOMEDS_IParameters.cxx index c2743ab05..44911592a 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.cxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.cxx @@ -31,6 +31,10 @@ using namespace std; #define PT_INTARRAY 5 #define PT_STRARRAY 6 +#define _AP_LISTS_LIST_ "AP_LISTS_LIST" +#define _AP_ENTRIES_LIST_ "AP_ENTRIES_LIST" +#define _AP_PROPERTIES_LIST_ "AP_PROPERTIES_LIST" + /*! Constructor @@ -46,8 +50,11 @@ int SALOMEDS_IParameters::append(const string& listName, const string& value) if(!_ap) return -1; vector v; if(!_ap->IsSet(listName, PT_STRARRAY)) { - if(!_ap->IsSet("AP_LISTS_LIST", PT_STRARRAY)) _ap->SetStrArray("AP_LISTS_LIST", v); - append("AP_LISTS_LIST", listName); + if(!_ap->IsSet(_AP_LISTS_LIST_, PT_STRARRAY)) _ap->SetStrArray(_AP_LISTS_LIST_, v); + if(listName != _AP_ENTRIES_LIST_ && + listName != _AP_PROPERTIES_LIST_) { + append(_AP_LISTS_LIST_, listName); + } _ap->SetStrArray(listName, v); } v = _ap->GetStrArray(listName); @@ -85,8 +92,8 @@ string SALOMEDS_IParameters::getValue(const string& listName, int index) vector SALOMEDS_IParameters::getLists() { vector v; - if(!_ap->IsSet("AP_LISTS_LIST", PT_STRARRAY)) return v; - return _ap->GetStrArray("AP_LISTS_LIST"); + if(!_ap->IsSet(_AP_LISTS_LIST_, PT_STRARRAY)) return v; + return _ap->GetStrArray(_AP_LISTS_LIST_); } void SALOMEDS_IParameters::setParameter(const string& entry, const string& parameterName, const string& value) @@ -94,7 +101,7 @@ void SALOMEDS_IParameters::setParameter(const string& entry, const string& param if(!_ap) return; vector v; if(!_ap->IsSet(entry, PT_STRARRAY)) { - append("AP_ENTRIES_LIST", entry); //Add the entry to the internal list of entries + append(_AP_ENTRIES_LIST_, entry); //Add the entry to the internal list of entries _ap->SetStrArray(entry, v); } v = _ap->GetStrArray(entry); @@ -143,7 +150,6 @@ vector SALOMEDS_IParameters::getAllParameterValues(const string& entry) return values; } - int SALOMEDS_IParameters::getNbParameters(const string& entry) { if(!_ap) return -1; @@ -154,13 +160,16 @@ int SALOMEDS_IParameters::getNbParameters(const string& entry) vector SALOMEDS_IParameters::getEntries() { vector v; - if(!_ap->IsSet("AP_ENTRIES_LIST", PT_STRARRAY)) return v; - return _ap->GetStrArray("AP_ENTRIES_LIST"); + if(!_ap->IsSet(_AP_ENTRIES_LIST_, PT_STRARRAY)) return v; + return _ap->GetStrArray(_AP_ENTRIES_LIST_); } void SALOMEDS_IParameters::setProperty(const string& name, const std::string& value) { if(!_ap) return; + if(!_ap->IsSet(name, PT_STRING)) { + append(_AP_PROPERTIES_LIST_, name); //Add the property to the internal list of properties + } _ap->SetString(name, value); } @@ -171,6 +180,13 @@ string SALOMEDS_IParameters::getProperty(const string& name) return _ap->GetString(name); } +vector SALOMEDS_IParameters::getProperties() +{ + vector v; + if(!_ap->IsSet(_AP_PROPERTIES_LIST_, PT_STRARRAY)) return v; + return _ap->GetStrArray(_AP_PROPERTIES_LIST_); +} + vector SALOMEDS_IParameters::parseValue(const string& value, const char separator, bool fromEnd) { diff --git a/src/SALOMEDS/SALOMEDS_IParameters.hxx b/src/SALOMEDS/SALOMEDS_IParameters.hxx index f67c8e297..e3096bcc6 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.hxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.hxx @@ -85,7 +85,7 @@ public: int getNbParameters(const std::string& entry); /*! - Returns a list all entries entry + Returns a list all entries */ std::vector getEntries(); @@ -99,6 +99,11 @@ public: */ std::string getProperty(const std::string& name); + /*! + Returns a list all properties + */ + std::vector getProperties(); + /*! Breaks a value string in two parts which is divided %separator. If fromEnd is True the search of separator starts from the end of the string -- 2.39.2