Skip to content

Commit

Permalink
libdoomsday|DEDRegister: DEDRegister provides immutable access to loo…
Browse files Browse the repository at this point in the history
…kup DictionaryValues
  • Loading branch information
danij-deng committed Jul 29, 2014
1 parent ddad669 commit 1493e6f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doomsday/libdoomsday/include/doomsday/defs/dedregister.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBDOOMSDAY_DEDREGISTER_H

#include "../libdoomsday.h"
#include <de/DictionaryValue>
#include <de/Record>

/**
Expand Down Expand Up @@ -92,6 +93,11 @@ class LIBDOOMSDAY_PUBLIC DEDRegister
de::Record & find(de::String const &key, de::String const &value);
de::Record const & find(de::String const &key, de::String const &value) const;

/**
* Provides immutable access to the register's dictionary, for efficient traversal.
*/
de::DictionaryValue const &lookup(de::String const &key) const;

private:
DENG2_PRIVATE(d)
};
Expand Down
9 changes: 9 additions & 0 deletions doomsday/libdoomsday/src/defs/dedregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,12 @@ Record const &DEDRegister::find(String const &key, String const &value) const
}
return *rec;
}

DictionaryValue const &DEDRegister::lookup(String const &key) const
{
if(!d->keys.contains(key))
{
throw UndefinedKeyError("DEDRegister::lookup", "Key '" + key + "' not defined");
}
return d->lookup(key);
}

0 comments on commit 1493e6f

Please sign in to comment.