From: <pst...@us...> - 2013-01-06 22:49:38
|
Revision: 942 http://sourceforge.net/p/jazzplusplus/code/942 Author: pstieber Date: 2013-01-06 22:49:35 +0000 (Sun, 06 Jan 2013) Log Message: ----------- 1. Changed const char* to const std::string& in the JZConfigurationEntry constructors and removed and extra constructor for a string value. 2. Changed the return value for JZConfigurationEntry::GetValue from const int& to int. 3. Changed the return value for JZConfiguration::GetValue(const char* pName) and JZConfiguration::GetValue(int Index) from const int& to int. 4. Removed c_str() usage. 5. Changed const char* pNoneString to const string NoneString. Modified Paths: -------------- trunk/jazz/src/Configuration.cpp trunk/jazz/src/Configuration.h Modified: trunk/jazz/src/Configuration.cpp =================================================================== --- trunk/jazz/src/Configuration.cpp 2013-01-06 22:40:42 UTC (rev 941) +++ trunk/jazz/src/Configuration.cpp 2013-01-06 22:49:35 UTC (rev 942) @@ -46,66 +46,35 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- JZConfigurationEntry::JZConfigurationEntry( - const char* pName, + const string& Name, int IntegerValue) : mType(eConfigEntryTypeInt), - mName(), + mName(Name), mValue(IntegerValue), mStringValue() { - if (pName) - { - mName = pName; - } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- JZConfigurationEntry::JZConfigurationEntry( - const char* pName, - const char* pStringValue) + const string& Name, + const string& StringValue) : mType(eConfigEntryTypeStr), - mName(), + mName(Name), mValue(0), - mStringValue() + mStringValue(StringValue) { - if (pName) - { - mName = pName; - } - - if (pStringValue) - { - mStringValue = pStringValue; - } } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -JZConfigurationEntry::JZConfigurationEntry( - const char* pName, - const string& StringValue) -{ - if (pName) - { - mName = pName; - } - - mStringValue = StringValue; -} - -//----------------------------------------------------------------------------- -//----------------------------------------------------------------------------- -JZConfigurationEntry::JZConfigurationEntry(const char* pName) +JZConfigurationEntry::JZConfigurationEntry(const string& Name) : mType(eConfigEntryTypeEmpty), - mName(), + mName(Name), mValue(0), mStringValue() { - if (pName) - { - mName = pName; - } } //----------------------------------------------------------------------------- @@ -134,8 +103,6 @@ mNames[i] = 0; } - const char* pNoneString = "None"; - // search for midi device mNames[C_Seq2Device] = new JZConfigurationEntry(".device", -1); @@ -295,12 +262,12 @@ // Default synthesizer type. mNames[C_SynthType] = new JZConfigurationEntry( ".synth_type", - gSynthesizerTypes[SynthTypeGS].first.c_str()); + gSynthesizerTypes[SynthTypeGS].first); // Default synthesizer configuration file. mNames[C_SynthConfig] = new JZConfigurationEntry( ".synth_config", - gSynthesierTypeFiles[SynthTypeGS].first.c_str()); + gSynthesierTypeFiles[SynthTypeGS].first); // When to send synthesizer reset (0 = never, 1 = song start, // 2 = start play). @@ -337,7 +304,9 @@ mDrumNames.push_back(make_pair("", i)); } - mDrumSets.push_back(make_pair(pNoneString, 0)); + const string NoneString = "None"; + + mDrumSets.push_back(make_pair(NoneString, 0)); for (int i = 1; i < 130; ++i) { mDrumSets.push_back(make_pair("", i)); @@ -348,7 +317,7 @@ mControlNames.push_back(make_pair("", i)); } - mVoiceNames.push_back(make_pair(pNoneString, 0)); + mVoiceNames.push_back(make_pair(NoneString, 0)); mVoiceNames.push_back(make_pair("", 0)); } @@ -525,7 +494,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const int& JZConfiguration::GetValue(const char* pName) const +int JZConfiguration::GetValue(const char* pName) const { int i = Check(pName); @@ -536,7 +505,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -const int& JZConfiguration::GetValue(int Index) const +int JZConfiguration::GetValue(int Index) const { assert((Index >= 0) && (Index < NumConfigNames)); return mNames[Index]->GetValue(); Modified: trunk/jazz/src/Configuration.h =================================================================== --- trunk/jazz/src/Configuration.h 2013-01-06 22:40:42 UTC (rev 941) +++ trunk/jazz/src/Configuration.h 2013-01-06 22:49:35 UTC (rev 942) @@ -137,19 +137,19 @@ { public: - JZConfigurationEntry(const char* pName, int IntegerValue); + JZConfigurationEntry(const std::string& Name, int IntegerValue); - JZConfigurationEntry(const char* pName, const char* pStringValue); + JZConfigurationEntry( + const std::string& Name, + const std::string& StringValue); - JZConfigurationEntry(const char* pName, const std::string& StringValue); + JZConfigurationEntry(const std::string& Name); - JZConfigurationEntry(const char* pName); - TEConfigEntryType GetType() const; const std::string& GetName() const; - const int& GetValue() const; + int GetValue() const; void SetValue(const int& Value); @@ -188,7 +188,7 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- inline -const int& JZConfigurationEntry::GetValue() const +int JZConfigurationEntry::GetValue() const { return mValue; } @@ -236,8 +236,8 @@ const std::string& GetStrValue(int Entry) const; - const int& GetValue(const char* pName) const; - const int& GetValue(int Index) const; + int GetValue(const char* pName) const; + int GetValue(int Index) const; bool Get(int Entry, std::string& Value); bool Get(int Entry, int& Value); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |