aboutsummaryrefslogtreecommitdiff
path: root/dep/g3dlite/source/AnyTableReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dep/g3dlite/source/AnyTableReader.cpp')
-rw-r--r--dep/g3dlite/source/AnyTableReader.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/dep/g3dlite/source/AnyTableReader.cpp b/dep/g3dlite/source/AnyTableReader.cpp
new file mode 100644
index 00000000000..7fff1983e46
--- /dev/null
+++ b/dep/g3dlite/source/AnyTableReader.cpp
@@ -0,0 +1,50 @@
+#include "G3D/Any.h"
+
+namespace G3D {
+
+/** Verifies that \a is a TABLE with the given \a name. */
+AnyTableReader::AnyTableReader(const std::string& name, const Any& a) : m_any(a) {
+ try {
+ m_any.verifyType(Any::TABLE);
+ m_any.verifyName(name);
+ } catch (const ParseError& e) {
+ // If an exception is thrown, the destructors will not be
+ // invoked automatically.
+ m_any.~Any();
+ m_alreadyRead.~Set();
+ throw e;
+ }
+}
+
+
+AnyTableReader::AnyTableReader(const Any& a) : m_any(a) {
+ try {
+ m_any.verifyType(Any::TABLE);
+ } catch (const ParseError& e) {
+ // If an exception is thrown, the destructors will not be
+ // invoked automatically.
+ m_any.~Any();
+ m_alreadyRead.~Set();
+ throw e;
+ }
+}
+
+
+void AnyTableReader::verifyDone() const {
+ if (hasMore()) {
+ // Some entries were unread. Find them.
+ const Table<std::string, Any>& table = m_any.table();
+
+ for (Table<std::string, Any>::Iterator it = table.begin();
+ it.hasMore();
+ ++it) {
+
+ if (containsUnread(it->key)) {
+ it->value.verify(false, std::string("Unread Any table key \"") + it->key + "\"");
+ }
+ }
+ }
+}
+
+
+} // namespace G3D