stlab.adobe.com Adobe Systems Incorporated

dictionary.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /**************************************************************************************************/
00008 
00009 #ifndef ADOBE_DICTIONARY_HPP
00010 #define ADOBE_DICTIONARY_HPP
00011 
00012 /**************************************************************************************************/
00013 
00014 #include <adobe/config.hpp>
00015 
00016 #include <adobe/dictionary_fwd.hpp>
00017 
00018 #include <stdexcept>
00019 
00020 #include <adobe/any_regular.hpp>
00021 #include <adobe/closed_hash.hpp>
00022 #include <adobe/name.hpp>
00023 #include <adobe/typeinfo.hpp>
00024 #include <adobe/string.hpp>
00025 
00026 #ifdef ADOBE_STD_SERIALIZATION
00027 #include <iosfwd>
00028 #endif
00029 
00030 /**************************************************************************************************/
00031 
00032 namespace adobe {
00033 namespace version_1 {
00034 
00035 /**************************************************************************************************/
00036 
00037 template <typename T>
00038 inline bool get_value(const dictionary_t& dict, name_t key, T& value)
00039 {
00040     dictionary_t::const_iterator i = dict.find(key);
00041     if (i == dict.end()) return false;
00042     return i->second.cast(value);
00043 }
00044 
00045 inline bool get_value(const dictionary_t& dict, name_t key, any_regular_t& value)
00046 {
00047     dictionary_t::const_iterator i = dict.find(key);
00048     if (i == dict.end()) return false;
00049     value = i->second;
00050     return true;
00051 }
00052 
00053 inline const any_regular_t& get_value(const dictionary_t& dict, name_t key)
00054 {
00055     dictionary_t::const_iterator i = dict.find(key);
00056     if (i == dict.end())
00057         throw std::out_of_range(make_string("dictionary_t: key '", key.c_str(), "' not found"));
00058         
00059     return i->second;
00060 }
00061 
00062 /**************************************************************************************************/
00063 
00064 #ifdef ADOBE_STD_SERIALIZATION
00065 
00066 // NOTE (sparent@adobe.com) : Code for serialization is located in source/any_regular.cpp.
00067 std::ostream& operator<<(std::ostream& out, const dictionary_t& x);
00068 
00069 #endif
00070 
00071 /**************************************************************************************************/
00072 
00073 } // namespace version_1
00074 
00075 using version_1::get_value;
00076 
00077 } // namespace adobe
00078 
00079 /**************************************************************************************************/
00080 
00081 ADOBE_SHORT_NAME_TYPE('d','i','c','t', adobe::dictionary_t)
00082 
00083 /**************************************************************************************************/
00084 
00085 #endif
00086 
00087 /**************************************************************************************************/
00088 

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google