tinybind学习一

本文介绍了tinybind,一个用于tinyxml的跨平台XML解析器的附加库,它简化了C++结构定义与XML文件之间的序列化/反序列化过程。文章详细记录了在Linux环境下编译tinybind过程中遇到的问题及解决办法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

tinybind 简介

add-on library for the cross-platform XML parser tinyxml that makes it easy to "bind" a C++ struct definition to an XML file format for easy serialize/deserialize. supports nested structs and STL containers.

源码地址

tinybind 编译

由于tinybind好多年没人维护了,编译时出现了多出错误。

在linux下编译时,出现了以下错误:

1、tinybind/tinybind.h:222: error: there are no arguments to 'params' that depend on a template parameter, so a declaration of 'params' must be available [-fpermissive]
      错误原因查看:参考文档

      解决方法:在 IMemberHolder<T>的报错子类中添加:

     using IMemberHolder<T>::tag;

     using IMemberHolder<T>::params;

2、tinybind/tinytest.cpp:27: error: specializing member '::GetTiXmlBinding<MyData>' requires 'template<>' syntax  TiXmlBinding<MyData> const *

      解决方法:

    TiXmlBinding<MyData> const *
GetTiXmlBinding<MyData>( MyData const &, Identity<MyData> )

   改为

   TiXmlBinding<MyData> const *
GetTiXmlBinding( MyData const &, Identity<MyData> )

3、tinybind/tinybind.h:276: error: 'stricmp' was not declared in this scope
     if( !stricmp(elem.Value(), tag()) ) {

   解决方法:   stricmp改为strcmp

4、tinybind/tinybind.h:324: error: 'ConvertFromString' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
       ConvertFromString( attributeValue, &mv );

      tinybind/tinybind.h:335: error: 'ConvertToString' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
     char const * attributeValue = ConvertToString( mv );
                                                       ^              ^

  解决方法:

   由于void ConvertFromString( char const * strIn, T * dataOut );

  char const * ConvertToString( T const & t );

  申明在调用者的后面,所以讲这两个申明放到前面就可以了   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值