JSON函数表
jsoncpp 主要包含三个class:Value、Reader、Writer。注意Json::Value 只能处理 ANSI 类型的字符串,如果 C++ 程序是用 Unicode 编码的,最好加一个 Adapt 类来适配。
Json内部类和方法:
Reader<是用于读取的,说的确切点,是用于将字符串转换为 Json::Value 对象的>
【构造函数】
1、Reader();
【拷贝构造函数】
2、Reader( const Features &features );
【将字符串或者输入流转换为JSON的Value对象】
【下边是相应的parse的重载函数】
3、bool parse( const std::string &document, Value &root,bool collectComments = true );
4、bool parse( const char *beginDoc, const char *endDoc,
Value &root,bool collectComments = true
5、bool parse( std::istream &is,Value &root,bool collectComments = true );
6、std::string getFormatedErrorMessages() const;
Value:<是jsoncpp 中最基本、最重要的类,用于表示各种类型的对象,jsoncpp 支持的对象类型可见 Json::ValueType 枚举值; Value类的对象代表一个JSON值,既可以代表一个文档,也可以代表 文档中一个值。如同JSON中定义的“值”一样,Value是递归的>
【构造函数】
1、Value( ValueType type = nullValue );
Value( Int value );
Value( UInt value );
Value( double value );
Value( const char *value );
Value( const char *beginValue, const char *endValue );
【拷贝构造函数】
2、Value( const StaticString &value );
Value( const std::string &value );
Value( const Value &other );
【相同类型的比较、交换、类型的获取】
3、void swap( Value &other );
ValueType type() const;
int compare( const Value &other );
【相应的赋值运算符的重载函数】
4、Value &operator=( const Value &other );
bool operator <( const Value &other ) const;
bool operator <=( const Value &other ) const;
bool operator >=( const Value &other ) const;
bool operator >( const Value &other ) const;
bool operator ==( const Value &other ) const;
bool operator !=( const Value &other ) const;
bool operator!() const;
Value &operator[]( UInt index );
const Value &operator[]( UInt index ) const;
【将Value对象进行相应的类型转换】
5、const char *asCString() const;
std::string asString() const;
const char *asCString() const;
std::string asString() const;
Int asInt() const;
UInt asUInt() const;
double asDouble() const;
【相应的判断函数】
6、bool isNull() const;
bool isBool() const;
bool isInt() const;
bool isUInt() const;
bool isIntegral() const;
bool isDouble() const;
bool isNumeric() const;
bool isString() const;
bool isArray() const;
bool isObject() const;
bool isConvertibleTo( ValueType other ) const;
bool isValidIndex( UInt index ) const;
bool isMember( const char *key ) const;
bool isMember( const std::string &key ) const;
【清除和扩容函数】
7、void clear();
void resize( UInt size );
【获取满足相应条件的Value】
8、Value get( UInt index, const Value &defaultValue ) const;
Value get( const std::string &key,const Value &defaultValue ) const;
Members getMemberNames() const;
【删除满足相应条件的Value】
9、Value removeMember( const char* key );
Value removeMember( const std::string &key );
10、void setComment( const char *comment,CommentPlacement placement );
void setComment( const std::string &comment,CommentPlacement placement );
bool hasComment( CommentPlacement placement ) const;
std::string getComment( CommentPlacement placement ) const;
std::string toStyledString()const;
Writer:<类是一个纯虚类,并不能直接使用。在此我们使用 Json::Writer 的子类(派生类):
Json::FastWriter、Json::StyledWriter、Json::StyledStreamWriter。顾名思义,用 Json::FastWriter 来处理 json 应该是最快的;负责将内存中的Value对象转换成JSON文档,
输出到文件或者是字符串中>
【FastWriter】
1、FastWriter();
virtual ~FastWriter(){}
void enableYAMLCompatibility();
virtual std::string write( const Value &root );
【StyledWriter】
2、StyledWriter();
virtual ~StyledWriter(){}
virtual std::string write( const Value &root );
JSON函数表的更多相关文章
- JSON函数表2
[class] Json::Reader [public] [将字符串或者输入流转换为JSON的Value对象] bool parse( const std::string &document ...
- JSON函数表1
jsoncpp 主要包含三个class:Value.Reader.Writer.注意Json::Value 只能处理 ANSI 类型的字符串,如果 C++ 程序是用 Unicode 编码的,最好加一个 ...
- C++ 虚函数表解析
转载:陈皓 http://blog.csdn.net/haoel 前言 C++中 的虚函数的作用主要是实现了多态的机制.关于多态,简而言之就是用父类型别的指针指向其子类的实例,然后通过父类的指针调用实 ...
- C++ 多态、虚函数机制以及虚函数表
1.非virtual函数,调用规则取决于对象的显式类型.例如 A* a = new B(); a->display(); 调用的就是A类中定义的display().和对象本体是B无关系. 2. ...
- C++迟后联编和虚函数表
先看一个题目: class Base { public: virtual void Show(int x) { cout << "In Base class, int x = & ...
- C++ 知道虚函数表的存在
今天翻看陈皓大大的博客,直接找关于C++的东东,看到了虚函数表的内容,找一些能看得懂的地方记下笔记. 0 引子 类中存在虚函数,就会存在虚函数表,在vs2015的实现中,它存在于类的头部. 假设有如下 ...
- C++虚函数和虚函数表
前导 在上面的博文中描述了基类中存在虚函数时,基类和派生类中虚函数表的结构. 在派生类也定义了虚函数时,函数表又是怎样的结构呢? 先看下面的示例代码: #include <iostream> ...
- C++ Daily 《5》----虚函数表的共享问题
问题: 包含一个以上虚函数的 class B, 它所定义的 对象是否共用一个虚函数表? 分析: 由于含有虚函数,因此对象内存包含了一个指向虚函数表的指针,但是这个指针指向的是同一个虚函数表吗? 实验如 ...
- C++虚函数表
大家知道虚函数是通过一张虚函数表来实现的.在这个表中,主要是一个类的虚函数的地址表,这张表解决了继承.覆盖的问题,其内容真是反应实际的函数.这样,在有虚函数的类的实例中,这个表分配在了这个实例的内存中 ...
随机推荐
- 转载 AMI方案和Insyde方案
闲来无事回头看看,自毕业以来一直都在BIOS这个行业打转,目前的各种新闻来看全球的IT行业都似乎不太景气,PC出货量一泻千里,想要有所转机看起来不是一天两天的事情,想来无事来看看做过的几个UEFI B ...
- Nginx之共享内存与slab机制
1. 共享内存 在 Nginx 里,一块完整的共享内存以结构体 ngx_shm_zone_t 来封装,如下: typedef struct ngx_shm_zone_s ngx_shm_zone_t; ...
- ECharts3D地图(详细示例——附有具体注释)
3D地图图表效果如下: 具体代码如下: <!DOCTYPE html><html><head> <meta charset="UTF-8" ...
- Ansible批量自动化管理工具 roles标准化
批量管理服务器的工具,无需部署代理,通过ssh进行管理,是python写的 ansible 常用模块 : (1)shell命令模块执行命令 (2)copy模块批量下发文件或文件夹 (3)script模 ...
- Sqlite的操作示例代码
import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.databa ...
- C#txt文件创建并写入信息
public static void LogWrite(string str) { //项目根目录 string path = HttpContext.Current.Server.MapPath(& ...
- smarty section 循环不同的四个样式
<div class="moban_spzs"> <{section name=goodslist loop=$strdata6}> <{if $sm ...
- 配置了configuration.xml之后提示找不到映射关系
在启动类里面单独增加一个Bean即可解决 @Bean public DatabaseIdProvider getDatabaseIdProvider(){ DatabaseIdProvider dat ...
- 原生vue实现表格的编辑,包括单元格合并,拆分,删除行/列, 添加行/列
先看效果图如下: 代码看这里: https://github.com/YalongYan/vue-table-edit
- appium的第一个实例
# !/usr/bin/env python # -*- coding:utf-8 -*- from appium import webdriver import time import unitte ...