diff --git a/include/exiv2/ini.hpp b/include/exiv2/ini.hpp index b3b1c9b0..c1749a3b 100755 --- a/include/exiv2/ini.hpp +++ b/include/exiv2/ini.hpp @@ -175,8 +175,7 @@ public: @return value */ - std::string Get(std::string section, std::string name, - std::string default_value); + std::string Get(const std::string& section, const std::string& name, const std::string& default_value); /*! @brief Get an integer (long) value from INI file, returning default_value if not found or not a valid integer (decimal "1234", "-1234", or hex "0x4d2"). @@ -187,7 +186,7 @@ public: @return value */ - long GetInteger(std::string section, std::string name, long default_value); + long GetInteger(const std::string& section, const std::string& name, long default_value); /*! @brief Get a real (floating point double) value from INI file, returning default_value if not found or not a valid floating point value @@ -199,7 +198,7 @@ public: @return value */ - double GetReal(std::string section, std::string name, double default_value); + double GetReal(const std::string& section, const std::string& name, double default_value); /*! @brief Get a boolean value from INI file, returning default_value if not found or if not a valid true/false value. Valid true values are "true", "yes", "on", "1", @@ -211,12 +210,13 @@ public: @return value */ - bool GetBoolean(std::string section, std::string name, bool default_value); + bool GetBoolean(const std::string& section, const std::string& name, bool default_value); private: int _error; //!< status std::map _values; //!< values from file - static std::string MakeKey(std::string section, std::string name); //!< return key encoded from section/name + static std::string MakeKey(const std::string& section, + const std::string& name); //!< return key encoded from section/name static int ValueHandler(void* user, const char* section, const char* name, const char* value); //!< value handler }; diff --git a/samples/Jzon.cpp b/samples/Jzon.cpp index 0c150969..76890fb2 100644 --- a/samples/Jzon.cpp +++ b/samples/Jzon.cpp @@ -458,7 +458,7 @@ namespace Jzon { children.push_back(NamedNodePtr(name, node.GetCopy())); } - void Object::Add(const std::string &name, Value node) + void Object::Add(const std::string &name, const Value &node) { children.push_back(NamedNodePtr(name, new Value(node))); } @@ -570,7 +570,7 @@ namespace Jzon { children.push_back(node.GetCopy()); } - void Array::Add(Value node) + void Array::Add(const Value &node) { children.push_back(new Value(node)); } diff --git a/samples/Jzon.h b/samples/Jzon.h index b784c320..d8230ce9 100644 --- a/samples/Jzon.h +++ b/samples/Jzon.h @@ -251,9 +251,9 @@ namespace Jzon Type GetType() const override; void Add(const std::string &name, Node &node); - void Add(const std::string &name, Value node); - void Remove(const std::string &name); - void Clear(); + void Add(const std::string &name, const Value &node); + void Remove(const std::string &name); + void Clear(); iterator begin(); const_iterator begin() const; @@ -319,9 +319,9 @@ namespace Jzon Type GetType() const override; void Add(Node &node); - void Add(Value node); - void Remove(size_t index); - void Clear(); + void Add(const Value &node); + void Remove(size_t index); + void Clear(); iterator begin(); const_iterator begin() const; diff --git a/samples/exiv2json.cpp b/samples/exiv2json.cpp index 968038ff..4bf8584c 100644 --- a/samples/exiv2json.cpp +++ b/samples/exiv2json.cpp @@ -91,7 +91,7 @@ bool getToken(std::string& in,Token& token, std::set* pNS=NULL) return result; } -Jzon::Node& addToTree(Jzon::Node& r1,Token token) +Jzon::Node& addToTree(Jzon::Node& r1, const Token& token) { Jzon::Object object ; Jzon::Array array ; diff --git a/samples/geotag.cpp b/samples/geotag.cpp index 5fa5a726..417291bc 100644 --- a/samples/geotag.cpp +++ b/samples/geotag.cpp @@ -670,7 +670,7 @@ bool sina(const char* s,const char** a) return bResult; } -int readFile(const char* path,Options /* options */) +int readFile(const char* path, const Options& /* options */) { FILE* f = fopen(path,"r"); int nResult = f ? typeFile : typeUnknown; diff --git a/samples/key-test.cpp b/samples/key-test.cpp index 4eb43459..6922a96d 100644 --- a/samples/key-test.cpp +++ b/samples/key-test.cpp @@ -87,7 +87,7 @@ int main() // ----- // Copy constructor - ExifKey ek2(ek); + const ExifKey& ek2(ek); // operator<< tc += 1; diff --git a/samples/taglist.cpp b/samples/taglist.cpp index 683c75c8..ed6a0e18 100644 --- a/samples/taglist.cpp +++ b/samples/taglist.cpp @@ -68,8 +68,7 @@ int main(int argc, char* argv[]) std::istringstream input(tags.str()) ; while (std::getline(input, line)) { std::cout << groupList->groupName_ << "." - << (item == "all" ? line.substr(0,line.find(",")) : line) - << std::endl; + << (item == "all" ? line.substr(0, line.find(',')) : line) << std::endl; } groupList++; } diff --git a/src/actions.cpp b/src/actions.cpp index b886a12c..536b80af 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -150,7 +150,7 @@ namespace { with os << make_pair( myString, width) */ - std::ostream& operator<<( std::ostream& os, std::pair strAndWidth); + std::ostream& operator<<(std::ostream& os, const std::pair& strAndWidth); //! Print image Structure information int printStructure(std::ostream& out, Exiv2::PrintStructureOption option, const std::string &path); @@ -2175,7 +2175,7 @@ namespace { return 0; } - std::ostream& operator<<( std::ostream& os, std::pair strAndWidth) + std::ostream& operator<<(std::ostream& os, const std::pair& strAndWidth) { const std::string& str( strAndWidth.first); size_t minChCount( strAndWidth.second); diff --git a/src/ini.cpp b/src/ini.cpp index bea9e080..7b66f441 100755 --- a/src/ini.cpp +++ b/src/ini.cpp @@ -238,13 +238,13 @@ int INIReader::ParseError() const return _error; } -string INIReader::Get(string section, string name, string default_value) +string INIReader::Get(const string& section, const string& name, const string& default_value) { string key = MakeKey(section, name); return _values.count(key) ? _values[key] : default_value; } -long INIReader::GetInteger(string section, string name, long default_value) +long INIReader::GetInteger(const string& section, const string& name, long default_value) { string valstr = Get(section, name, ""); const char* value = valstr.c_str(); @@ -254,7 +254,7 @@ long INIReader::GetInteger(string section, string name, long default_value) return end > value ? n : default_value; } -double INIReader::GetReal(string section, string name, double default_value) +double INIReader::GetReal(const string& section, const string& name, double default_value) { string valstr = Get(section, name, ""); const char* value = valstr.c_str(); @@ -263,7 +263,7 @@ double INIReader::GetReal(string section, string name, double default_value) return end > value ? n : default_value; } -bool INIReader::GetBoolean(string section, string name, bool default_value) +bool INIReader::GetBoolean(const string& section, const string& name, bool default_value) { string valstr = Get(section, name, ""); // Convert to lower case to make string comparisons case-insensitive @@ -275,7 +275,7 @@ bool INIReader::GetBoolean(string section, string name, bool default_value) return default_value; } -string INIReader::MakeKey(string section, string name) +string INIReader::MakeKey(const string& section, const string& name) { string key = section + "=" + name; // Convert to lower case to make section/name lookups case-insensitive diff --git a/src/pngchunk_int.cpp b/src/pngchunk_int.cpp index 81c70886..42e61ba0 100644 --- a/src/pngchunk_int.cpp +++ b/src/pngchunk_int.cpp @@ -240,10 +240,7 @@ namespace Exiv2 { } // PngChunk::parsePngChunk - void PngChunk::parseChunkContent( Image* pImage, - const byte* key, - long keySize, - const DataBuf arr) + void PngChunk::parseChunkContent(Image* pImage, const byte* key, long keySize, const DataBuf& arr) { // We look if an ImageMagick EXIF raw profile exist. diff --git a/src/pngchunk_int.hpp b/src/pngchunk_int.hpp index 4901dc7a..018eae67 100644 --- a/src/pngchunk_int.hpp +++ b/src/pngchunk_int.hpp @@ -131,10 +131,7 @@ namespace Exiv2 { Xmp packet generated by Adobe ==> Image Xmp metadata. Description string ==> Image Comments. */ - static void parseChunkContent( Image* pImage, - const byte* key, - long keySize, - const DataBuf arr); + static void parseChunkContent(Image* pImage, const byte* key, long keySize, const DataBuf& arr); /*! @brief Return a compressed (zTXt) or uncompressed (tEXt) PNG ASCII text chunk diff --git a/src/xmpsidecar.cpp b/src/xmpsidecar.cpp index 5d6a4326..4a71ae3a 100644 --- a/src/xmpsidecar.cpp +++ b/src/xmpsidecar.cpp @@ -119,7 +119,7 @@ namespace Exiv2 { return b; } - static bool matchi(const std::string key,const char* substr) + static bool matchi(const std::string& key, const char* substr) { return toLowerCase(key).find(substr) != std::string::npos; } diff --git a/unitTests/test_XmpKey.cpp b/unitTests/test_XmpKey.cpp index f2ebe26a..f204c24d 100644 --- a/unitTests/test_XmpKey.cpp +++ b/unitTests/test_XmpKey.cpp @@ -75,7 +75,7 @@ TEST_F(AXmpKey, correctlyInstantiatedWithValidPrefixAndProperty) TEST_F(AXmpKey, canBeCopiedConstructed) { XmpKey key(expectedPrefix, expectedProperty); - XmpKey copiedKey(key); + const XmpKey& copiedKey(key); checkValidity(copiedKey); }