libopenraw  0.3.7
metavalue.hpp
1 /*
2  * libopenraw - metavalue.h
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 #pragma once
23 
24 #include <stdint.h>
25 #include <vector>
26 
27 #include <boost/variant.hpp>
28 
29 #include "ifd.hpp"
30 
31 namespace OpenRaw {
32 
34 class MetaValue
35 {
36 public:
37  typedef boost::variant<std::string, uint8_t, uint32_t, int32_t, double, OpenRaw::Internals::IFD::ORRational, OpenRaw::Internals::IFD::ORSRational> value_t;
38 
39  MetaValue(const MetaValue &);
40  template <class T> MetaValue(const T &v)
41  {
42  m_values.push_back(v);
43  }
44  template <class T> MetaValue(const std::vector<T> &v)
45  : m_values(v)
46  {
47  }
48  explicit MetaValue(const value_t &v);
49  explicit MetaValue(const std::vector<value_t> &v);
50 
51  uint32_t getCount() const
52  {
53  return m_values.size();
54  }
55 
56  uint32_t getUInteger(int idx) const;
57  int32_t getSInteger(int idx) const;
58  const std::string & getString(int idx) const;
59  double getDouble(int idx) const;
62  const std::string & getAsString(bool full) const;
63 private:
65  template<typename T> T get(int idx) const;
67  template<typename T> const T & getRef(int idx) const;
68 
69  std::vector<value_t> m_values;
70  mutable std::string m_as_str;
71 };
72 
73 
74 }
75 
76 /*
77  Local Variables:
78  mode:c++
79  c-file-style:"stroustrup"
80  c-file-offsets:((innamespace . 0))
81  indent-tabs-mode:nil
82  fill-column:80
83  End:
84 */
Metadata value.
Definition: metavalue.hpp:35
const std::string & getAsString(bool full) const
Convert to a string.
Definition: metavalue.cpp:132
Global namespace for libopenraw.
Definition: arwfile.cpp:29