Browse Source

Fixed const ARFF helper functions

Ioannis Agtzidis 5 years ago
parent
commit
0025b10097
3 changed files with 11 additions and 11 deletions
  1. 2 2
      arffHelper/Arff.cpp
  2. 5 5
      arffHelper/ArffBase.cpp
  3. 4 4
      arffHelper/ArffBase.h

+ 2 - 2
arffHelper/Arff.cpp

@@ -40,7 +40,7 @@ void Arff::ChangeData(int row, int column, double value)
     m_isChanged = true;
 }
 
-int Arff::WidthPx()
+int Arff::WidthPx() const
 {
     string value;
     if (GetMetadata("width_px", value))
@@ -54,7 +54,7 @@ void Arff::SetWidthPx(int width)
     SetMetadata("width_px", to_string(width));
 }
 
-int Arff::HeightPx()
+int Arff::HeightPx() const
 {
     string value;
     if (GetMetadata("height_px", value))

+ 5 - 5
arffHelper/ArffBase.cpp

@@ -112,14 +112,14 @@ void ArffBase::SetRelation(string relation)
     m_relation = relation;
 }
 
-string ArffBase::GetRelation()
+string ArffBase::GetRelation() const
 {
     return m_relation;
 }
 
-bool ArffBase::GetMetadata(const string& key, string& value)
+bool ArffBase::GetMetadata(const string& key, string& value) const
 {
-    map<string,string>::iterator it = m_mMetadata.find(key);
+    map<string,string>::const_iterator it = m_mMetadata.find(key);
     if (it != m_mMetadata.end())
     {
         value = it->second;
@@ -137,7 +137,7 @@ bool ArffBase::SetMetadata(const string &key, const string &value)
     return true;
 }
 
-bool ArffBase::GetAttMapping(const int &attIndex, vector<string>& values)
+bool ArffBase::GetAttMapping(const int &attIndex, vector<string>& values) const
 {
     values = m_vpAttributes.at(attIndex)->GetMapping();
     if (values.size() == 0)
@@ -146,7 +146,7 @@ bool ArffBase::GetAttMapping(const int &attIndex, vector<string>& values)
     return true;
 }
 
-bool ArffBase::GetAttMapping(const string &attName, vector<string>& values)
+bool ArffBase::GetAttMapping(const string &attName, vector<string>& values) const
 {
     int index = 0;
 

+ 4 - 4
arffHelper/ArffBase.h

@@ -39,16 +39,16 @@ public:
 
     void SetRelation(string relation);
 
-    string GetRelation();
+    string GetRelation() const;
 
-    bool GetMetadata(const string& key, string& value);
+    bool GetMetadata(const string& key, string& value) const;
 
     bool SetMetadata(const string &key, const string &value);
     ///< This function returns always true.
 
-    bool GetAttMapping(const int &attIndex, vector<string>& values);
+    bool GetAttMapping(const int &attIndex, vector<string>& values) const;
 
-    bool GetAttMapping(const string &attName, vector<string>& values);
+    bool GetAttMapping(const string &attName, vector<string>& values) const;
     ///< The values are the strings of the mapping to the doubles
     ///< in the data.