summaryrefslogtreecommitdiff
path: root/libfrontend-elements/frontend-elements/context.hxx
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-23 15:21:29 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2014-07-23 15:21:29 +0200
commitbada6666c70977a058755ccf232e7d67b24adeed (patch)
tree1e92d50cebce96abaf9bce19e36026c47f77b9ba /libfrontend-elements/frontend-elements/context.hxx
parenteaf34adcbd8095bc6d1f3371b1227f654c7b19fc (diff)
New upstream release
Diffstat (limited to 'libfrontend-elements/frontend-elements/context.hxx')
-rw-r--r--libfrontend-elements/frontend-elements/context.hxx133
1 files changed, 0 insertions, 133 deletions
diff --git a/libfrontend-elements/frontend-elements/context.hxx b/libfrontend-elements/frontend-elements/context.hxx
deleted file mode 100644
index 9a31da2..0000000
--- a/libfrontend-elements/frontend-elements/context.hxx
+++ /dev/null
@@ -1,133 +0,0 @@
-// file : frontend-elements/context.hxx
-// author : Boris Kolpackov <boris@kolpackov.net>
-// copyright : Copyright (c) 2005-2010 Boris Kolpackov
-// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
-
-#ifndef FRONTEND_ELEMENTS_CONTEXT_HXX
-#define FRONTEND_ELEMENTS_CONTEXT_HXX
-
-#include <frontend-elements/types.hxx>
-
-#include <cult/containers/any.hxx>
-#include <cult/containers/map.hxx>
-
-namespace FrontendElements
-{
- class Context: public NonCopyable
- {
- typedef
- Cult::Containers::Map<String, Cult::Containers::Any>
- Map;
-
- public:
- struct NoEntry {};
- struct Typing {};
-
- Context ()
- {
- }
-
- Void
- swap (Context& c)
- {
- map_.swap (c.map_);
- }
-
- Size
- count (Char const* key) const
- {
- return map_.count (key);
- }
-
- template <typename X>
- X&
- get (Char const* key)
- {
- Map::Iterator i (map_.find (key));
-
- if (i == map_.end ())
- throw NoEntry ();
-
- try
- {
- return i->second. template value<X> ();
- }
- catch (Cult::Containers::Any::Typing const&)
- {
- throw Typing ();
- }
- }
-
- template <typename X>
- X const&
- get (Char const* key) const
- {
- Map::ConstIterator i (map_.find (key));
-
- if (i == map_.end ())
- throw NoEntry ();
-
- try
- {
- return i->second. template value<X> ();
- }
- catch (Cult::Containers::Any::Typing const&)
- {
- throw Typing ();
- }
- }
-
- template <typename X>
- X const&
- get (Char const* key, X const& default_value) const
- {
- Map::ConstIterator i (map_.find (key));
-
- if (i == map_.end ())
- return default_value;
-
- try
- {
- return i->second. template value<X> ();
- }
- catch (Cult::Containers::Any::Typing const&)
- {
- throw Typing ();
- }
- }
-
- template <typename X>
- Void
- set (Char const* key, X const& value)
- {
- try
- {
- if (!map_.insert (Map::Pair (key, value)).second)
- {
- Map::Iterator i (map_.find (key));
- i->second.template value <X> () = value;
- }
- }
- catch (Cult::Containers::Any::Typing const&)
- {
- throw Typing ();
- }
- }
-
- Void
- remove (Char const* key)
- {
- Map::Iterator i (map_.find (key));
-
- if (i == map_.end ())
- throw NoEntry ();
-
- map_.erase (i);
- }
-
- private:
- Map map_;
- };
-}
-
-#endif // FRONTEND_ELEMENTS_CONTEXT_HXX