File indexing completed on 2024-04-06 12:11:30
0001 #ifndef Fireworks_Core_FWConfiguration_h
0002 #define Fireworks_Core_FWConfiguration_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <vector>
0023 #include <memory>
0024 #include <string>
0025 #include <ostream>
0026
0027
0028
0029
0030
0031 class FWConfiguration {
0032 public:
0033 FWConfiguration(unsigned int iVersion = 1) : m_version(iVersion) {}
0034 FWConfiguration(const std::string& iValue) : m_stringValues(new std::vector<std::string>(1, iValue)), m_version(0) {}
0035 virtual ~FWConfiguration();
0036
0037 FWConfiguration(const FWConfiguration&);
0038
0039 FWConfiguration& operator=(const FWConfiguration&);
0040 typedef std::vector<std::pair<std::string, FWConfiguration> > KeyValues;
0041 typedef KeyValues::const_iterator KeyValuesIt;
0042
0043 typedef std::vector<std::string> StringValues;
0044 typedef StringValues::const_iterator StringValuesIt;
0045
0046
0047 const std::string& value(unsigned int iIndex = 0) const;
0048 const FWConfiguration* valueForKey(const std::string& iKey) const;
0049 unsigned int version() const { return m_version; }
0050
0051 const KeyValues* keyValues() const { return m_keyValues.get(); }
0052 const StringValues* stringValues() const { return m_stringValues.get(); }
0053
0054
0055
0056
0057 FWConfiguration& addKeyValue(const std::string&, const FWConfiguration&);
0058 FWConfiguration& addKeyValue(const std::string&, FWConfiguration&, bool iDoSwap = false);
0059 FWConfiguration& addValue(const std::string&);
0060 void swap(FWConfiguration&);
0061
0062 static void streamTo(std::ostream& oTo, const FWConfiguration& iConfig, const std::string& name);
0063
0064 private:
0065
0066
0067 std::unique_ptr<std::vector<std::string> > m_stringValues;
0068 std::unique_ptr<std::vector<std::pair<std::string, FWConfiguration> > > m_keyValues;
0069 unsigned int m_version;
0070 };
0071
0072 void streamTo(std::ostream&, const FWConfiguration&, const std::string& name);
0073
0074 #endif