libopenraw
metavalue.cpp
1 /*
2  * libopenraw - metavalue.cpp
3  *
4  * Copyright (C) 2007-2016 Hubert Figuiere
5  * Copyright (C) 2008 Novell, Inc.
6  *
7  * This library is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation, either version 3 of
10  * the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library. If not, see
19  * <http://www.gnu.org/licenses/>.
20  */
21 
22 
23 #include <assert.h>
24 
25 #include "metavalue.hpp"
26 #include "exception.hpp"
27 
28 namespace OpenRaw {
29 
30 MetaValue::MetaValue(const MetaValue & r)
31  : m_values(r.m_values)
32 {
33 }
34 
35 MetaValue::MetaValue(const value_t &v)
36 {
37  m_values.push_back(v);
38 }
39 
40 MetaValue::MetaValue(const std::vector<value_t> &v)
41  : m_values(v)
42 {
43 
44 }
45 
46 template<typename T>
47 inline T MetaValue::get(int idx) const noexcept(false)
48 {
49  assert(!m_values.empty());
50  try {
51  return boost::get<T>(m_values[idx]);
52  }
53  catch(...) { //const boost::bad_any_cast &) {
54  throw Internals::BadTypeException();
55  }
56 }
57 
58 template<typename T>
59 inline const T & MetaValue::getRef(int idx) const noexcept(false)
60 {
61  static const T v;
62  assert(!m_values.empty());
63  try {
64  return boost::get<T>(m_values[idx]);
65  }
66  catch(...) { //const boost::bad_any_cast &) {
67  throw Internals::BadTypeException();
68  }
69  return v;
70 }
71 
72 
73 uint32_t MetaValue::getInteger(int idx) const
74 {
75  return get<uint32_t>(idx);
76 }
77 
78 const std::string & MetaValue::getString(int idx) const
79 {
80  return getRef<std::string>(idx);
81 }
82 
83 double MetaValue::getDouble(int idx) const
84 {
85  return get<double>(idx);
86 }
87 
88 }
89 /*
90  Local Variables:
91  mode:c++
92  c-file-style:"stroustrup"
93  c-file-offsets:((innamespace . 0))
94  indent-tabs-mode:nil
95  fill-column:80
96  End:
97 */
CIFF is the container for CRW files. It is an attempt from Canon to make this a standard. I guess it failed.
Definition: arwfile.cpp:30