From ce67e1623fee0c1bbd125ba03b7f27a55a220206 Mon Sep 17 00:00:00 2001 From: HanzZ Date: Mon, 30 Apr 2012 14:13:56 +0200 Subject: [PATCH] Fixed unhandled exception when admin_jid is not set --- include/transport/config.h | 6 +++--- spectrum_manager/src/managerconfig.h | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/transport/config.h b/include/transport/config.h index 7d01eaa0..903480e9 100644 --- a/include/transport/config.h +++ b/include/transport/config.h @@ -28,13 +28,13 @@ #include #include - +#define CONFIG_HAS_KEY(PTR, KEY) (*PTR).hasKey(KEY) #define CONFIG_STRING(PTR, KEY) (*PTR)[KEY].as() #define CONFIG_INT(PTR, KEY) (*PTR)[KEY].as() #define CONFIG_BOOL(PTR, KEY) (*PTR)[KEY].as() #define CONFIG_LIST(PTR, KEY) (*PTR)[KEY].as >() -#define CONFIG_VECTOR(PTR, KEY) (*PTR)[KEY].as >() -#define CONFIG_HAS_KEY(PTR, KEY) (*PTR).hasKey(KEY) +#define CONFIG_VECTOR(PTR, KEY) ((*PTR).hasKey(KEY) ? (*PTR)[KEY].as >() : std::vector()) + namespace Transport { diff --git a/spectrum_manager/src/managerconfig.h b/spectrum_manager/src/managerconfig.h index 933843c3..48ca15b8 100644 --- a/spectrum_manager/src/managerconfig.h +++ b/spectrum_manager/src/managerconfig.h @@ -68,6 +68,10 @@ class ManagerConfig { return m_variables[key]; } + bool hasKey(const std::string &key) { + return m_variables.find(key) != m_variables.end(); + } + /// Returns path to config file from which data were loaded. const std::string &getManagerConfigFile() { return m_file; }