From 8286ac511144e4f17d34eac9affb97e50646344a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:25:44 +0200 Subject: Imported Upstream version 4.0.0 --- libfrontend-elements/frontend-elements/context.hxx | 133 --------------------- 1 file changed, 133 deletions(-) delete mode 100644 libfrontend-elements/frontend-elements/context.hxx (limited to 'libfrontend-elements/frontend-elements/context.hxx') 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 -// 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 - -#include -#include - -namespace FrontendElements -{ - class Context: public NonCopyable - { - typedef - Cult::Containers::Map - 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 - X& - get (Char const* key) - { - Map::Iterator i (map_.find (key)); - - if (i == map_.end ()) - throw NoEntry (); - - try - { - return i->second. template value (); - } - catch (Cult::Containers::Any::Typing const&) - { - throw Typing (); - } - } - - template - 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 (); - } - catch (Cult::Containers::Any::Typing const&) - { - throw Typing (); - } - } - - template - 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 (); - } - catch (Cult::Containers::Any::Typing const&) - { - throw Typing (); - } - } - - template - 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 () = 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 -- cgit v1.2.3