From 5e8277e923c5545a15bae7c740ab6afaa597a59f Mon Sep 17 00:00:00 2001 From: jackpoz Date: Fri, 22 Aug 2014 16:58:23 +0200 Subject: Core/Dependencies: Update G3D to v9.0 r4036 --- dep/g3dlite/source/AnyTableReader.cpp | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 dep/g3dlite/source/AnyTableReader.cpp (limited to 'dep/g3dlite/source/AnyTableReader.cpp') 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& table = m_any.table(); + + for (Table::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 -- cgit v1.2.3