22 #include "usServicePropertiesImpl_p.h"
26 #ifdef US_PLATFORM_WINDOWS
28 #define ci_compare strnicmp
31 #define ci_compare strncasecmp
36 Any ServicePropertiesImpl::emptyAny;
42 throw std::runtime_error(
"ServiceProperties object contains too many keys");
45 keys.reserve(p.size());
46 values.reserve(p.size());
48 for (ServiceProperties::const_iterator iter = p.begin();
49 iter != p.end(); ++iter)
51 if (Find(iter->first) > -1)
53 std::string msg =
"ServiceProperties object contains case variants of the key: ";
55 throw std::runtime_error(msg.c_str());
57 keys.push_back(iter->first);
58 values.push_back(iter->second);
62 const Any& ServicePropertiesImpl::Value(
const std::string& key)
const
65 if (i < 0)
return emptyAny;
69 const Any& ServicePropertiesImpl::Value(
int index)
const
71 if (index < 0 || static_cast<std::size_t>(index) >= values.size())
73 return values[
static_cast<std::size_t
>(index)];
76 int ServicePropertiesImpl::Find(
const std::string& key)
const
78 for (std::size_t i = 0; i < keys.size(); ++i)
80 if (
ci_compare(key.c_str(), keys[i].c_str(), key.size()) == 0)
82 return static_cast<int>(i);
88 int ServicePropertiesImpl::FindCaseSensitive(
const std::string& key)
const
90 for (std::size_t i = 0; i < keys.size(); ++i)
94 return static_cast<int>(i);
100 const std::vector<std::string>& ServicePropertiesImpl::Keys()
const
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties