diff options
author | Chris Kühl <chrisk@openismus.com> | 2011-06-18 01:29:27 +0200 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2011-08-26 12:52:15 +0200 |
commit | 966b29ff261fb8868eac8146ca9cd64802ff1de6 (patch) | |
tree | ae2216d9595b2686ebbb8d9d3cbfb34a1eb986d7 | |
parent | d8931235924d5c69cab8b7232f22ea4c93b9aaff (diff) |
syncevo: Clean up namespace pollution.
Removed all the "using namespace std;" statements from the header
files and made corrosponding changes. Where needed added "using
namespace std;" statement to the implementation files.
35 files changed, 411 insertions, 416 deletions
diff --git a/src/syncevo/Cmdline.cpp b/src/syncevo/Cmdline.cpp index 4e8c8af3..3653af20 100644 --- a/src/syncevo/Cmdline.cpp +++ b/src/syncevo/Cmdline.cpp @@ -47,7 +47,9 @@ using namespace std; #include <boost/foreach.hpp> #include <boost/range.hpp> #include <fstream> + #include <syncevo/declarations.h> +using namespace std; SE_BEGIN_CXX // synopsis and options char strings diff --git a/src/syncevo/Cmdline.h b/src/syncevo/Cmdline.h index 4da76e4e..f3c379b9 100644 --- a/src/syncevo/Cmdline.h +++ b/src/syncevo/Cmdline.h @@ -25,7 +25,6 @@ #include <syncevo/util.h> #include <set> -using namespace std; #include <boost/shared_ptr.hpp> #include <boost/scoped_array.hpp> @@ -44,24 +43,24 @@ class CmdlineTest; */ class CmdlineLUID { - string m_encodedLUID; + std::string m_encodedLUID; public: /** fill with encoded LUID */ - void setEncoded(const string &encodedLUID) { m_encodedLUID = encodedLUID; } + void setEncoded(const std::string &encodedLUID) { m_encodedLUID = encodedLUID; } /** return encoded LUID as string */ - string getEncoded() const { return m_encodedLUID; } + std::string getEncoded() const { return m_encodedLUID; } /** return original LUID */ - string toLUID() const { return toLUID(m_encodedLUID); } - static string toLUID(const string &encoded) { return StringEscape::unescape(encoded, '%'); } + std::string toLUID() const { return toLUID(m_encodedLUID); } + static std::string toLUID(const std::string &encoded) { return StringEscape::unescape(encoded, '%'); } /** fill with unencoded LUID */ - void setLUID(const string &luid) { m_encodedLUID = fromLUID(luid); } + void setLUID(const std::string &luid) { m_encodedLUID = fromLUID(luid); } /** convert from unencoded LUID */ - static string fromLUID(const string &luid) { return StringEscape::escape(luid, '%', StringEscape::STRICT); } + static std::string fromLUID(const std::string &luid) { return StringEscape::escape(luid, '%', StringEscape::STRICT); } }; class Cmdline { @@ -70,9 +69,9 @@ public: * @param out stdout stream for normal messages * @param err stderr stream for error messages */ - Cmdline(int argc, const char * const *argv, ostream &out, ostream &err); - Cmdline(const vector<string> &args, ostream &out, ostream &err); - Cmdline(ostream &out, ostream &err, const char *arg, ...); + Cmdline(int argc, const char * const *argv, std::ostream &out, std::ostream &err); + Cmdline(const std::vector<std::string> &args, std::ostream &out, std::ostream &err); + Cmdline(std::ostream &out, std::ostream &err, const char *arg, ...); /** * parse the command line options @@ -88,7 +87,7 @@ public: * * @retval true if command line was okay */ - bool parse(vector<string> &args); + bool parse(std::vector<std::string> &args); /** * @return false if run() still needs to be invoked, true when parse() already did @@ -131,18 +130,18 @@ public: bool status() { return m_status; } /* server name */ - string getConfigName() { return m_server; } + std::string getConfigName() { return m_server; } /* check whether command line runs sync. It should be called after parsing. */ bool isSync(); protected: // vector to store strings for arguments - vector<string> m_args; + std::vector<std::string> m_args; int m_argc; const char * const * m_argv; - ostream &m_out, &m_err; + std::ostream &m_out, &m_err; //array to store pointers of arguments boost::scoped_array<const char *> m_argvArray; @@ -171,24 +170,24 @@ protected: const ConfigPropertyRegistry &m_validSyncProps; const ConfigPropertyRegistry &m_validSourceProps; - string m_restore; + std::string m_restore; Bool m_before, m_after; Bool m_accessItems; - string m_itemPath; - string m_delimiter; - list<string> m_luids; + std::string m_itemPath; + std::string m_delimiter; + std::list<std::string> m_luids; Bool m_printItems, m_update, m_import, m_export, m_deleteItems; - string m_server; - string m_template; - set<string> m_sources; + std::string m_server; + std::string m_template; + std::set<std::string> m_sources; /** running the command line modified configuration settings (add, update, remove) */ Bool m_configModified; /** compose description of cmd line option with optional parameter */ - static string cmdOpt(const char *opt, const char *param = NULL); + static std::string cmdOpt(const char *opt, const char *param = NULL); /** * rename file or directory by appending .old or (if that already @@ -204,7 +203,7 @@ protected: */ void copyConfig(const boost::shared_ptr<SyncConfig> &from, const boost::shared_ptr<SyncConfig> &to, - const set<string> &selectedSources); + const std::set<std::string> &selectedSources); /** * flush, move .synthesis dir, set ConsumerReady, ... @@ -232,11 +231,11 @@ protected: const char *propname = NULL); bool listPropValues(const ConfigPropertyRegistry &validProps, - const string &propName, - const string &opt); + const std::string &propName, + const std::string &opt); bool listProperties(const ConfigPropertyRegistry &validProps, - const string &opt); + const std::string &opt); /** * check that m_props don't contain @@ -248,12 +247,12 @@ protected: /** * list all known data sources of a certain type */ - void listSources(SyncSource &syncSource, const string &header); + void listSources(SyncSource &syncSource, const std::string &header); - void dumpConfigs(const string &preamble, + void dumpConfigs(const std::string &preamble, const SyncConfig::ConfigList &servers); - void dumpConfigTemplates(const string &preamble, + void dumpConfigTemplates(const std::string &preamble, const SyncConfig::TemplateList &templates, bool printRank = false); @@ -277,14 +276,14 @@ protected: bool hidden, const ConfigPropertyRegistry &allProps); - void dumpComment(ostream &stream, - const string &prefix, - const string &comment); + void dumpComment(std::ostream &stream, + const std::string &prefix, + const std::string &comment); /** print usage information */ void usage(bool full, - const string &error = string(""), - const string ¶m = string("")); + const std::string &error = std::string(""), + const std::string ¶m = std::string("")); /** * This is a factory method used to delay sync client creation to its @@ -317,7 +316,7 @@ protected: * Unsafe characters are escaped with SafeConfigNode::escape(true,true). * startDataRead() must have been called. */ - void readLUIDs(SyncSource *source, list<string> &luids); + void readLUIDs(SyncSource *source, std::list<std::string> &luids); /** * Add or update one item. @@ -326,7 +325,7 @@ protected: * @param data the item data to insert * @return encoded luid of inserted item */ - CmdlineLUID insertItem(SyncSourceRaw *source, const string &luid, const string &data); + CmdlineLUID insertItem(SyncSourceRaw *source, const std::string &luid, const std::string &data); }; diff --git a/src/syncevo/ConfigFilter.cpp b/src/syncevo/ConfigFilter.cpp index a803abdd..31d5c747 100644 --- a/src/syncevo/ConfigFilter.cpp +++ b/src/syncevo/ConfigFilter.cpp @@ -23,6 +23,8 @@ #include <syncevo/ConfigFilter.h> #include <syncevo/SyncConfig.h> +using namespace std; + SE_BEGIN_CXX void ConfigProps::add(const ConfigProps &other) @@ -200,6 +202,4 @@ void FullProps::createFilters(const string &context, } } - - SE_END_CXX diff --git a/src/syncevo/ConfigFilter.h b/src/syncevo/ConfigFilter.h index b939b19c..0ac04b6f 100644 --- a/src/syncevo/ConfigFilter.h +++ b/src/syncevo/ConfigFilter.h @@ -27,13 +27,12 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** a case-insensitive string to string mapping */ -class ConfigProps : public map<string, string, Nocase<string> > { +class ConfigProps : public std::map<std::string, std::string, Nocase<std::string> > { public: /** format as <key> = <value> lines */ - operator string () const; + operator std::string () const; /** * Add all entries from the second set of properties, @@ -45,7 +44,7 @@ class ConfigProps : public map<string, string, Nocase<string> > { /** * Return value in map or the given default. */ - string get(const string &key, const string &def = "") const; + std::string get(const std::string &key, const std::string &def = "") const; }; /** @@ -53,7 +52,7 @@ class ConfigProps : public map<string, string, Nocase<string> > { * * Source and property names are case-insensitive. */ -class SourceProps : public map<string, ConfigProps, Nocase<string> > +class SourceProps : public std::map<std::string, ConfigProps, Nocase<std::string> > { public: /** @@ -83,7 +82,7 @@ struct ContextProps * * Index is case-insensitive. */ -class FullProps : public map<string, ContextProps, Nocase<string> > +class FullProps : public std::map<std::string, ContextProps, Nocase<std::string> > { public: /** any of the contained ConfigProps has entries */ @@ -125,9 +124,9 @@ class FullProps : public map<string, ContextProps, Nocase<string> > * listed explicitly, * key "" as fallback for unknown sources */ - void createFilters(const string &context, - const string &config, - const set<string> *sources, + void createFilters(const std::string &context, + const std::string &config, + const std::set<std::string> *sources, ConfigProps &syncFilter, SourceProps &sourceFilters); }; diff --git a/src/syncevo/ConfigNode.cpp b/src/syncevo/ConfigNode.cpp index 7ca4723d..58ba54a5 100644 --- a/src/syncevo/ConfigNode.cpp +++ b/src/syncevo/ConfigNode.cpp @@ -22,6 +22,9 @@ #include <syncevo/SafeConfigNode.h> #include <syncevo/declarations.h> + +using namespace std; + SE_BEGIN_CXX boost::shared_ptr<ConfigNode> ConfigNode::createFileNode(const string &filename) diff --git a/src/syncevo/ConfigNode.h b/src/syncevo/ConfigNode.h index 8aefe854..0243f107 100644 --- a/src/syncevo/ConfigNode.h +++ b/src/syncevo/ConfigNode.h @@ -24,7 +24,6 @@ #include <utility> #include <string> #include <sstream> -using namespace std; #include <boost/shared_ptr.hpp> #include <boost/algorithm/string/predicate.hpp> @@ -49,10 +48,10 @@ class ConfigNode { virtual ~ConfigNode() {} /** creates a file-backed config node which accepts arbitrary key/value pairs */ - static boost::shared_ptr<ConfigNode> createFileNode(const string &filename); + static boost::shared_ptr<ConfigNode> createFileNode(const std::string &filename); /** a name for the node that the user can understand */ - virtual string getName() const = 0; + virtual std::string getName() const = 0; /** * save all changes persistently @@ -68,7 +67,7 @@ class ConfigNode { * @param property - the property name * @return value of the property or empty string if not set */ - virtual string readProperty(const string &property) const = 0; + virtual std::string readProperty(const std::string &property) const = 0; /** * Sets a property value. @@ -83,15 +82,15 @@ class ConfigNode { * remember that the value hasn't really been changed. * An implementation can decide to not support this. */ - virtual void setProperty(const string &property, - const string &value, - const string &comment = string(""), - const string *defValue = NULL) = 0; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = std::string(""), + const std::string *defValue = NULL) = 0; /** * Sets a boolean property, using "true/false". */ - void setProperty(const string &property, bool value) { + void setProperty(const std::string &property, bool value) { setProperty(property, value ? "true" : "false"); } @@ -99,20 +98,20 @@ class ConfigNode { * Sets a property value with automatic conversion to the underlying string, * using stream formatting. */ - template <class T> void setProperty(const string &property, + template <class T> void setProperty(const std::string &property, const T &value) { std::stringstream strval; strval << value; setProperty(property, strval.str()); } - bool getProperty(const string &property, - string &value) const { + bool getProperty(const std::string &property, + std::string &value) const { value = readProperty(property); return !value.empty(); } - bool getProperty(const string &property, + bool getProperty(const std::string &property, bool &value) const { std::string str = readProperty(property); if (str.empty()) { @@ -143,7 +142,7 @@ class ConfigNode { return false; } - template <class T> bool getProperty(const string &property, + template <class T> bool getProperty(const std::string &property, T &value) const { std::string str = readProperty(property); if (str.empty()) { @@ -180,7 +179,7 @@ class ConfigNode { * * @param property the name of the property which is to be removed */ - virtual void removeProperty(const string &property) = 0; + virtual void removeProperty(const std::string &property) = 0; /** * Remove all properties. diff --git a/src/syncevo/ConfigTree.h b/src/syncevo/ConfigTree.h index e8e30959..4cc51f6a 100644 --- a/src/syncevo/ConfigTree.h +++ b/src/syncevo/ConfigTree.h @@ -27,7 +27,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; class ConfigNode; @@ -80,10 +79,10 @@ class ConfigTree { * * The nodes must not be in use for this to work. */ - virtual void remove(const string &path) = 0; + virtual void remove(const std::string &path) = 0; /** a string identifying the root of the configuration - exact meaning varies */ - virtual string getRootPath() const = 0; + virtual std::string getRootPath() const = 0; /** * Selects which node attached to a path name is to be used. @@ -108,9 +107,9 @@ class ConfigTree { * node's name (allows having multiple different such * nodes); an empty string is allowed */ - virtual boost::shared_ptr<ConfigNode> open(const string &path, + virtual boost::shared_ptr<ConfigNode> open(const std::string &path, PropertyType type, - const string &otherId = string("")) = 0; + const std::string &otherId = std::string("")) = 0; /** * Use the specified node, with type determined @@ -125,13 +124,13 @@ class ConfigTree { * @param node default instance if not opened before, discarded if a * node was registered or opened under the given path before */ - virtual boost::shared_ptr<ConfigNode> add(const string &path, + virtual boost::shared_ptr<ConfigNode> add(const std::string &path, const boost::shared_ptr<ConfigNode> &node) = 0; /** * returns names of all existing nodes beneath the given path */ - virtual list<string> getChildren(const string &path) = 0; + virtual std::list<std::string> getChildren(const std::string &path) = 0; }; diff --git a/src/syncevo/CurlTransportAgent.h b/src/syncevo/CurlTransportAgent.h index ce3f45d0..deb457c5 100644 --- a/src/syncevo/CurlTransportAgent.h +++ b/src/syncevo/CurlTransportAgent.h @@ -74,7 +74,7 @@ class CurlTransportAgent : public HTTPTransportAgent * libcurl < 7.17.0 does not copy strings passed into curl_easy_setopt(). * These are local copies that remain valid as long as needed. */ - string m_url, m_proxy, m_auth, m_agent, + std::string m_url, m_proxy, m_auth, m_agent, m_cacerts; /** message buffer (owned by caller) */ diff --git a/src/syncevo/FileConfigNode.h b/src/syncevo/FileConfigNode.h index 8ef071a8..672bdedc 100644 --- a/src/syncevo/FileConfigNode.h +++ b/src/syncevo/FileConfigNode.h @@ -27,15 +27,14 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** * A base class for file related config */ class FileBaseConfigNode: public ConfigNode { protected: - string m_path; - string m_fileName; + std::string m_path; + std::string m_fileName; bool m_modified; const bool m_readonly; bool m_exists; @@ -49,7 +48,7 @@ class FileBaseConfigNode: public ConfigNode { * @param readonly do not create or write file, it must exist; * flush() will throw an exception when changes would have to be written */ - FileBaseConfigNode(const string &path, const string &fileName, bool readonly); + FileBaseConfigNode(const std::string &path, const std::string &fileName, bool readonly); /** * a virtual method to serial data structure to the file * It is used by flush function to flush memory into disk file @@ -57,7 +56,7 @@ class FileBaseConfigNode: public ConfigNode { virtual void toFile(FILE* file) = 0; public: virtual void flush(); - virtual string getName() const { return m_path + "/" + m_fileName; } + virtual std::string getName() const { return m_path + "/" + m_fileName; } virtual bool exists() const { return m_exists; } virtual bool isReadOnly() const { return m_readonly; } }; @@ -77,7 +76,7 @@ class FileBaseConfigNode: public ConfigNode { * @todo rewrite with standard C++ containers */ class FileConfigNode : public FileBaseConfigNode { - list<string> m_lines; + std::list<std::string> m_lines; void read(); @@ -95,18 +94,18 @@ class FileConfigNode : public FileBaseConfigNode { * @param readonly do not create or write file, it must exist; * flush() will throw an exception when changes would have to be written */ - FileConfigNode(const string &path, const string &fileName, bool readonly); + FileConfigNode(const std::string &path, const std::string &fileName, bool readonly); /* keep underlying methods visible; our own setProperty() would hide them */ using ConfigNode::setProperty; - virtual string readProperty(const string &property) const; - virtual void setProperty(const string &property, - const string &value, - const string &comment = "", - const string *defValue = NULL); + virtual std::string readProperty(const std::string &property) const; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = "", + const std::string *defValue = NULL); virtual void readProperties(ConfigProps &props) const; - virtual void removeProperty(const string &property); + virtual void removeProperty(const std::string &property); virtual void clear(); }; @@ -116,7 +115,7 @@ class FileConfigNode : public FileBaseConfigNode { * Here comments for property default value are discarded. */ class HashFileConfigNode: public FileBaseConfigNode { - map<std::string, std::string> m_props; + std::map<std::string, std::string> m_props; /** * Map used to store pairs */ @@ -127,15 +126,15 @@ class HashFileConfigNode: public FileBaseConfigNode { virtual void toFile(FILE* file); public: - HashFileConfigNode(const string &path, const string &fileName, bool readonly); - virtual string readProperty(const string &property) const; - virtual void setProperty(const string &property, - const string &value, - const string &comment = "", - const string *defValue = NULL); + HashFileConfigNode(const std::string &path, const std::string &fileName, bool readonly); + virtual std::string readProperty(const std::string &property) const; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = "", + const std::string *defValue = NULL); virtual void readProperties(ConfigProps &props) const; virtual void writeProperties(const ConfigProps &props); - virtual void removeProperty(const string &property); + virtual void removeProperty(const std::string &property); virtual void clear(); }; diff --git a/src/syncevo/FileConfigTree.cpp b/src/syncevo/FileConfigTree.cpp index ded89480..5c83cf66 100644 --- a/src/syncevo/FileConfigTree.cpp +++ b/src/syncevo/FileConfigTree.cpp @@ -34,6 +34,7 @@ #include <dirent.h> #include <syncevo/declarations.h> +using namespace std; SE_BEGIN_CXX FileConfigTree::FileConfigTree(const string &root, diff --git a/src/syncevo/FileConfigTree.h b/src/syncevo/FileConfigTree.h index bea702ec..7c6351cd 100644 --- a/src/syncevo/FileConfigTree.h +++ b/src/syncevo/FileConfigTree.h @@ -28,7 +28,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** * This implementation maps nodes to plain .ini style files below an @@ -47,40 +46,40 @@ class FileConfigTree : public ConfigTree { * that SHARED_LAYOUT creates the "peers" directory during * flushing */ - FileConfigTree(const string &root, - const string &peer, + FileConfigTree(const std::string &root, + const std::string &peer, SyncConfig::Layout layout); void setReadOnly(bool readonly) { m_readonly = readonly; } bool getReadOnly() const { return m_readonly; } /* ConfigTree API */ - virtual string getRootPath() const; + virtual std::string getRootPath() const; virtual void flush(); virtual void reload(); - virtual void remove(const string &path); + virtual void remove(const std::string &path); virtual void reset(); - virtual boost::shared_ptr<ConfigNode> open(const string &path, + virtual boost::shared_ptr<ConfigNode> open(const std::string &path, PropertyType type, - const string &otherId = string("")); - virtual boost::shared_ptr<ConfigNode> add(const string &path, + const std::string &otherId = std::string("")); + virtual boost::shared_ptr<ConfigNode> add(const std::string &path, const boost::shared_ptr<ConfigNode> &node); - list<string> getChildren(const string &path); + std::list<std::string> getChildren(const std::string &path); private: /** * remove all nodes from the node cache which are located at 'fullpath' * or are contained inside it */ - void clearNodes(const string &fullpath); + void clearNodes(const std::string &fullpath); private: - const string m_root; - const string m_peer; + const std::string m_root; + const std::string m_peer; SyncConfig::Layout m_layout; bool m_readonly; - typedef map< string, boost::shared_ptr<ConfigNode> > NodeCache_t; + typedef std::map< std::string, boost::shared_ptr<ConfigNode> > NodeCache_t; /** cache of all nodes ever accessed */ NodeCache_t m_nodes; }; diff --git a/src/syncevo/FilterConfigNode.h b/src/syncevo/FilterConfigNode.h index 5c273af7..9f65ef15 100644 --- a/src/syncevo/FilterConfigNode.h +++ b/src/syncevo/FilterConfigNode.h @@ -32,7 +32,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** * This class acts as filter between a real config node and its user: @@ -56,11 +55,11 @@ class FilterConfigNode : public ConfigNode { FilterConfigNode(const boost::shared_ptr<const ConfigNode> &node, const ConfigFilter &filter = ConfigFilter()); - virtual string getName() const { return m_readOnlyNode->getName(); } + virtual std::string getName() const { return m_readOnlyNode->getName(); } /** add another entry to the list of filter properties */ - virtual void addFilter(const string &property, - const string &value); + virtual void addFilter(const std::string &property, + const std::string &value); /** replace current filter list with new one */ virtual void setFilter(const ConfigFilter &filter); @@ -68,13 +67,13 @@ class FilterConfigNode : public ConfigNode { /* ConfigNode API */ virtual void flush(); - virtual string readProperty(const string &property) const; - virtual void setProperty(const string &property, - const string &value, - const string &comment = "", - const string *defValue = NULL); + virtual std::string readProperty(const std::string &property) const; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = "", + const std::string *defValue = NULL); virtual void readProperties(ConfigProps &props) const; - virtual void removeProperty(const string &property); + virtual void removeProperty(const std::string &property); virtual bool exists() const { return m_readOnlyNode->exists(); } virtual bool isReadOnly() const { return !m_node || m_readOnlyNode->isReadOnly(); } virtual void clear(); diff --git a/src/syncevo/GLibSupport.cpp b/src/syncevo/GLibSupport.cpp index c75f3d09..4c9d3294 100644 --- a/src/syncevo/GLibSupport.cpp +++ b/src/syncevo/GLibSupport.cpp @@ -33,6 +33,8 @@ #include <glib.h> #endif +using namespace std; + SE_BEGIN_CXX #ifdef HAVE_GLIB diff --git a/src/syncevo/GLibSupport.h b/src/syncevo/GLibSupport.h index e050cb4d..53a22e31 100644 --- a/src/syncevo/GLibSupport.h +++ b/src/syncevo/GLibSupport.h @@ -245,7 +245,7 @@ template< class T, class L, void (*D)(T*) = NoopDestructor<T> > struct GListCXX */ operator L * () { return m_list; } - class iterator : public std::iterator<forward_iterator_tag, T *> { + class iterator : public std::iterator<std::forward_iterator_tag, T *> { L *m_entry; public: iterator(L *list) : m_entry(list) {} @@ -267,7 +267,7 @@ template< class T, class L, void (*D)(T*) = NoopDestructor<T> > struct GListCXX iterator begin() { return iterator(m_list); } iterator end() { return iterator(NULL); } - class const_iterator : public std::iterator<forward_iterator_tag, T *> { + class const_iterator : public std::iterator<std::forward_iterator_tag, T *> { L *m_entry; T *m_value; diff --git a/src/syncevo/IniConfigNode.cpp b/src/syncevo/IniConfigNode.cpp index b7b2d68e..68aee5a2 100644 --- a/src/syncevo/IniConfigNode.cpp +++ b/src/syncevo/IniConfigNode.cpp @@ -27,6 +27,7 @@ #include <boost/foreach.hpp> #include <syncevo/declarations.h> +using namespace std; SE_BEGIN_CXX IniBaseConfigNode::IniBaseConfigNode(const boost::shared_ptr<DataBlob> &data) : @@ -56,7 +57,7 @@ IniFileConfigNode::IniFileConfigNode(const boost::shared_ptr<DataBlob> &data) : read(); } -IniFileConfigNode::IniFileConfigNode(const string &path, const string &fileName, bool readonly) : +IniFileConfigNode::IniFileConfigNode(const std::string &path, const std::string &fileName, bool readonly) : IniBaseConfigNode(boost::shared_ptr<DataBlob>(new FileDataBlob(path, fileName, readonly))) { read(); diff --git a/src/syncevo/IniConfigNode.h b/src/syncevo/IniConfigNode.h index 9b5ed507..e918f85e 100644 --- a/src/syncevo/IniConfigNode.h +++ b/src/syncevo/IniConfigNode.h @@ -28,7 +28,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** * A base class for .ini style data blobs. @@ -53,7 +52,7 @@ class IniBaseConfigNode: public ConfigNode { public: virtual void flush(); virtual void reload() = 0; - virtual string getName() const { return m_data->getName(); } + virtual std::string getName() const { return m_data->getName(); } virtual bool exists() const { return m_data->exists(); } virtual bool isReadOnly() const { return true; } }; @@ -73,7 +72,7 @@ class IniBaseConfigNode: public ConfigNode { * */ class IniFileConfigNode : public IniBaseConfigNode { - list<string> m_lines; + std::list<std::string> m_lines; void read(); @@ -82,18 +81,18 @@ class IniFileConfigNode : public IniBaseConfigNode { public: IniFileConfigNode(const boost::shared_ptr<DataBlob> &data); - IniFileConfigNode(const string &path, const string &fileName, bool readonly); + IniFileConfigNode(const std::string &path, const std::string &fileName, bool readonly); /* keep underlying methods visible; our own setProperty() would hide them */ using ConfigNode::setProperty; - virtual string readProperty(const string &property) const; - virtual void setProperty(const string &property, - const string &value, - const string &comment = "", - const string *defValue = NULL); + virtual std::string readProperty(const std::string &property) const; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = "", + const std::string *defValue = NULL); virtual void readProperties(ConfigProps &props) const; - virtual void removeProperty(const string &property); + virtual void removeProperty(const std::string &property); virtual void clear(); virtual void reload() { clear(); read(); } }; @@ -104,7 +103,7 @@ class IniFileConfigNode : public IniBaseConfigNode { * Here comments for property default value are discarded. */ class IniHashConfigNode: public IniBaseConfigNode { - map<std::string, std::string> m_props; + std::map<std::string, std::string> m_props; /** * Map used to store pairs */ @@ -116,15 +115,15 @@ class IniHashConfigNode: public IniBaseConfigNode { public: IniHashConfigNode(const boost::shared_ptr<DataBlob> &data); - IniHashConfigNode(const string &path, const string &fileName, bool readonly); - virtual string readProperty(const string &property) const; - virtual void setProperty(const string &property, - const string &value, - const string &comment = "", - const string *defValue = NULL); + IniHashConfigNode(const std::string &path, const std::string &fileName, bool readonly); + virtual std::string readProperty(const std::string &property) const; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = "", + const std::string *defValue = NULL); virtual void readProperties(ConfigProps &props) const; virtual void writeProperties(const ConfigProps &props); - virtual void removeProperty(const string &property); + virtual void removeProperty(const std::string &property); virtual void clear(); virtual void reload() { clear(); read(); } }; diff --git a/src/syncevo/LocalTransportAgent.h b/src/syncevo/LocalTransportAgent.h index 8643ad67..cacb15ff 100644 --- a/src/syncevo/LocalTransportAgent.h +++ b/src/syncevo/LocalTransportAgent.h @@ -112,7 +112,7 @@ class LocalTransportAgent : public TransportAgent private: SyncContext *m_server; boost::shared_ptr<SyncContext> m_client; - string m_clientContext; + std::string m_clientContext; GMainLoop *m_loop; unsigned m_timeoutSeconds; Status m_status; diff --git a/src/syncevo/LogRedirect.cpp b/src/syncevo/LogRedirect.cpp index 401754eb..b3985d0d 100644 --- a/src/syncevo/LogRedirect.cpp +++ b/src/syncevo/LogRedirect.cpp @@ -44,6 +44,7 @@ #include <syncevo/declarations.h> +using namespace std; SE_BEGIN_CXX LogRedirect *LogRedirect::m_redirect; diff --git a/src/syncevo/LogStdout.cpp b/src/syncevo/LogStdout.cpp index 4f6713be..391fcf16 100644 --- a/src/syncevo/LogStdout.cpp +++ b/src/syncevo/LogStdout.cpp @@ -23,6 +23,7 @@ #include <errno.h> #include <syncevo/declarations.h> +using namespace std; SE_BEGIN_CXX diff --git a/src/syncevo/MapSyncSource.h b/src/syncevo/MapSyncSource.h index 8d1dde91..0bb610a7 100644 --- a/src/syncevo/MapSyncSource.h +++ b/src/syncevo/MapSyncSource.h @@ -25,7 +25,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; class MapSyncSource; diff --git a/src/syncevo/MultiplexConfigNode.cpp b/src/syncevo/MultiplexConfigNode.cpp index 98879219..b331fa0b 100644 --- a/src/syncevo/MultiplexConfigNode.cpp +++ b/src/syncevo/MultiplexConfigNode.cpp @@ -23,7 +23,7 @@ SE_BEGIN_CXX FilterConfigNode * -MultiplexConfigNode::getNode(const string &property, +MultiplexConfigNode::getNode(const std::string &property, const ConfigProperty **found) const { BOOST_FOREACH(const ConfigProperty *prop, m_registry) { @@ -49,8 +49,8 @@ MultiplexConfigNode::getNode(const string &property, return NULL; } -void MultiplexConfigNode::addFilter(const string &property, - const string &value) +void MultiplexConfigNode::addFilter(const std::string &property, + const std::string &value) { FilterConfigNode::addFilter(property, value); for (int i = 0; i < 2; i++) { @@ -85,7 +85,7 @@ void MultiplexConfigNode::flush() } } -string MultiplexConfigNode::readProperty(const string &property) const +std::string MultiplexConfigNode::readProperty(const std::string &property) const { FilterConfigNode *node = getNode(property); if (node) { @@ -95,10 +95,10 @@ string MultiplexConfigNode::readProperty(const string &property) const } } -void MultiplexConfigNode::setProperty(const string &property, - const string &value, - const string &comment, - const string *defValue) +void MultiplexConfigNode::setProperty(const std::string &property, + const std::string &value, + const std::string &comment, + const std::string *defValue) { const ConfigProperty *prop; FilterConfigNode *node = getNode(property, &prop); @@ -120,7 +120,7 @@ void MultiplexConfigNode::readProperties(PropsType &props) const } } -void MultiplexConfigNode::removeProperty(const string &property) +void MultiplexConfigNode::removeProperty(const std::string &property) { #if 1 SE_THROW(property + ": removing via configuration multiplexer not supported"); diff --git a/src/syncevo/MultiplexConfigNode.h b/src/syncevo/MultiplexConfigNode.h index 1fe2acfd..16ba77f9 100644 --- a/src/syncevo/MultiplexConfigNode.h +++ b/src/syncevo/MultiplexConfigNode.h @@ -39,7 +39,7 @@ class MultiplexConfigNode : public FilterConfigNode bool m_havePeerNodes; int m_hiddenLower, m_hiddenUpper; - FilterConfigNode *getNode(const string &property, + FilterConfigNode *getNode(const std::string &property, const ConfigProperty **prop = NULL) const; public: @@ -76,17 +76,17 @@ class MultiplexConfigNode : public FilterConfigNode m_nodes[hidden][sharing].reset(new FilterConfigNode(node)); } - virtual void addFilter(const string &property, - const string &value); + virtual void addFilter(const std::string &property, + const std::string &value); virtual void setFilter(const ConfigFilter &filter); - virtual string getName() const { return m_name; } + virtual std::string getName() const { return m_name; } virtual void flush(); - virtual string readProperty(const string &property) const; - virtual void setProperty(const string &property, - const string &value, - const string &comment = string(""), - const string *defValue = NULL); + virtual std::string readProperty(const std::string &property) const; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = std::string(""), + const std::string *defValue = NULL); virtual void readProperties(PropsType &props) const; /* @@ -94,7 +94,7 @@ class MultiplexConfigNode : public FilterConfigNode * not certain what should be deleted: only properties which are * not shared?! */ - virtual void removeProperty(const string &property); + virtual void removeProperty(const std::string &property); virtual void clear(); /** diff --git a/src/syncevo/PrefixConfigNode.h b/src/syncevo/PrefixConfigNode.h index 1af5f778..049759d3 100644 --- a/src/syncevo/PrefixConfigNode.h +++ b/src/syncevo/PrefixConfigNode.h @@ -30,7 +30,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** * This class acts as filter between a real config node and its user: @@ -44,30 +43,30 @@ using namespace std; class PrefixConfigNode : public ConfigNode { public: /** read-write access to underlying node */ - PrefixConfigNode(const string prefix, + PrefixConfigNode(const std::string prefix, const boost::shared_ptr<ConfigNode> &node); /** read-only access to underlying node */ - PrefixConfigNode(const string prefix, + PrefixConfigNode(const std::string prefix, const boost::shared_ptr<const ConfigNode> &node); - virtual string getName() const { return m_readOnlyNode->getName(); } + virtual std::string getName() const { return m_readOnlyNode->getName(); } /* ConfigNode API */ virtual void flush(); - virtual string readProperty(const string &property) const; - virtual void setProperty(const string &property, - const string &value, - const string &comment = "", - const string *defValue = NULL); + virtual std::string readProperty(const std::string &property) const; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = "", + const std::string *defValue = NULL); virtual void readProperties(ConfigProps &props) const; - virtual void removeProperty(const string &property); + virtual void removeProperty(const std::string &property); virtual bool exists() const { return m_readOnlyNode->exists(); } virtual bool isReadOnly() const { return !m_node || m_readOnlyNode->isReadOnly(); } virtual void clear(); private: - string m_prefix; + std::string m_prefix; boost::shared_ptr<ConfigNode> m_node; boost::shared_ptr<const ConfigNode> m_readOnlyNode; }; diff --git a/src/syncevo/SafeConfigNode.h b/src/syncevo/SafeConfigNode.h index de1e1416..1297ff80 100644 --- a/src/syncevo/SafeConfigNode.h +++ b/src/syncevo/SafeConfigNode.h @@ -30,7 +30,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** * This class acts as filter between a real config node and its user: @@ -57,20 +56,20 @@ class SafeConfigNode : public ConfigNode { void setMode(bool strict) { m_strictMode = strict; } bool getMode() { return m_strictMode; } - virtual string getName() const { return m_readOnlyNode->getName(); } + virtual std::string getName() const { return m_readOnlyNode->getName(); } /* keep underlying methods visible; our own setProperty() would hide them */ using ConfigNode::setProperty; /* ConfigNode API */ virtual void flush(); - virtual string readProperty(const string &property) const; - virtual void setProperty(const string &property, - const string &value, - const string &comment = "", - const string *defValue = NULL); + virtual std::string readProperty(const std::string &property) const; + virtual void setProperty(const std::string &property, + const std::string &value, + const std::string &comment = "", + const std::string *defValue = NULL); virtual void readProperties(ConfigProps &props) const; - virtual void removeProperty(const string &property); + virtual void removeProperty(const std::string &property); virtual bool exists() const { return m_readOnlyNode->exists(); } virtual bool isReadOnly() const { return !m_node || m_readOnlyNode->isReadOnly(); } virtual void clear() { m_node->clear(); } @@ -83,11 +82,11 @@ class SafeConfigNode : public ConfigNode { /** * turn str into something which can be used as key or value in ConfigNode */ - string escape(const string &str) const { + std::string escape(const std::string &str) const { return StringEscape::escape(str, '!', m_strictMode ? StringEscape::STRICT : StringEscape::INI_VALUE); } - static string unescape(const string &str) { + static std::string unescape(const std::string &str) { return StringEscape::unescape(str, '!'); } }; diff --git a/src/syncevo/SingleFileConfigTree.h b/src/syncevo/SingleFileConfigTree.h index f0bc1383..adf31188 100644 --- a/src/syncevo/SingleFileConfigTree.h +++ b/src/syncevo/SingleFileConfigTree.h @@ -62,7 +62,7 @@ class SingleFileConfigTree : public ConfigTree { boost::shared_ptr<ConfigNode> open(const std::string &filename); /* ConfigTree API */ - virtual string getRootPath() const { return m_data->getName(); } + virtual std::string getRootPath() const { return m_data->getName(); } virtual void flush(); virtual void reload(); virtual void remove(const std::string &path); @@ -70,9 +70,9 @@ class SingleFileConfigTree : public ConfigTree { virtual boost::shared_ptr<ConfigNode> open(const std::string &path, PropertyType type, const std::string &otherId = std::string("")); - virtual boost::shared_ptr<ConfigNode> add(const string &path, + virtual boost::shared_ptr<ConfigNode> add(const std::string &path, const boost::shared_ptr<ConfigNode> &bode); - list<string> getChildren(const std::string &path); + std::list<std::string> getChildren(const std::string &path); private: boost::shared_ptr<DataBlob> m_data; @@ -84,7 +84,7 @@ class SingleFileConfigTree : public ConfigTree { FileContent_t m_content; /** cache of all nodes ever accessed */ - typedef map< string, boost::shared_ptr<ConfigNode> > NodeCache_t; + typedef std::map< std::string, boost::shared_ptr<ConfigNode> > NodeCache_t; NodeCache_t m_nodes; /** diff --git a/src/syncevo/SmartPtr.h b/src/syncevo/SmartPtr.h index 7d1142bc..c1594b20 100644 --- a/src/syncevo/SmartPtr.h +++ b/src/syncevo/SmartPtr.h @@ -34,7 +34,6 @@ #include <stdexcept> #include <string> #include <memory> -using namespace std; #include <boost/scoped_array.hpp> #include <boost/shared_ptr.hpp> diff --git a/src/syncevo/StringDataBlob.cpp b/src/syncevo/StringDataBlob.cpp index 3e7cf264..f6fb803d 100644 --- a/src/syncevo/StringDataBlob.cpp +++ b/src/syncevo/StringDataBlob.cpp @@ -52,12 +52,12 @@ StringDataBlob::StringDataBlob(const std::string &name, boost::shared_ptr<std::ostream> StringDataBlob::write() { - return boost::shared_ptr<std::ostringstream>(new ostringstream, FinalizeWrite(m_data)); + return boost::shared_ptr<std::ostringstream>(new std::ostringstream, FinalizeWrite(m_data)); } boost::shared_ptr<std::istream> StringDataBlob::read() { - return boost::shared_ptr<std::istream>(new istringstream(m_data ? *m_data : "")); + return boost::shared_ptr<std::istream>(new std::istringstream(m_data ? *m_data : "")); } SE_END_CXX diff --git a/src/syncevo/SyncConfig.h b/src/syncevo/SyncConfig.h index afc3d432..7df2ffc8 100644 --- a/src/syncevo/SyncConfig.h +++ b/src/syncevo/SyncConfig.h @@ -39,7 +39,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** * @defgroup ConfigHandling Configuration Handling @@ -135,22 +134,22 @@ class ConstSyncSourceNodes; extern const char *const SourceAdminDataName; /** simplified creation of string lists: InitList("foo") + "bar" + ... */ -template<class T> class InitList : public list<T> { +template<class T> class InitList : public std::list<T> { public: InitList() {} InitList(const T &initialValue) { - list<T>::push_back(initialValue); + std::list<T>::push_back(initialValue); } InitList &operator + (const T &rhs) { - list<T>::push_back(rhs); + std::list<T>::push_back(rhs); return *this; } InitList &operator += (const T &rhs) { - list<T>::push_back(rhs); + std::list<T>::push_back(rhs); return *this; } }; -typedef InitList<string> Aliases; +typedef InitList<std::string> Aliases; typedef InitList<Aliases> Values; enum PropertyType { @@ -235,8 +234,8 @@ class PropertySpecifier { */ class ConfigProperty { public: - ConfigProperty(const string &name, const string &comment, - const string &def = string(""), const string &descr = string("")) : + ConfigProperty(const std::string &name, const std::string &comment, + const std::string &def = std::string(""), const std::string &descr = std::string("")) : m_obligatory(false), m_hidden(false), m_sharing(NO_SHARING), @@ -247,8 +246,8 @@ class ConfigProperty { m_descr(descr) {} - ConfigProperty(const Aliases &names, const string &comment, - const string &def = string(""), const string &descr = string("")) : + ConfigProperty(const Aliases &names, const std::string &comment, + const std::string &def = std::string(""), const std::string &descr = std::string("")) : m_obligatory(false), m_hidden(false), m_sharing(NO_SHARING), @@ -261,16 +260,16 @@ class ConfigProperty { virtual ~ConfigProperty() {} /** name to be used for a specific node: first name if not in node, otherwise existing key */ - string getName(const ConfigNode &node) const; + std::string getName(const ConfigNode &node) const; /** primary name */ - string getMainName() const { return m_names.front(); } + std::string getMainName() const { return m_names.front(); } /* virtual so that derived classes like SourceBackendConfigProperty can generate the result dynamically */ virtual const Aliases &getNames() const { return m_names; } - virtual string getComment() const { return m_comment; } - virtual string getDefValue() const { return m_defValue; } - virtual string getDescr() const { return m_descr; } + virtual std::string getComment() const { return m_comment; } + virtual std::string getDefValue() const { return m_defValue; } + virtual std::string getDescr() const { return m_descr; } /** * Check whether the given value is okay. @@ -278,7 +277,7 @@ class ConfigProperty { * * @return true if value is okay */ - virtual bool checkValue(const string &value, string &error) const { return true; } + virtual bool checkValue(const std::string &value, std::string &error) const { return true; } /** * Only useful when a config property wants to check itself whether to retrieve password @@ -292,9 +291,9 @@ class ConfigProperty { * @param sourceConfigNode the config node for the source */ virtual void checkPassword(ConfigUserInterface &ui, - const string &serverName, + const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName = string(), + const std::string &sourceName = std::string(), const boost::shared_ptr<FilterConfigNode> &sourceConfigNode = boost::shared_ptr<FilterConfigNode>()) const {} /** @@ -303,9 +302,9 @@ class ConfigProperty { * function to save the password if necessary */ virtual void savePassword(ConfigUserInterface &ui, - const string &serverName, + const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName = string(), + const std::string &sourceName = std::string(), const boost::shared_ptr<FilterConfigNode> &sourceConfigNode = boost::shared_ptr<FilterConfigNode>()) const {} /** @@ -314,14 +313,13 @@ class ConfigProperty { * Derived classes can override this function. Used by 'checkPassword' and 'savePassword' * to generate description for user interface. */ - virtual const string getDescr(const string &serverName, + virtual const std::string getDescr(const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName = string(), + const std::string &sourceName = std::string(), const boost::shared_ptr<FilterConfigNode> &sourceConfigNode=boost::shared_ptr<FilterConfigNode>()) const { return m_descr.empty() ? serverName : m_descr; } - /** split \n separated comment into lines without \n, appending them to commentLines */ - static void splitComment(const string &comment, list<string> &commentLines); + static void splitComment(const std::string &comment, std::list<std::string> &commentLines); /** internal property? */ bool isHidden() const { return m_hidden; } @@ -346,9 +344,9 @@ class ConfigProperty { void setSharing(Sharing sharing) { m_sharing = sharing; } /** set value unconditionally, even if it is not valid */ - void setProperty(ConfigNode &node, const string &value) const { node.setProperty(getName(node), value, getComment()); } - void setProperty(FilterConfigNode &node, const string &value, bool temporarily = false) const { - string name = getName(node); + void setProperty(ConfigNode &node, const std::string &value) const { node.setProperty(getName(node), value, getComment()); } + void setProperty(FilterConfigNode &node, const std::string &value, bool temporarily = false) const { + std::string name = getName(node); if (temporarily) { node.addFilter(name, value); } else { @@ -358,8 +356,8 @@ class ConfigProperty { /** set default value of a property, marked as default unless forced setting */ void setDefaultProperty(ConfigNode &node, bool force) const { - string name = getName(node); - string defValue = getDefValue(); + std::string name = getName(node); + std::string defValue = getDefValue(); node.setProperty(name, defValue, getComment(), force ? NULL : &defValue); } @@ -371,11 +369,11 @@ class ConfigProperty { * @retval isDefault return true if the node had no value set and * the default was returned instead */ - virtual string getProperty(const ConfigNode &node, bool *isDefault = NULL) const { - string name = getName(node); - string value = node.readProperty(name); + virtual std::string getProperty(const ConfigNode &node, bool *isDefault = NULL) const { + std::string name = getName(node); + std::string value = node.readProperty(name); if (!value.empty()) { - string error; + std::string error; if (!checkValue(value, error)) { throwValueError(node, name, value, error); } @@ -393,13 +391,13 @@ class ConfigProperty { // true if property is set to non-empty value bool isSet(const ConfigNode &node) const { - string name = getName(node); - string value = node.readProperty(name); + std::string name = getName(node); + std::string value = node.readProperty(name); return !value.empty(); } protected: - void throwValueError(const ConfigNode &node, const string &name, const string &value, const string &error) const; + void throwValueError(const ConfigNode &node, const std::string &name, const std::string &value, const std::string &error) const; private: bool m_obligatory; @@ -407,7 +405,7 @@ class ConfigProperty { Sharing m_sharing; int m_flags; const Aliases m_names; - const string m_comment, m_defValue, m_descr; + const std::string m_comment, m_defValue, m_descr; }; /** @@ -421,9 +419,9 @@ class ConfigProperty { */ class StringConfigProperty : public ConfigProperty { public: - StringConfigProperty(const string &name, const string &comment, - const string &def = string(""), - const string &descr = string(""), + StringConfigProperty(const std::string &name, const std::string &comment, + const std::string &def = std::string(""), + const std::string &descr = std::string(""), const Values &values = Values()) : ConfigProperty(name, comment, def, descr), m_values(values) @@ -432,10 +430,10 @@ class StringConfigProperty : public ConfigProperty { /** * @return false if aliases are defined and the string is not one of them */ - bool normalizeValue(string &res) const { + bool normalizeValue(std::string &res) const { Values values = getValues(); BOOST_FOREACH(const Values::value_type &value, values) { - BOOST_FOREACH(const string &alias, value) { + BOOST_FOREACH(const std::string &alias, value) { if (boost::iequals(res, alias)) { res = *value.begin(); return true; @@ -449,13 +447,13 @@ class StringConfigProperty : public ConfigProperty { * This implementation accepts all values if no aliases * are given, otherwise the value must be part of the aliases. */ - virtual bool checkValue(const string &propValue, string &error) const { + virtual bool checkValue(const std::string &propValue, std::string &error) const { Values values = getValues(); if (values.empty()) { return true; } - ostringstream err; + std::ostringstream err; err << "not one of the valid values ("; bool firstval = true; BOOST_FOREACH(const Values::value_type &value, values) { @@ -465,7 +463,7 @@ class StringConfigProperty : public ConfigProperty { firstval = false; } bool firstalias = true; - BOOST_FOREACH(const string &alias, value) { + BOOST_FOREACH(const std::string &alias, value) { if (!firstalias) { err << " = "; } else { @@ -487,8 +485,8 @@ class StringConfigProperty : public ConfigProperty { return false; } - virtual string getProperty(const ConfigNode &node, bool *isDefault = NULL) const { - string res = ConfigProperty::getProperty(node, isDefault); + virtual std::string getProperty(const ConfigNode &node, bool *isDefault = NULL) const { + std::string res = ConfigProperty::getProperty(node, isDefault); normalizeValue(res); return res; } @@ -507,7 +505,7 @@ class StringConfigProperty : public ConfigProperty { */ template<class T> class TypedConfigProperty : public ConfigProperty { public: - TypedConfigProperty(const string &name, const string &comment, const string &defValue = string("0"), const string &descr = string("")) : + TypedConfigProperty(const std::string &name, const std::string &comment, const std::string &defValue = std::string("0"), const std::string &descr = std::string("")) : ConfigProperty(name, comment, defValue, descr) {} @@ -515,8 +513,8 @@ template<class T> class TypedConfigProperty : public ConfigProperty { * This implementation accepts all values that can be converted * to the required type. */ - virtual bool checkValue(const string &value, string &error) const { - istringstream in(value); + virtual bool checkValue(const std::string &value, std::string &error) const { + std::istringstream in(value); T res; if (in >> res) { return true; @@ -527,14 +525,14 @@ template<class T> class TypedConfigProperty : public ConfigProperty { } void setProperty(ConfigNode &node, const T &value) const { - ostringstream out; + std::ostringstream out; out << value; node.setProperty(getName(node), out.str(), getComment()); } void setProperty(FilterConfigNode &node, const T &value, bool temporarily = false) const { - ostringstream out; - string name = getName(node); + std::ostringstream out; + std::string name = getName(node); out << value; if (temporarily) { @@ -545,12 +543,12 @@ template<class T> class TypedConfigProperty : public ConfigProperty { } T getPropertyValue(const ConfigNode &node, bool *isDefault = NULL) const { - string name = getName(node); - string value = node.readProperty(name); - istringstream in(value); + std::string name = getName(node); + std::string value = node.readProperty(name); + std::istringstream in(value); T res; if (value.empty()) { - istringstream defStream(getDefValue()); + std::istringstream defStream(getDefValue()); defStream >> res; if (isDefault) { *isDefault = true; @@ -590,11 +588,11 @@ template <class T, T Tmin, T Tmax, class ScalarConfigProperty : public TypedConfigProperty<T> { public: - ScalarConfigProperty(const string &name, const string &comment, const string &defValue = string("0"), const string &descr = string("")) : + ScalarConfigProperty(const std::string &name, const std::string &comment, const std::string &defValue = std::string("0"), const std::string &descr = std::string("")) : TypedConfigProperty<T>(name, comment, defValue, descr) {} - virtual bool checkValue(const string &value, string &error) const { + virtual bool checkValue(const std::string &value, std::string &error) const { errno = 0; const char *nptr = value.c_str(); char *endptr; @@ -670,15 +668,15 @@ typedef ScalarConfigProperty<unsigned long, 0, ULONG_MAX, unsigned long, 0, ULON class SecondsConfigProperty : public UIntConfigProperty { public: - SecondsConfigProperty(const string &name, const string &comment, - const string &defValue = string("0"), const string &descr = "") : + SecondsConfigProperty(const std::string &name, const std::string &comment, + const std::string &defValue = std::string("0"), const std::string &descr = "") : UIntConfigProperty(name, comment, defValue, descr) {} - virtual bool checkValue(const string &value, string &error) const; + virtual bool checkValue(const std::string &value, std::string &error) const; unsigned int getPropertyValue(const ConfigNode &node, bool *isDefault = NULL) const; - static bool parseDuration(const string &value, string &error, unsigned int &seconds); + static bool parseDuration(const std::string &value, std::string &error, unsigned int &seconds); }; /** @@ -693,17 +691,17 @@ struct ConfigPasswordKey { ConfigPasswordKey() : port(0) {} /** the user for the password */ - string user; + std::string user; /** the server for the password */ - string server; + std::string server; /** the domain name */ - string domain; + std::string domain; /** the remote object */ - string object; + std::string object; /** the network protocol */ - string protocol; + std::string protocol; /** the authentication type */ - string authtype; + std::string authtype; /** the network port */ unsigned int port; }; @@ -729,7 +727,7 @@ class ConfigUserInterface { * to make user interface independent on Configuration Tree * @return entered password */ - virtual string askPassword(const string &passwordName, const string &descr, const ConfigPasswordKey &key) = 0; + virtual std::string askPassword(const std::string &passwordName, const std::string &descr, const ConfigPasswordKey &key) = 0; /** * A helper function which is used for user interface to save @@ -740,15 +738,15 @@ class ConfigUserInterface { * @param key the key used to store password * @return true if ui saves the password and false if not */ - virtual bool savePassword(const string &passwordName, const string &password, const ConfigPasswordKey &key) = 0; + virtual bool savePassword(const std::string &passwordName, const std::string &password, const ConfigPasswordKey &key) = 0; }; class PasswordConfigProperty : public ConfigProperty { public: - PasswordConfigProperty(const string &name, const string &comment, const string &def = string(""),const string &descr = string("")) : + PasswordConfigProperty(const std::string &name, const std::string &comment, const std::string &def = std::string(""),const std::string &descr = std::string("")) : ConfigProperty(name, comment, def, descr) {} - PasswordConfigProperty(const Aliases &names, const string &comment, const string &def = string(""),const string &descr = string("")) : + PasswordConfigProperty(const Aliases &names, const std::string &comment, const std::string &def = std::string(""),const std::string &descr = std::string("")) : ConfigProperty(names, comment, def, descr) {} @@ -756,9 +754,9 @@ class PasswordConfigProperty : public ConfigProperty { * Check the password and cache the result. */ virtual void checkPassword(ConfigUserInterface &ui, - const string &serverName, + const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName = "", + const std::string &sourceName = "", const boost::shared_ptr<FilterConfigNode> &sourceConfigNode = boost::shared_ptr<FilterConfigNode>()) const; @@ -767,9 +765,9 @@ class PasswordConfigProperty : public ConfigProperty { * function to save the password if necessary */ virtual void savePassword(ConfigUserInterface &ui, - const string &serverName, + const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName = "", + const std::string &sourceName = "", const boost::shared_ptr<FilterConfigNode> &sourceConfigNode = boost::shared_ptr<FilterConfigNode>()) const; @@ -780,18 +778,18 @@ class PasswordConfigProperty : public ConfigProperty { * @param globalConfigNode the global config node * @param sourceConfigNode the source config node. It might be empty */ - virtual ConfigPasswordKey getPasswordKey(const string &descr, - const string &serverName, + virtual ConfigPasswordKey getPasswordKey(const std::string &descr, + const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName = string(), + const std::string &sourceName = std::string(), const boost::shared_ptr<FilterConfigNode> &sourceConfigNode = boost::shared_ptr<FilterConfigNode>()) const; /** * return the cached value if necessary and possible */ - virtual string getCachedProperty(const ConfigNode &node, - const string &cachedPassword); + virtual std::string getCachedProperty(const ConfigNode &node, + const std::string &cachedPassword); }; /** @@ -799,7 +797,7 @@ class PasswordConfigProperty : public ConfigProperty { */ class ProxyPasswordConfigProperty : public PasswordConfigProperty { public: - ProxyPasswordConfigProperty(const string &name, const string &comment, const string &def = string(""), const string &descr = string("")) : + ProxyPasswordConfigProperty(const std::string &name, const std::string &comment, const std::string &def = std::string(""), const std::string &descr = std::string("")) : PasswordConfigProperty(name,comment,def,descr) {} /** @@ -807,14 +805,14 @@ class ProxyPasswordConfigProperty : public PasswordConfigProperty { * before retrieving proxy password */ virtual void checkPassword(ConfigUserInterface &ui, - const string &serverName, + const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName, + const std::string &sourceName, const boost::shared_ptr<FilterConfigNode> &sourceConfigNode) const; - virtual ConfigPasswordKey getPasswordKey(const string &descr, - const string &serverName, + virtual ConfigPasswordKey getPasswordKey(const std::string &descr, + const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName = string(), + const std::string &sourceName = std::string(), const boost::shared_ptr<FilterConfigNode> &sourceConfigNode=boost::shared_ptr<FilterConfigNode>()) const; }; @@ -824,21 +822,21 @@ class ProxyPasswordConfigProperty : public PasswordConfigProperty { class DatabasePasswordConfigProperty : public PasswordConfigProperty { public: DatabasePasswordConfigProperty(const Aliases &names, - const string &comment, - const string &def = string(""), - const string &descr = string("")): + const std::string &comment, + const std::string &def = std::string(""), + const std::string &descr = std::string("")): PasswordConfigProperty(names,comment,def,descr) {} - virtual ConfigPasswordKey getPasswordKey(const string &descr, - const string &serverName, + virtual ConfigPasswordKey getPasswordKey(const std::string &descr, + const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName = string(), + const std::string &sourceName = std::string(), const boost::shared_ptr<FilterConfigNode> &sourceConfigNode=boost::shared_ptr<FilterConfigNode>()) const; - virtual const string getDescr(const string &serverName, + virtual const std::string getDescr(const std::string &serverName, FilterConfigNode &globalConfigNode, - const string &sourceName, + const std::string &sourceName, const boost::shared_ptr<FilterConfigNode> &sourceConfigNode) const { - string descr = sourceName; + std::string descr = sourceName; descr += " "; descr += ConfigProperty::getDescr(); return descr; @@ -851,7 +849,7 @@ class DatabasePasswordConfigProperty : public PasswordConfigProperty { */ class BoolConfigProperty : public StringConfigProperty { public: - BoolConfigProperty(const string &name, const string &comment, const string &defValue = string("F"),const string &descr = string("")) : + BoolConfigProperty(const std::string &name, const std::string &comment, const std::string &defValue = std::string("F"),const std::string &descr = std::string("")) : StringConfigProperty(name, comment, defValue,descr, Values() + (Aliases("1") + "T" + "TRUE") + (Aliases("0") + "F" + "FALSE")) {} @@ -863,7 +861,7 @@ class BoolConfigProperty : public StringConfigProperty { StringConfigProperty::setProperty(node, value ? "1" : "0", temporarily); } int getPropertyValue(const ConfigNode &node, bool *isDefault = NULL) const { - string res = ConfigProperty::getProperty(node, isDefault); + std::string res = ConfigProperty::getProperty(node, isDefault); return boost::iequals(res, "T") || boost::iequals(res, "TRUE") || @@ -876,15 +874,15 @@ class BoolConfigProperty : public StringConfigProperty { */ class SafeConfigProperty : public ConfigProperty { public: - SafeConfigProperty(const string &name, const string &comment) : + SafeConfigProperty(const std::string &name, const std::string &comment) : ConfigProperty(name, comment) {} - void setProperty(ConfigNode &node, const string &value) { + void setProperty(ConfigNode &node, const std::string &value) { ConfigProperty::setProperty(node, StringEscape::escape(value, '!', StringEscape::INI_WORD)); } - virtual string getProperty(const ConfigNode &node, bool *isDefault = NULL) const { - string res = ConfigProperty::getProperty(node, isDefault); + virtual std::string getProperty(const ConfigNode &node, bool *isDefault = NULL) const { + std::string res = ConfigProperty::getProperty(node, isDefault); res = StringEscape::unescape(res, '!'); return res; } @@ -894,12 +892,12 @@ class SafeConfigProperty : public ConfigProperty { * A registry for all properties which might be saved in the same ConfigNode. * Currently the same as a simple list. Someone else owns the instances. */ -class ConfigPropertyRegistry : public list<const ConfigProperty *> { +class ConfigPropertyRegistry : public std::list<const ConfigProperty *> { public: /** case-insensitive search for property */ - const ConfigProperty *find(const string &propName) const { + const ConfigProperty *find(const std::string &propName) const { BOOST_FOREACH(const ConfigProperty *prop, *this) { - BOOST_FOREACH(const string &name, prop->getNames()) { + BOOST_FOREACH(const std::string &name, prop->getNames()) { if (boost::iequals(name, propName)) { return prop; } @@ -981,9 +979,9 @@ class SyncConfig { * in non-peer context configs. * Used by SyncContext for local sync. */ - SyncConfig(const string &peer, + SyncConfig(const std::string &peer, boost::shared_ptr<ConfigTree> tree = boost::shared_ptr<ConfigTree>(), - const string &redirectPeerRootPath = ""); + const std::string &redirectPeerRootPath = ""); /** @@ -1018,9 +1016,9 @@ class SyncConfig { void prepareConfigForWrite(); /** absolute directory name of the configuration root */ - string getRootPath() const; + std::string getRootPath() const; - typedef list< std::pair<std::string, std::string> > ConfigList; + typedef std::list< std::pair<std::string, std::string> > ConfigList; /** A simple description of the template or the configuration based on a * template. The rank field is used to indicate how good it matches the @@ -1079,7 +1077,7 @@ class SyncConfig { INVALID }; - typedef list<boost::shared_ptr <TemplateDescription> > TemplateList; + typedef std::list<boost::shared_ptr <TemplateDescription> > TemplateList; struct DeviceDescription { /** the id of the device */ @@ -1097,7 +1095,7 @@ class SyncConfig { {} }; - typedef list<DeviceDescription> DeviceList; + typedef std::list<DeviceDescription> DeviceList; /** * returns list of servers in either the old (.sync4j) or @@ -1140,7 +1138,7 @@ class SyncConfig { * "none" returns an empty template (default sync properties and dev ID set). * @return NULL if no such template */ - static boost::shared_ptr<SyncConfig> createPeerTemplate(const string &peer); + static boost::shared_ptr<SyncConfig> createPeerTemplate(const std::string &peer); /** * true if the main configuration file already exists; @@ -1160,18 +1158,18 @@ class SyncConfig { * The normalized, unique config name used by this instance. * Empty if not backed up by a real config. */ - string getConfigName() const { return m_peer; } + std::string getConfigName() const { return m_peer; } /** * The normalized context used by this instance. * Includes @ sign. */ - string getContextName() const; + std::string getContextName() const; /** * the normalized peer name, empty if not a peer config */ - string getPeerName() const; + std::string getPeerName() const; /** * true if the config is for a peer, false if a context config @@ -1182,7 +1180,7 @@ class SyncConfig { * returns names of peers inside this config; * empty if not a context */ - list<string> getPeers() const; + std::list<std::string> getPeers() const; /** * Do something before doing flush to files. This is particularly @@ -1233,7 +1231,7 @@ class SyncConfig { * otherwise added if missing * - empty string replaced with "@default" */ - static string normalizeConfigString(const string &config, NormalizeFlags flags = NORMALIZE_SHORTHAND); + static std::string normalizeConfigString(const std::string &config, NormalizeFlags flags = NORMALIZE_SHORTHAND); /** * Split a config string (normalized or not) into the peer part @@ -1242,7 +1240,7 @@ class SyncConfig { * * @return true when the context was specified explicitly */ - static bool splitConfigString(const string &config, string &peer, string &context); + static bool splitConfigString(const std::string &config, std::string &peer, std::string &context); /** * Replaces the property filter of either the sync properties or @@ -1304,15 +1302,15 @@ class SyncConfig { * * Can be called for sources which do not exist yet. */ - virtual boost::shared_ptr<PersistentSyncSourceConfig> getSyncSourceConfig(const string &name); - virtual boost::shared_ptr<const PersistentSyncSourceConfig> getSyncSourceConfig(const string &name) const { + virtual boost::shared_ptr<PersistentSyncSourceConfig> getSyncSourceConfig(const std::string &name); + virtual boost::shared_ptr<const PersistentSyncSourceConfig> getSyncSourceConfig(const std::string &name) const { return const_cast<SyncConfig *>(this)->getSyncSourceConfig(name); } /** * Returns list of all configured (not active!) sync sources. */ - virtual list<string> getSyncSources() const; + virtual std::list<std::string> getSyncSources() const; /** * Creates config nodes for a certain node. The nodes are not @@ -1329,10 +1327,10 @@ class SyncConfig { * @param name the name of the sync source * @param trackName additional part of the tracking node name (used for unit testing) */ - SyncSourceNodes getSyncSourceNodes(const string &name, - const string &trackName = ""); - ConstSyncSourceNodes getSyncSourceNodes(const string &name, - const string &trackName = "") const; + SyncSourceNodes getSyncSourceNodes(const std::string &name, + const std::string &trackName = ""); + ConstSyncSourceNodes getSyncSourceNodes(const std::string &name, + const std::string &trackName = "") const; /** * Creates config nodes for a certain node. The nodes are not @@ -1346,7 +1344,7 @@ class SyncConfig { * * @param name the name of the sync source */ - SyncSourceNodes getSyncSourceNodesNoTracking(const string &name); + SyncSourceNodes getSyncSourceNodesNoTracking(const std::string &name); /** * initialize all properties with their default value @@ -1356,7 +1354,7 @@ class SyncConfig { /** * create a new sync source configuration with default values */ - void setSourceDefaults(const string &name, bool force = true); + void setSourceDefaults(const std::string &name, bool force = true); /** * Remove sync source configuration. And remove the directory @@ -1367,14 +1365,14 @@ class SyncConfig { * configuration is removed, including properties stored * for in any of the peers. */ - void removeSyncSource(const string &name); + void removeSyncSource(const std::string &name); /** * clear existing visible source properties selected by the * configuration: with or without peer-specific properties, * depending on the current view */ - void clearSyncSourceProperties(const string &name); + void clearSyncSourceProperties(const std::string &name); /** * clear all global sync properties, with or without @@ -1398,7 +1396,7 @@ class SyncConfig { * (regardless whether they exist or not) */ void copy(const SyncConfig &other, - const set<string> *sources); + const std::set<std::string> *sources); /** * @name Settings specific to SyncEvolution @@ -1409,11 +1407,11 @@ class SyncConfig { */ /**@{*/ - virtual string getDefaultPeer() const; - virtual void setDefaultPeer(const string &value); + virtual std::string getDefaultPeer() const; + virtual void setDefaultPeer(const std::string &value); virtual std::string getLogDir() const; - virtual void setLogDir(const string &value, bool temporarily = false); + virtual void setLogDir(const std::string &value, bool temporarily = false); virtual int getMaxLogDirs() const; virtual void setMaxLogDirs(int value, bool temporarily = false); @@ -1460,26 +1458,26 @@ class SyncConfig { /**@{*/ virtual std::string getSyncUsername() const; - virtual void setSyncUsername(const string &value, bool temporarily = false); + virtual void setSyncUsername(const std::string &value, bool temporarily = false); virtual std::string getSyncPassword() const; - virtual void setSyncPassword(const string &value, bool temporarily = false); + virtual void setSyncPassword(const std::string &value, bool temporarily = false); virtual bool getPreventSlowSync() const; virtual void setPreventSlowSync(bool value, bool temporarily = false); virtual bool getUseProxy() const; virtual void setUseProxy(bool value, bool temporarily = false); virtual std::string getProxyHost() const; - virtual void setProxyHost(const string &value, bool temporarily = false); + virtual void setProxyHost(const std::string &value, bool temporarily = false); virtual int getProxyPort() const { return 0; } virtual std::string getProxyUsername() const; - virtual void setProxyUsername(const string &value, bool temporarily = false); + virtual void setProxyUsername(const std::string &value, bool temporarily = false); virtual std::string getProxyPassword() const; - virtual void setProxyPassword(const string &value, bool temporarily = false); - virtual vector<string> getSyncURL() const; - virtual void setSyncURL(const string &value, bool temporarily = false); - virtual void setSyncURL(const vector<string> &value, bool temporarily = false); + virtual void setProxyPassword(const std::string &value, bool temporarily = false); + virtual std::vector<std::string> getSyncURL() const; + virtual void setSyncURL(const std::string &value, bool temporarily = false); + virtual void setSyncURL(const std::vector<std::string> &value, bool temporarily = false); virtual std::string getClientAuthType() const; - virtual void setClientAuthType(const string &value, bool temporarily = false); + virtual void setClientAuthType(const std::string &value, bool temporarily = false); virtual unsigned long getMaxMsgSize() const; virtual void setMaxMsgSize(unsigned long value, bool temporarily = false); virtual unsigned int getMaxObjSize() const; @@ -1494,7 +1492,7 @@ class SyncConfig { */ std::string findSSLServerCertificate(); - virtual void setSSLServerCertificates(const string &value, bool temporarily = false); + virtual void setSSLServerCertificates(const std::string &value, bool temporarily = false); virtual bool getSSLVerifyServer() const; virtual void setSSLVerifyServer(bool value, bool temporarily = false); virtual bool getSSLVerifyHost() const; @@ -1507,51 +1505,51 @@ class SyncConfig { virtual void setCompression(bool value, bool temporarily = false); virtual unsigned int getResponseTimeout() const { return 0; } virtual std::string getDevID() const; - virtual void setDevID(const string &value, bool temporarily = false); + virtual void setDevID(const std::string &value, bool temporarily = false); /*Used for Server Alerted Sync*/ virtual std::string getRemoteIdentifier() const; - virtual void setRemoteIdentifier (const string &value, bool temporaritly = false); + virtual void setRemoteIdentifier (const std::string &value, bool temporaritly = false); virtual bool getPeerIsClient () const; virtual void setPeerIsClient (bool value, bool temporarily = false); virtual std::string getSyncMLVersion() const; - virtual void setSyncMLVersion (const string &value, bool temporarily = false); + virtual void setSyncMLVersion (const std::string &value, bool temporarily = false); /** * An arbitrary name assigned to the peer configuration, * not necessarily unique. Can be used by a GUI instead * of the config name. */ - virtual string getUserPeerName() const; - virtual void setUserPeerName(const string &name); + virtual std::string getUserPeerName() const; + virtual void setUserPeerName(const std::string &name); /** * The Device ID of our peer. Typically only relevant when the * peer is a client. Servers don't have a Device ID, just some * unique way of contacting them. */ - virtual string getRemoteDevID() const; - virtual void setRemoteDevID(const string &value); + virtual std::string getRemoteDevID() const; + virtual void setRemoteDevID(const std::string &value); /** * The opaque nonce value stored for a peer, required for MD5 * authentication. Only used when acting as server. */ - virtual string getNonce() const; - virtual void setNonce(const string &value); + virtual std::string getNonce() const; + virtual void setNonce(const std::string &value); /** * The opaque per-peer admin data managed by the Synthesis * engine. Only used when acting as server. */ - virtual string getDeviceData() const; - virtual void setDeviceData(const string &value); + virtual std::string getDeviceData() const; + virtual void setDeviceData(const std::string &value); /** * Automatic sync related properties, used to control its behaviors */ - virtual string getAutoSync() const; - virtual void setAutoSync(const string &value, bool temporarily = false); + virtual std::string getAutoSync() const; + virtual void setAutoSync(const std::string &value, bool temporarily = false); virtual unsigned int getAutoSyncInterval() const; virtual void setAutoSyncInterval(unsigned int value, bool temporarily = false); virtual unsigned int getAutoSyncDelay() const; @@ -1595,7 +1593,7 @@ private: * @param configname expected name of config files (config.ini or config.txt) * @retval res filled with new peer configurations found */ - static void addPeers(const string &root, + static void addPeers(const std::string &root, const std::string &configname, SyncConfig::ConfigList &res); @@ -1620,7 +1618,7 @@ private: * might also reference just a context without any * peer-specific properties ("@some-context", or "@default"). */ - string m_peer; + std::string m_peer; /** * Lower case path to peer configuration, @@ -1631,19 +1629,19 @@ private: * * Empty if configuration view has no peer-specific properties. */ - string m_peerPath; + std::string m_peerPath; /** * lower case path to source set properties, * unused for old layouts, else something like * "default" or "other_context" */ - string m_contextPath; + std::string m_contextPath; Layout m_layout; - string m_redirectPeerRootPath; - string m_cachedPassword; - string m_cachedProxyPassword; + std::string m_redirectPeerRootPath; + std::string m_cachedPassword; + std::string m_cachedProxyPassword; ConfigWriteMode m_configWriteMode; /** holds all config nodes relative to the root that we found */ @@ -1671,18 +1669,18 @@ private: */ SourceProps m_sourceFilters; - static string getOldRoot() { + static std::string getOldRoot() { return getHome() + "/.sync4j/evolution"; } - static string getNewRoot() { + static std::string getNewRoot() { const char *xdg_root_str = getenv("XDG_CONFIG_HOME"); - return xdg_root_str ? string(xdg_root_str) + "/syncevolution" : + return xdg_root_str ? std::string(xdg_root_str) + "/syncevolution" : getHome() + "/.config/syncevolution"; } /** remember all SyncSourceNodes so that temporary changes survive */ - map<string, SyncSourceNodes> m_nodeCache; + std::map<std::string, SyncSourceNodes> m_nodeCache; }; /** @@ -1719,7 +1717,7 @@ class SyncSourceNodes { const boost::shared_ptr<ConfigNode> &hiddenPeerNode, const boost::shared_ptr<ConfigNode> &trackingNode, const boost::shared_ptr<ConfigNode> &serverNode, - const string &cacheDir); + const std::string &cacheDir); friend class SyncConfig; @@ -1748,7 +1746,7 @@ class SyncSourceNodes { /** read-write access to backend specific tracking node */ boost::shared_ptr<ConfigNode> getTrackingNode() const { return m_trackingNode; } - string getCacheDir() const { return m_cacheDir; } + std::string getCacheDir() const { return m_cacheDir; } protected: const bool m_havePeerNode; @@ -1757,7 +1755,7 @@ class SyncSourceNodes { const boost::shared_ptr<ConfigNode> m_hiddenPeerNode; const boost::shared_ptr<ConfigNode> m_trackingNode; const boost::shared_ptr<ConfigNode> m_serverNode; - const string m_cacheDir; + const std::string m_cacheDir; /** multiplexer for the other nodes */ boost::shared_ptr<FilterConfigNode> m_props[2]; @@ -1799,17 +1797,17 @@ struct SourceType { * The <version> part is not stored anymore (was required by file * backend, but not actually used). */ - SourceType(const string &type); + SourceType(const std::string &type); /** * converts back to SyncEvolution <= 1.1 type specifier */ - string toString() const; + std::string toString() const; - string m_backend; /**< identifies the SyncEvolution backend (either via a generic term like "addressbook" or a specific one like "Evolution Contacts") */ - string m_localFormat; /**< the format to be used inside the backend for storing items; typically + std::string m_backend; /**< identifies the SyncEvolution backend (either via a generic term like "addressbook" or a specific one like "Evolution Contacts") */ + std::string m_localFormat; /**< the format to be used inside the backend for storing items; typically hard-coded and not configurable */ - string m_format; /**< the format to be used (typically a MIME type) when talking to our peer */ + std::string m_format; /**< the format to be used (typically a MIME type) when talking to our peer */ bool m_forceFormat; /**< force to use the client's preferred format instead giving the engine and server a choice */ }; @@ -1820,7 +1818,7 @@ struct SourceType { */ class SyncSourceConfig { public: - SyncSourceConfig(const string &name, const SyncSourceNodes &nodes); + SyncSourceConfig(const std::string &name, const SyncSourceNodes &nodes); static ConfigPropertyRegistry &getRegistry(); @@ -1841,7 +1839,7 @@ class SyncSourceConfig { * something per-peer in the file system. Currently not * configurable, set via SyncSourceNodes. */ - string getCacheDir() const { return m_nodes.getCacheDir(); } + std::string getCacheDir() const { return m_nodes.getCacheDir(); } /** * Returns the right config node for a certain property, @@ -1874,22 +1872,22 @@ class SyncSourceConfig { } virtual std::string getUser() const; - virtual void setUser(const string &value, bool temporarily = false); + virtual void setUser(const std::string &value, bool temporarily = false); virtual std::string getPassword() const; - virtual void setPassword(const string &value, bool temporarily = false); + virtual void setPassword(const std::string &value, bool temporarily = false); /** same as SyncConfig::checkPassword() but with * an extra argument globalConfigNode for source config property * may need global config node to check password */ - virtual void checkPassword(ConfigUserInterface &ui, const string &serverName, FilterConfigNode& globalConfigNode); + virtual void checkPassword(ConfigUserInterface &ui, const std::string &serverName, FilterConfigNode& globalConfigNode); /** same as SyncConfig::savePassword() */ - virtual void savePassword(ConfigUserInterface &ui, const string &serverName, FilterConfigNode& globalConfigNode); + virtual void savePassword(ConfigUserInterface &ui, const std::string &serverName, FilterConfigNode& globalConfigNode); /** selects the backend database to use */ virtual std::string getDatabaseID() const; - virtual void setDatabaseID(const string &value, bool temporarily = false); + virtual void setDatabaseID(const std::string &value, bool temporarily = false); /** * internal property: unique integer ID for the source, needed by Synthesis XML <dbtypeid>, @@ -1928,7 +1926,7 @@ class SyncSourceConfig { * the same time. */ virtual std::string getURI() const; - virtual void setURI(const string &value, bool temporarily = false); + virtual void setURI(const std::string &value, bool temporarily = false); /** * like getURI(), but instead of returning an empty string when @@ -1950,12 +1948,12 @@ class SyncSourceConfig { * - refresh-from-client */ virtual std::string getSync() const; - virtual void setSync(const string &value, bool temporarily = false); + virtual void setSync(const std::string &value, bool temporarily = false); private: - string m_name; + std::string m_name; SyncSourceNodes m_nodes; - string m_cachedPassword; + std::string m_cachedPassword; }; class SingleFileConfigTree; @@ -1967,10 +1965,10 @@ class TemplateConfig { boost::shared_ptr<SingleFileConfigTree> m_template; ConfigProps m_metaProps; - string m_id; - string m_templateName; + std::string m_id; + std::string m_templateName; public: - TemplateConfig (const string &path); + TemplateConfig (const std::string &path); enum { NO_MATCH = 0, LEVEL1_MATCH = 1, @@ -1979,15 +1977,15 @@ public: LEVEL4_MATCH = 4, BEST_MATCH=5 }; - static bool isTemplateConfig (const string &path); + static bool isTemplateConfig (const std::string &path); bool isTemplateConfig() const; - virtual int metaMatch (const string &fingerprint, SyncConfig::MatchMode mode); + virtual int metaMatch (const std::string &fingerprint, SyncConfig::MatchMode mode); virtual int serverModeMatch (SyncConfig::MatchMode mode); - virtual int fingerprintMatch (const string &fingerprint); - virtual string getTemplateId (); - virtual string getDescription(); - virtual string getFingerprint(); - virtual string getTemplateName(); + virtual int fingerprintMatch (const std::string &fingerprint); + virtual std::string getTemplateId (); + virtual std::string getDescription(); + virtual std::string getFingerprint(); + virtual std::string getTemplateName(); }; diff --git a/src/syncevo/SyncContext.h b/src/syncevo/SyncContext.h index 094a7ee1..83ff6797 100644 --- a/src/syncevo/SyncContext.h +++ b/src/syncevo/SyncContext.h @@ -30,7 +30,6 @@ #include <set> #include <map> #include <stdint.h> -using namespace std; #include <boost/smart_ptr.hpp> diff --git a/src/syncevo/SyncML.cpp b/src/syncevo/SyncML.cpp index a3a42765..f152b829 100644 --- a/src/syncevo/SyncML.cpp +++ b/src/syncevo/SyncML.cpp @@ -35,6 +35,7 @@ #include <synthesis/syerror.h> #include <syncevo/declarations.h> +using namespace std; SE_BEGIN_CXX std::string PrettyPrintSyncMode(SyncMode mode, bool userVisible) diff --git a/src/syncevo/TrackingSyncSource.h b/src/syncevo/TrackingSyncSource.h index af9e1949..430f05d5 100644 --- a/src/syncevo/TrackingSyncSource.h +++ b/src/syncevo/TrackingSyncSource.h @@ -30,7 +30,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; /** * This class implements change tracking. Data sources which want to use diff --git a/src/syncevo/VolatileConfigNode.h b/src/syncevo/VolatileConfigNode.h index 48fba6a1..571c9b21 100644 --- a/src/syncevo/VolatileConfigNode.h +++ b/src/syncevo/VolatileConfigNode.h @@ -37,7 +37,7 @@ class VolatileConfigNode : public FilterConfigNode { FilterConfigNode(boost::shared_ptr<ConfigNode>(new FileConfigNode("/dev/null", "dummy.ini", true))) {} - virtual string getName() const { return "intermediate configuration"; } + virtual std::string getName() const { return "intermediate configuration"; } virtual void flush() {} }; diff --git a/src/syncevo/eds_abi_wrapper.cpp b/src/syncevo/eds_abi_wrapper.cpp index 4894e326..9d06130f 100644 --- a/src/syncevo/eds_abi_wrapper.cpp +++ b/src/syncevo/eds_abi_wrapper.cpp @@ -27,7 +27,7 @@ #include <stdarg.h> #include <syncevo/declarations.h> - +using namespace std; namespace { std::string lookupDebug, lookupInfo; diff --git a/src/syncevo/lcs.cpp b/src/syncevo/lcs.cpp index 4ed90f29..1f7aafdc 100644 --- a/src/syncevo/lcs.cpp +++ b/src/syncevo/lcs.cpp @@ -117,7 +117,7 @@ public: std::vector< LCS::Entry<std::string> > result; LCS::lcs(content1, content2, std::back_inserter(result), LCS::accessor<content>()); - ostringstream out; + std::ostringstream out; std::copy(result.begin(), result.end(), std::ostream_iterator< LCS::Entry<std::string> >(out)); CPPUNIT_ASSERT_EQUAL(std::string("1, 4: begin\n" "2, 5: item1\n" diff --git a/src/syncevo/util.h b/src/syncevo/util.h index 1ac530d5..1d330617 100644 --- a/src/syncevo/util.h +++ b/src/syncevo/util.h @@ -41,7 +41,6 @@ #include <syncevo/declarations.h> SE_BEGIN_CXX -using namespace std; class Logger; @@ -58,43 +57,43 @@ public: }; /** shorthand, primarily useful for BOOST_FOREACH macro */ -typedef pair<string, string> StringPair; -typedef map<string, string> StringMap; +typedef std::pair<std::string, std::string> StringPair; +typedef std::map<std::string, std::string> StringMap; /** * remove multiple slashes in a row and dots directly after a slash if not followed by filename, * remove trailing / */ -string normalizePath(const string &path); +std::string normalizePath(const std::string &path); /** * Returns last component of path. Trailing slash is ignored. * Empty if path is empty. */ -string getBasename(const string &path); +std::string getBasename(const std::string &path); /** * Returns path without the last component. Empty if nothing left. */ -string getDirname(const string &path); +std::string getDirname(const std::string &path); /** * Splits path into directory and file part. Trailing slashes * are stripped first. */ -void splitPath(const string &path, string &dir, string &file); +void splitPath(const std::string &path, std::string &dir, std::string &file); /** * convert relative path to canonicalized absolute path * @param path will be turned into absolute path if possible, otherwise left unchanged * @return true if conversion is successful, false otherwise(errno will be set) */ -bool relToAbs(string &path); +bool relToAbs(std::string &path); /** ensure that m_path is writable, otherwise throw error */ -void mkdir_p(const string &path); +void mkdir_p(const std::string &path); -inline bool rm_r_all(const string &path, bool isDir) { return true; } +inline bool rm_r_all(const std::string &path, bool isDir) { return true; } /** * remove a complete directory hierarchy; invoking on non-existant directory is okay @@ -103,7 +102,7 @@ inline bool rm_r_all(const string &path, bool isDir) { return true; } * to be deleted (return true in that case); called with full path * to entry and true if known to be a directory */ -void rm_r(const string &path, boost::function<bool (const string &, +void rm_r(const std::string &path, boost::function<bool (const std::string &, bool)> filter = rm_r_all); /** @@ -120,10 +119,10 @@ void rm_r(const string &path, boost::function<bool (const string &, * @param from source directory or file * @param to target directory or file (must have same type as from) */ -void cp_r(const string &from, const string &to); +void cp_r(const std::string &from, const std::string &to); /** true if the path refers to a directory */ -bool isDir(const string &path); +bool isDir(const std::string &path); /** * try to read a file into the given string, throw exception if fails @@ -132,8 +131,8 @@ bool isDir(const string &path); * @retval content filled with file content * @return true if file could be read */ -bool ReadFile(const string &filename, string &content); -bool ReadFile(istream &in, string &content); +bool ReadFile(const std::string &filename, std::string &content); +bool ReadFile(std::istream &in, std::string &content); enum ExecuteFlags { EXECUTE_NO_STDERR = 1<<0, /**< suppress stderr of command */ @@ -224,20 +223,20 @@ class StringEscape /** * escape string according to current settings */ - string escape(const string &str) const; + std::string escape(const std::string &str) const; /** escape string with the given settings */ - static string escape(const string &str, char escapeChar, Mode mode); + static std::string escape(const std::string &str, char escapeChar, Mode mode); /** * unescape string, with escape character as currently set */ - string unescape(const string &str) const { return unescape(str, m_escapeChar); } + std::string unescape(const std::string &str) const { return unescape(str, m_escapeChar); } /** * unescape string, with escape character as given */ - static string unescape(const string &str, char escapeChar); + static std::string unescape(const std::string &str, char escapeChar); }; /** @@ -251,7 +250,7 @@ class StringEscape * Instantiating this class will generate a new unique UUID, available afterwards * in the base string class. */ -class UUID : public string { +class UUID : public std::string { public: UUID(); }; @@ -272,10 +271,10 @@ inline const char *NullPtrCheck(const char *ptr, const char *def = "(null)") */ class ReadDir { public: - ReadDir(const string &path, bool throwError = true); + ReadDir(const std::string &path, bool throwError = true); - typedef vector<string>::const_iterator const_iterator; - typedef vector<string>::iterator iterator; + typedef std::vector<std::string>::const_iterator const_iterator; + typedef std::vector<std::string>::iterator iterator; iterator begin() { return m_entries.begin(); } iterator end() { return m_entries.end(); } const_iterator begin() const { return m_entries.begin(); } @@ -285,11 +284,11 @@ class ReadDir { * check whether directory contains entry, returns full path * @param caseInsensitive ignore case, pick first entry which matches randomly */ - string find(const string &entry, bool caseSensitive); + std::string find(const std::string &entry, bool caseSensitive); private: - string m_path; - vector<string> m_entries; + std::string m_path; + std::vector<std::string> m_entries; }; /** @@ -469,7 +468,7 @@ class TransportStatusException : public StatusException */ std::string SubstEnvironment(const std::string &str); -inline string getHome() { +inline std::string getHome() { const char *homestr = getenv("HOME"); return homestr ? homestr : "."; } @@ -504,10 +503,10 @@ std::string Flags2String(int flags, const Flag *descr, const std::string &sep = class ScopedEnvChange { public: - ScopedEnvChange(const string &var, const string &value); + ScopedEnvChange(const std::string &var, const std::string &value); ~ScopedEnvChange(); private: - string m_var, m_oldval; + std::string m_var, m_oldval; bool m_oldvalset; }; |