move base value type definitions to separate header to enable basic types to be includes without full overhead of value conversions
This commit is contained in:
parent
648105c2c4
commit
59dace25db
2 changed files with 89 additions and 53 deletions
|
@ -24,6 +24,7 @@
|
|||
#define MAPNIK_VALUE_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/value_types.hpp>
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
@ -69,54 +70,6 @@ inline void to_utf8(UnicodeString const& input, std::string & target)
|
|||
}
|
||||
}
|
||||
|
||||
struct value_null
|
||||
{
|
||||
template <typename T>
|
||||
value_null operator+ (T const& other) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator- (T const& other) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator* (T const& other) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator/ (T const& other) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator% (T const& other) const
|
||||
{
|
||||
boost::ignore_unused_variable_warning(other);
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BIGINT
|
||||
typedef long long value_integer;
|
||||
#else
|
||||
typedef int value_integer;
|
||||
#endif
|
||||
|
||||
typedef double value_double;
|
||||
typedef UnicodeString value_unicode_string;
|
||||
typedef bool value_bool;
|
||||
|
||||
typedef boost::variant<value_null,value_bool,value_integer,value_double,value_unicode_string> value_base;
|
||||
|
||||
namespace impl {
|
||||
|
@ -798,11 +751,7 @@ struct to_int : public boost::static_visitor<value_integer>
|
|||
value_integer operator() (std::string const& val) const
|
||||
{
|
||||
value_integer result;
|
||||
#ifdef BIGINT
|
||||
if (util::string2longlong(val,result))
|
||||
#else
|
||||
if (util::string2int(val,result))
|
||||
#endif
|
||||
return result;
|
||||
return value_integer(0);
|
||||
}
|
||||
|
@ -912,7 +861,6 @@ public:
|
|||
{
|
||||
return boost::apply_visitor(impl::to_int(),base_);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
inline const value operator+(value const& p1,value const& p2)
|
||||
|
|
88
include/mapnik/value_types.hpp
Normal file
88
include/mapnik/value_types.hpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* This file is part of Mapnik (c++ mapping toolkit)
|
||||
*
|
||||
* Copyright (C) 2012 Artem Pavlenko
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAPNIK_VALUE_TYPES_HPP
|
||||
#define MAPNIK_VALUE_TYPES_HPP
|
||||
|
||||
// icu
|
||||
#include <unicode/unistr.h> // for UnicodeString
|
||||
|
||||
// boost
|
||||
//#include <boost/cstdint.hpp>
|
||||
|
||||
// stl
|
||||
#include <iosfwd> // for ostream
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
#ifdef BIGINT
|
||||
//typedef boost::long_long_type value_integer;
|
||||
typedef long long value_integer;
|
||||
#else
|
||||
typedef int value_integer;
|
||||
#endif
|
||||
|
||||
typedef double value_double;
|
||||
typedef UnicodeString value_unicode_string;
|
||||
typedef bool value_bool;
|
||||
|
||||
struct value_null
|
||||
{
|
||||
template <typename T>
|
||||
value_null operator+ (T const& /*other*/) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator- (T const& /*other*/) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator* (T const& /*other*/) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator/ (T const& /*other*/) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
value_null operator% (T const& /*other*/) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream& operator<< (std::ostream & out,value_null const& v)
|
||||
{
|
||||
return out;
|
||||
}
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_VALUE_TYPES_HPP
|
Loading…
Add table
Reference in a new issue