|
Boost Users : |
Subject: [Boost-users] [Users][Property Tree] Problem with compiling basic_tree<std::string, ...>
From: Jani Plesnicar (plesnicar.jani_at_[hidden])
Date: 2010-07-11 09:24:10
Hy i have problem with
#include "windows.h"
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <iostream>
#include <map>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/property_tree/exceptions.hpp>
#include <boost/property_tree/ptree_fwd.hpp>
#include <boost/property_tree/string_path.hpp>
#include <boost/property_tree/stream_translator.hpp>
#include <boost/property_tree/exceptions.hpp>
#include <boost/property_tree/detail/ptree_utils.hpp>
namespace property_tree = boost::property_tree;
namespace json_parser = boost::property_tree::json_parser;
namespace info_parser = boost::property_tree::info_parser;
namespace xml_parser = boost::property_tree::xml_parser;
class DataHold
{
public:
const DataHold& DataHold::operator=(const DataHold& oth)
{
return oth;
}
DataHold::DataHold(void)
: _dht(DHT_NULL)
{/**/}
DataHold::DataHold(int* d)
: _d_pint(d), _dht(DHT_PINT)
{/**/}
DataHold::DataHold(char* d)
: _d_pchar(d), _dht(DHT_PCHAR)
{/**/}
DataHold::DataHold(float* d)
: _d_pfloat(d), _dht(DHT_PFLOAT)
{/**/}
DataHold::DataHold(double* d)
: _d_pdouble(d), _dht(DHT_PDOUBLE)
{/**/}
DataHold::DataHold(bool* d)
: _d_pbool(d), _dht(DHT_PBOOL)
{/**/}
DataHold::DataHold(std::string* d)
: _d_pstdstr(d), _dht(DHT_PSTDSTRING)
{/**/}
typedef enum
{
DHT_NULL,
DHT_PINT,
DHT_PCHAR,
DHT_PBOOL,
DHT_PFLOAT,
DHT_PDOUBLE,
DHT_PSTDSTRING
} DATA_HOLD_TYPE;
DATA_HOLD_TYPE DataHold::TypeIndex() const
{return _dht;}
int* _d_pint;
char* _d_pchar;
bool* _d_pbool;
float* _d_pfloat;
double* _d_pdouble;
std::string* _d_pstdstr;
bool empty() const
{
return _dht==DHT_NULL;
}
friend std::ostream& operator<< (std::ostream &os,const DataHold &me)
{
os << (int)(me.TypeIndex());
return os;
}
private:
friend class property_tree::basic_ptree<std::string,DataHold>;
void swap(DataHold& x)
{
int* dint = x._d_pint;
char* dchr = x._d_pchar;
bool* dbol = x._d_pbool;
float* dflt = x._d_pfloat;
double* ddbl = x._d_pdouble;
std::string* dstr = x._d_pstdstr;
DATA_HOLD_TYPE dht = x._dht;
x._d_pint = this->_d_pint;
x._d_pchar = this->_d_pchar;
x._d_pbool = this->_d_pbool;
x._d_pfloat = this->_d_pfloat;
x._d_pdouble = this->_d_pdouble;
x._d_pstdstr = this->_d_pstdstr;
x._dht = this->_dht;
this->_d_pint = dint;
this->_d_pchar = dchr;
this->_d_pbool = dbol;
this->_d_pfloat = dflt;
this->_d_pdouble = ddbl;
this->_d_pstdstr = dstr;
this->_dht = dht;
}
DATA_HOLD_TYPE _dht;
};
namespace prop_tree {
typedef property_tree::basic_ptree<std::string,DataHold> ptreedh;
};
int main(int argc, char** argv)
{
std::string nejm = "Test";
std::string priimk = "Bla";
int dejt[3] = {14, 06, 2010};
float height = 181.5f;
float weight = 57.5f;
prop_tree::ptreedh ptree_rt;
prop_tree::ptreedh pt = ptree_rt.put("oseba.ime", DataHold(&nejm));
std::cout << ptree_rt.get_value("oseba.ime");
system("pause");
return 0;
}
I get these errors in Visual Studio C++ 2008 when trying to compile.
1>------ Build started: Project: DebugServerLib, Configuration: Debug Win32
------
1>Compiling...
1>main.cpp
1>p:\cpp\boost\include\boost-1_42\boost\property_tree\detail\ptree_implementation.hpp(655)
: error C2027: use of undefined type
'boost::property_tree::translator_between<Internal,External>'
1> with
1> [
1> Internal=DataHold,
1>
External=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1> ]
1>
p:\cpp\boost\include\boost-1_42\boost\property_tree\detail\ptree_implementation.hpp(666)
: see reference to function template instantiation
'std::basic_string<_Elem,_Traits,_Ax>
boost::property_tree::basic_ptree<Key,Data>::get_value<std::basic_string<_Elem,_Traits,_Ax>>(const
Type &) const' being compiled
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>,
1> Key=std::string,
1> Data=DataHold,
1> Type=std::basic_string<char,std::char_traits<char>,std::allocator<char>>
1> ]
1> p:\cpp\debugserverlib\debugserverlib\main.cpp(156) : see reference to
function template instantiation 'std::basic_string<_Elem,_Traits,_Ax>
boost::property_tree::basic_ptree<Key,Data>::get_value<char>(const Ch *)
const' being compiled
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>,
1> Key=std::string,
1> Data=DataHold,
1> Ch=char
1> ]
1>p:\cpp\boost\include\boost-1_42\boost\property_tree\detail\ptree_implementation.hpp(655)
: error C2955: 'boost::type' : use of class template requires template
argument list
1> p:\cpp\boost\include\boost-1_42\boost\type.hpp(14) : see declaration of
'boost::type'
1>p:\cpp\boost\include\boost-1_42\boost\property_tree\detail\ptree_implementation.hpp(655)
: error C2780:
'boost::enable_if<boost::property_tree::detail::is_character<Ch>,std::basic_string<Ch>>::type
boost::property_tree::basic_ptree<Key,Data>::get_value(const Ch *) const' :
expects 1 arguments - 2 provided
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1> p:\cpp\boost\include\boost-1_42\boost\property_tree\ptree.hpp(344) : see
declaration of 'boost::property_tree::basic_ptree<Key,Data>::get_value'
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1>p:\cpp\boost\include\boost-1_42\boost\property_tree\detail\ptree_implementation.hpp(655)
: error C2780:
'boost::disable_if<boost::property_tree::detail::is_translator<Type>,Type>::type
boost::property_tree::basic_ptree<Key,Data>::get_value(const Type &) const'
: expects 1 arguments - 2 provided
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1> p:\cpp\boost\include\boost-1_42\boost\property_tree\ptree.hpp(336) : see
declaration of 'boost::property_tree::basic_ptree<Key,Data>::get_value'
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1>p:\cpp\boost\include\boost-1_42\boost\property_tree\detail\ptree_implementation.hpp(655)
: error C2784:
'boost::enable_if<boost::property_tree::detail::is_character<Ch>,std::basic_string<Ch>>::type
boost::property_tree::basic_ptree<Key,Data>::get_value(const Ch
*,Translator) const' : could not deduce template argument for 'const Ch *'
from 'const std::basic_string<_Elem,_Traits,_Ax>'
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1> and
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> p:\cpp\boost\include\boost-1_42\boost\property_tree\ptree.hpp(328) : see
declaration of 'boost::property_tree::basic_ptree<Key,Data>::get_value'
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1>p:\cpp\boost\include\boost-1_42\boost\property_tree\detail\ptree_implementation.hpp(655)
: error C2780: 'Type
boost::property_tree::basic_ptree<Key,Data>::get_value(void) const' :
expects 0 arguments - 2 provided
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1> p:\cpp\boost\include\boost-1_42\boost\property_tree\ptree.hpp(313) : see
declaration of 'boost::property_tree::basic_ptree<Key,Data>::get_value'
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1>p:\cpp\boost\include\boost-1_42\boost\property_tree\detail\ptree_implementation.hpp(655)
: error C2780:
'boost::enable_if<boost::property_tree::detail::is_translator<Translator>,Type>::type
boost::property_tree::basic_ptree<Key,Data>::get_value(Translator) const' :
expects 1 arguments - 2 provided
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1> p:\cpp\boost\include\boost-1_42\boost\property_tree\ptree.hpp(306) : see
declaration of 'boost::property_tree::basic_ptree<Key,Data>::get_value'
1> with
1> [
1> Key=std::string,
1> Data=DataHold
1> ]
1>Build Time 0:05
1>Build log was saved at
"file://p:\cpp\DebugServerLib\DebugServerLib\Debug\BuildLog.htm"
1>DebugServerLib - 7 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net