Blame lib/metavalue.hpp

rpm-build d2b433
/*
rpm-build d2b433
 * libopenraw - metavalue.h
rpm-build d2b433
 *
rpm-build d2b433
 * Copyright (C) 2007-2016 Hubert Figuiere
rpm-build d2b433
 * Copyright (C) 2008 Novell, Inc.
rpm-build d2b433
 *
rpm-build d2b433
 * This library is free software: you can redistribute it and/or
rpm-build d2b433
 * modify it under the terms of the GNU Lesser General Public License
rpm-build d2b433
 * as published by the Free Software Foundation, either version 3 of
rpm-build d2b433
 * the License, or (at your option) any later version.
rpm-build d2b433
 *
rpm-build d2b433
 * This library is distributed in the hope that it will be useful,
rpm-build d2b433
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build d2b433
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build d2b433
 * Lesser General Public License for more details.
rpm-build d2b433
 *
rpm-build d2b433
 * You should have received a copy of the GNU Lesser General Public
rpm-build d2b433
 * License along with this library.  If not, see
rpm-build d2b433
 * <http://www.gnu.org/licenses/>.
rpm-build d2b433
 */
rpm-build d2b433
rpm-build d2b433
rpm-build d2b433
#ifndef LIBOPENRAWPP_METAVALUE_H_
rpm-build d2b433
#define LIBOPENRAWPP_METAVALUE_H_
rpm-build d2b433
rpm-build d2b433
#include <stdint.h>
rpm-build d2b433
#include <vector>
rpm-build d2b433
rpm-build d2b433
#include <boost/variant.hpp>
rpm-build d2b433
rpm-build d2b433
namespace OpenRaw {
rpm-build d2b433
rpm-build d2b433
class MetaValue
rpm-build d2b433
{
rpm-build d2b433
public:
rpm-build d2b433
    typedef boost::variant<std::string, uint32_t, double> value_t;
rpm-build d2b433
rpm-build d2b433
    MetaValue(const MetaValue &);
rpm-build d2b433
    template <class T> MetaValue(const T &v)
rpm-build d2b433
        {
rpm-build d2b433
            m_values.push_back(v);
rpm-build d2b433
        }
rpm-build d2b433
    template <class T> MetaValue(const std::vector<T> &v)
rpm-build d2b433
        : m_values(v)
rpm-build d2b433
        {
rpm-build d2b433
        }
rpm-build d2b433
    explicit MetaValue(const value_t &v);
rpm-build d2b433
    explicit MetaValue(const std::vector<value_t> &v);
rpm-build d2b433
rpm-build d2b433
    uint32_t getCount() const
rpm-build d2b433
        {
rpm-build d2b433
            return m_values.size();
rpm-build d2b433
        }
rpm-build d2b433
rpm-build d2b433
    uint32_t getInteger(int idx) const;
rpm-build d2b433
    const std::string & getString(int idx) const;
rpm-build d2b433
    double getDouble(int idx) const;
rpm-build d2b433
private:
rpm-build d2b433
    /// Return a copy of the value
rpm-build d2b433
    template<typename T> T get(int idx) const;
rpm-build d2b433
    /// Return a const ref to the value. T needs to be default constructible.
rpm-build d2b433
    template<typename T> const T & getRef(int idx) const;
rpm-build d2b433
rpm-build d2b433
    std::vector<value_t> m_values;
rpm-build d2b433
};
rpm-build d2b433
rpm-build d2b433
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
/*
rpm-build d2b433
  Local Variables:
rpm-build d2b433
  mode:c++
rpm-build d2b433
  c-file-style:"stroustrup"
rpm-build d2b433
  c-file-offsets:((innamespace . 0))
rpm-build d2b433
  indent-tabs-mode:nil
rpm-build d2b433
  fill-column:80
rpm-build d2b433
  End:
rpm-build d2b433
*/
rpm-build d2b433
rpm-build d2b433
#endif