]> granicus.if.org Git - icinga2/commitdiff
Remove support for anonymous dictionary items.
authorGunnar Beutner <gunnar.beutner@netways.de>
Thu, 14 Mar 2013 11:40:02 +0000 (12:40 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Thu, 14 Mar 2013 11:40:02 +0000 (12:40 +0100)
lib/base/dictionary.cpp
lib/base/dictionary.h
lib/base/process.cpp
lib/config/expression.cpp
lib/remoting/messagepart.cpp
lib/remoting/messagepart.h
test/base-dictionary.cpp

index de0a5f21dae0cf56ad19ccf81cb509597604cf0b..0914fa65e2e255af037535d09a9a73dbaef4e826 100644 (file)
@@ -120,38 +120,6 @@ void Dictionary::Set(const String& key, const Value& value)
                ret.first->second = value;
 }
 
-/**
- * Adds an unnamed value to the dictionary.
- *
- * @param value The value.
- * @returns The key that was used to add the new item.
- * @threadsafety Always.
- */
-String Dictionary::Add(const Value& value)
-{
-       ASSERT(!OwnsLock());
-       ObjectLock olock(this);
-
-       Dictionary::Iterator it;
-       String key;
-       long index = m_Data.size();
-       do {
-               stringstream s;
-               s << "_" << std::hex << std::setw(8) << std::setfill('0') << index;
-               index++;
-
-               key = s.str();
-               it = m_Data.find(key);
-       } while (it != m_Data.end());
-
-       pair<map<String, Value>::iterator, bool> ret;
-       ret = m_Data.insert(make_pair(key, value));
-       if (!ret.second)
-               ret.first->second = value;
-
-       return key;
-}
-
 /**
  * Returns an iterator to the beginning of the dictionary.
  *
index ffe6c49adb835fbcd4d0d921a3b5546dd0e67fae..cd933dd78a5035d8192cae2d1dbdcb93ec37d6d3 100644 (file)
@@ -44,7 +44,6 @@ public:
        Value Get(const char *key) const;
        Value Get(const String& key) const;
        void Set(const String& key, const Value& value);
-       String Add(const Value& value);
        bool Contains(const String& key) const;
 
        void Seal(void);
index 4b2df758a7c3ca60d19bb9fa0ac72cd4ac57b03a..70a55354a5e325bef2a282d52c22cbf0f945c15f 100644 (file)
@@ -42,13 +42,12 @@ vector<String> Process::SplitCommand(const Value& command)
 {
        vector<String> args;
 
-       if (command.IsObjectType<Dictionary>()) {
-               Dictionary::Ptr dict = command;
-               ObjectLock olock(dict);
+       if (command.IsObjectType<Array>()) {
+               Array::Ptr arguments = command;
 
-               Value arg;
-               BOOST_FOREACH(tie(tuples::ignore, arg), dict) {
-                       args.push_back(arg);
+               ObjectLock olock(arguments);
+               BOOST_FOREACH(const Value& argument, arguments) {
+                       args.push_back(argument);
                }
 
                return args;
index d7d249e5122da4cb70f3d4e59d23a04b048c22e8..f3815bb619ec8d9c3b0cdef83a5ada03516491f3 100644 (file)
@@ -105,10 +105,7 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const
                        BOOST_THROW_EXCEPTION(runtime_error("Not yet implemented."));
        }
 
-       if (m_Key.IsEmpty())
-               dictionary->Add(newValue);
-       else
-               dictionary->Set(m_Key, newValue);
+       dictionary->Set(m_Key, newValue);
 }
 
 void Expression::DumpValue(ostream& fp, int indent, const Value& value, bool inlineDict)
index f5a5280da98f646d8c4e867ea0d4286bc10d0fe3..7975881a066a91fe7d8a80c10cb88961d58b1964 100644 (file)
@@ -91,16 +91,6 @@ void MessagePart::Set(String key, const MessagePart& value)
        GetDictionary()->Set(key, value.GetDictionary());
 }
 
-/**
- * Adds an item to the message using an automatically generated property name.
- *
- * @param value The value.
- */
-void MessagePart::Add(const MessagePart& value)
-{
-       GetDictionary()->Add(value.GetDictionary());
-}
-
 /**
  * Returns an iterator that points to the first element of the dictionary
  * which holds the properties for the message.
index 56c1e2f7f9a240e694202f7a937d058b8d51e508..1d0b3da722d14fd78193b4b72535b0871a6c2b89 100644 (file)
@@ -75,19 +75,6 @@ public:
        bool Get(String key, MessagePart *value) const;
        void Set(String key, const MessagePart& value);
 
-       /**
-        * Adds an item to the message using an automatically generated property name.
-        *
-        * @param value The value.
-        */
-       template<typename T>
-       void Add(const T& value)
-       {
-               GetDictionary()->Add(value);
-       }
-
-       void Add(const MessagePart& value);
-
        bool Contains(const String& key) const;
 
        Dictionary::Iterator Begin(void);
index d12d8fb8020fe939ed7c4af5c0e5452235e28b54..486e7042909bbadaf21921f211b9d0f8e0a0b6bd 100644 (file)
@@ -64,33 +64,4 @@ BOOST_AUTO_TEST_CASE(getproperty_dict)
        BOOST_CHECK(!test2);
 }
 
-BOOST_AUTO_TEST_CASE(unnamed)
-{
-       Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
-       dictionary->Add("test1");
-       dictionary->Add("test2");
-       dictionary->Add("test3");
-
-       ObjectLock olock(dictionary);
-       BOOST_CHECK(distance(dictionary->Begin(), dictionary->End()) == 3);
-}
-
-BOOST_AUTO_TEST_CASE(unnamed_order)
-{
-       Dictionary::Ptr dictionary = boost::make_shared<Dictionary>();
-
-       for (int i = 0; i < 1000; i++)
-               dictionary->Add(i);
-
-       /* unnamed items are guaranteed to be in whatever order they were
-        * inserted in. */
-       Value value;
-       int i = 0;
-       ObjectLock olock(dictionary);
-       BOOST_FOREACH(tie(tuples::ignore, value), dictionary) {
-               BOOST_CHECK(value == i);
-               i++;
-       }
-}
-
 BOOST_AUTO_TEST_SUITE_END()