Make object, type and variable names case-sensitive.

Fixes #5228
This commit is contained in:
Gunnar Beutner 2013-11-27 12:23:27 +01:00
parent 25da7a2291
commit 640136fbdb
10 changed files with 18 additions and 51 deletions

View File

@ -69,13 +69,13 @@ public:
private:
String m_Name;
typedef std::map<String, DynamicObject::Ptr, string_iless> ObjectMap;
typedef std::map<String, DynamicObject::Ptr> ObjectMap;
typedef std::vector<DynamicObject::Ptr> ObjectVector;
ObjectMap m_ObjectMap;
ObjectVector m_ObjectVector;
typedef std::map<String, DynamicType::Ptr, string_iless> TypeMap;
typedef std::map<String, DynamicType::Ptr> TypeMap;
typedef std::vector<DynamicType::Ptr> TypeVector;
static TypeMap& InternalGetTypeMap(void);

View File

@ -151,30 +151,16 @@ struct string_iless : std::binary_function<String, String, bool>
{
bool operator()(const String& s1, const String& s2) const
{
return strcasecmp(s1.CStr(), s2.CStr()) < 0;
return strcasecmp(s1.CStr(), s2.CStr()) < 0;
/* The "right" way would be to do this - however the
* overhead is _massive_ due to the repeated non-inlined
* function calls:
/* The "right" way would be to do this - however the
* overhead is _massive_ due to the repeated non-inlined
* function calls:
return lexicographical_compare(s1.Begin(), s1.End(),
s2.Begin(), s2.End(), boost::algorithm::is_iless());
return lexicographical_compare(s1.Begin(), s1.End(),
s2.Begin(), s2.End(), boost::algorithm::is_iless());
*/
}
};
struct pair_string_iless : std::binary_function<std::pair<String, String>, std::pair<String, String>, bool>
{
bool operator()(const std::pair<String, String>& p1, const std::pair<String, String>& p2) const
{
if (string_iless()(p1.first, p2.first))
return true;
if (string_iless()(p2.first, p1.first))
return false;
return string_iless()(p1.second, p2.second);
*/
}
};

View File

@ -41,7 +41,7 @@ template<typename U, typename T>
class Registry
{
public:
typedef std::map<String, T, string_iless> ItemMap;
typedef std::map<String, T> ItemMap;
static Registry<U, T> *GetInstance(void)
{

View File

@ -144,8 +144,6 @@ DynamicObject::Ptr ConfigItem::Commit(void)
{
ASSERT(!OwnsLock());
String type, name;
Log(LogDebug, "base", "Commit called for ConfigItem Type=" + GetType() + ", Name=" + GetName());
/* Make sure the type is valid. */
@ -154,7 +152,7 @@ DynamicObject::Ptr ConfigItem::Commit(void)
if (!dtype)
BOOST_THROW_EXCEPTION(std::runtime_error("Type '" + GetType() + "' does not exist."));
if (m_DynamicObject.lock() || dtype->GetObject(m_Name))
if (dtype->GetObject(GetName()))
BOOST_THROW_EXCEPTION(std::runtime_error("An object with type '" + GetType() + "' and name '" + GetName() + "' already exists."));
if (IsAbstract())
@ -199,18 +197,6 @@ void ConfigItem::Register(void)
}
}
/**
* Retrieves the DynamicObject that belongs to the configuration item.
*
* @returns The DynamicObject.
*/
DynamicObject::Ptr ConfigItem::GetDynamicObject(void) const
{
ObjectLock olock(this);
return m_DynamicObject.lock();
}
/**
* Retrieves a configuration item by type and name.
*

View File

@ -55,8 +55,6 @@ public:
DynamicObject::Ptr Commit(void);
void Register(void);
DynamicObject::Ptr GetDynamicObject(void) const;
DebugInfo GetDebugInfo(void) const;
static ConfigItem::Ptr GetObject(const String& type,
@ -82,12 +80,9 @@ private:
ExpressionList::Ptr m_LinkedExpressionList;
DynamicObject::WeakPtr m_DynamicObject; /**< The instantiated version
* of this configuration item */
static boost::mutex m_Mutex;
typedef std::map<std::pair<String, String>, ConfigItem::Ptr, pair_string_iless> ItemMap;
typedef std::map<std::pair<String, String>, ConfigItem::Ptr> ItemMap;
static ItemMap m_Items; /**< All registered configuration items. */
static ConfigItem::Ptr GetObjectUnlocked(const String& type,

View File

@ -192,7 +192,7 @@ void Expression::ExtractPath(const std::vector<String>& path, const ExpressionLi
}
}
void Expression::ExtractFiltered(const std::set<String, string_iless>& keys, const shared_ptr<ExpressionList>& result) const
void Expression::ExtractFiltered(const std::set<String>& keys, const shared_ptr<ExpressionList>& result) const
{
if (keys.find(m_Key) != keys.end()) {
result->AddExpression(*this);

View File

@ -62,7 +62,7 @@ public:
void Execute(const Dictionary::Ptr& dictionary) const;
void ExtractPath(const std::vector<String>& path, const shared_ptr<ExpressionList>& result) const;
void ExtractFiltered(const std::set<String, string_iless>& keys, const shared_ptr<ExpressionList>& result) const;
void ExtractFiltered(const std::set<String>& keys, const shared_ptr<ExpressionList>& result) const;
void ErasePath(const std::vector<String>& path);

View File

@ -62,7 +62,7 @@ void ExpressionList::ExtractPath(const std::vector<String>& path, const Expressi
}
}
void ExpressionList::ExtractFiltered(const std::set<String, string_iless>& keys, const ExpressionList::Ptr& result) const
void ExpressionList::ExtractFiltered(const std::set<String>& keys, const ExpressionList::Ptr& result) const
{
BOOST_FOREACH(const Expression& expression, m_Expressions) {
expression.ExtractFiltered(keys, result);

View File

@ -45,7 +45,7 @@ public:
size_t GetLength(void) const;
void ExtractPath(const std::vector<String>& path, const ExpressionList::Ptr& result) const;
void ExtractFiltered(const std::set<String, string_iless>& keys, const ExpressionList::Ptr& result) const;
void ExtractFiltered(const std::set<String>& keys, const ExpressionList::Ptr& result) const;
void ErasePath(const std::vector<String>& path);

View File

@ -40,8 +40,8 @@ public:
DECLARE_PTR_TYPEDEFS(DbType);
typedef boost::function<shared_ptr<DbObject> (const shared_ptr<DbType>&, const String&, const String&)> ObjectFactory;
typedef std::map<String, DbType::Ptr, string_iless> TypeMap;
typedef std::map<std::pair<String, String>, shared_ptr<DbObject>, pair_string_iless> ObjectMap;
typedef std::map<String, DbType::Ptr> TypeMap;
typedef std::map<std::pair<String, String>, shared_ptr<DbObject> > ObjectMap;
DbType(const String& name, const String& table, long tid, const String& idcolumn, const ObjectFactory& factory);