
#include "variantmap.h"

namespace MolCore {

// === VariantMap ========================================================== //
/// \class VariantMap
/// \brief The VariantMap class provides a map between string keys
///        and variant values.

// --- Construction and Destruction ---------------------------------------- //
/// Creates a new variant map object.
VariantMap::VariantMap()
{
}

/// Destroys the variant map.
VariantMap::~VariantMap()
{
}

// --- Properties ---------------------------------------------------------- //
/// Returns the size of the variant map.
size_t VariantMap::size() const
{
  return m_map.size();
}

/// Returns \c true if the variant map is empty (i.e. size() ==
/// \c 0).
bool VariantMap::isEmpty() const
{
  return m_map.empty();
}

// --- Values -------------------------------------------------------------- //
/// Sets the value of \p name to \p value.
void VariantMap::setValue(const std::string &name, const Variant &value)
{
  m_map[name] = value;
}

/// Returns the value for \p name. If \p name is not found a null
/// variant is returned.
Variant VariantMap::value(const std::string &name) const
{
  std::map<std::string, Variant>::const_iterator iter = m_map.find(name);
  if(iter == m_map.end())
    return Variant();

  return iter->second;
}

} // end MolCore namespace


#include "variantmap.h"

namespace MolCore {

// === VariantMap ========================================================== //
/// \class VariantMap
/// \brief The VariantMap class provides a map between string keys
///        and variant values.

// --- Construction and Destruction ---------------------------------------- //
/// Creates a new variant map object.
VariantMap::VariantMap()
{
}

/// Destroys the variant map.
VariantMap::~VariantMap()
{
}

// --- Properties ---------------------------------------------------------- //
/// Returns the size of the variant map.
size_t VariantMap::size() const
{
  return m_map.size();
}

/// Returns \c true if the variant map is empty (i.e. size() ==
/// \c 0).
bool VariantMap::isEmpty() const
{
  return m_map.empty();
}

// --- Values -------------------------------------------------------------- //
/// Sets the value of \p name to \p value.
void VariantMap::setValue(const std::string &name, const Variant &value)
{
  m_map[name] = value;
}

/// Returns the value for \p name.
Variant VariantMap::value(const std::string &name) const
{
  return m_map.at(name);
}

} // end MolCore namespace

--- 
+++ 
@@ -40,10 +40,15 @@
   m_map[name] = value;
 }
 
-/// Returns the value for \p name.
+/// Returns the value for \p name. If \p name is not found a null
+/// variant is returned.
 Variant VariantMap::value(const std::string &name) const
 {
-  return m_map.at(name);
+  std::map<std::string, Variant>::const_iterator iter = m_map.find(name);
+  if(iter == m_map.end())
+    return Variant();
+
+  return iter->second;
 }
 
 } // end MolCore namespace
Remove the usage of non-portable std::map::at() from VariantMap

This removes the usage of the non-portable std::map::at() method
in the VariantMap::value() method. This fixes a compilation error
on windows.

Change-Id: Ifb5947af016f4f4e773a9a9721b979bea247b6bb
