Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
dictionary.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_DICTIONARY_HPP
9#define ADOBE_DICTIONARY_HPP
10
11/**************************************************************************************************/
12
13#include <adobe/config.hpp>
14
16
17#include <stdexcept>
18
19#include <adobe/any_regular.hpp>
20#include <adobe/closed_hash.hpp>
21#include <adobe/name.hpp>
22#include <adobe/string.hpp>
23
24#ifdef ADOBE_STD_SERIALIZATION
25#include <iosfwd>
26#endif
27
28/**************************************************************************************************/
29
30namespace adobe {
31inline namespace version_1 {
32
33/**************************************************************************************************/
34
35template <typename T>
36inline bool get_value(const dictionary_t& dict, name_t key, T& value) {
38 if (i == dict.end())
39 return false;
40 return i->second.cast(value);
41}
42
43inline bool get_value(const dictionary_t& dict, name_t key, any_regular_t& value) {
45 if (i == dict.end())
46 return false;
47 value = i->second;
48 return true;
49}
50
51inline const any_regular_t& get_value(const dictionary_t& dict, name_t key) {
53 if (i == dict.end())
54 throw std::out_of_range(make_string("dictionary_t: key '", key.c_str(), "' not found"));
55
56 return i->second;
57}
58
59/**************************************************************************************************/
60
61#ifdef ADOBE_STD_SERIALIZATION
62
63// NOTE (sparent@adobe.com) : Code for serialization is located in source/any_regular.cpp.
64std::ostream& operator<<(std::ostream& out, const dictionary_t& x);
65
66#endif
67
68/**************************************************************************************************/
69
70} // namespace version_1
71
72} // namespace adobe
73
74/**************************************************************************************************/
75
76#endif
77
78/**************************************************************************************************/
A runtime polymorphic type similar to boost::any which can hold any type which models Regular.
implementation::closed_hash_iterator< closed_hash_set, const value_type > const_iterator
const_iterator find(const key_type &key) const
closed_hash_map< name_t, any_regular_t > dictionary_t
bool get_value(const dictionary_t &dict, name_t key, T &value)
std::string make_string(const char *a, const char *b)
Definition string.hpp:31
std::ostream & operator<<(std::ostream &s, const extents_t &x)
A character string class for immutable strings.
Definition name.hpp:220
const char * c_str() const
Definition name.hpp:261