当前位置: 首页>>代码示例>>C++>>正文


C++ json::value类代码示例

本文整理汇总了C++中json::value的典型用法代码示例。如果您正苦于以下问题:C++ value类的具体用法?C++ value怎么用?C++ value使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了value类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: draw

    // canvas::draw overridable
    virtual void draw( HELEMENT he, graphics& gx, UINT width, UINT height )
    { 
      if( !data.is_array() )
      {
        draw_message( gx, width, height, const_wchars(L"Data not found") );
        return; 
      }

      color black(0,0,0);

       // x axis
      gx.line_cap(LINE_CAP_BUTT);
      gx.line_color(black);
      gx.line( 0.5, height - 0.5, width - 0.5, height - 0.5 ); // 0.5 - to draw line in the middle of the pixel

      for( int n = 0; n < data.length(); ++n )
      {
        json::value bar_def = data[n];
        json::value color_v = bar_def.k2v(L"color"); 
        json::value value_v = bar_def.k2v(L"value");
        if( color_v.is_undefined() || value_v.is_undefined())
        {
          draw_message( gx, width, height, const_wchars(L"Bad data structure") );
          return; 
        }
        draw_bar(gx, width, height, n, data.length(), color(color_v.get(0)), value_v.get(1.0));
      }
    }
开发者ID:txe,项目名称:ieml,代码行数:29,代码来源:behavior_chart.cpp

示例2: strtod

	/*!
	 * \brief Reads an ECMAScript conformant number from the input buffer
	 */
bool parser_UTF8::readnum(JSON::value &rv){
	bool flt=false;
	const char *strt =bfr.ptr;
	bool fail=false;
	while (charisNumeric(*(bfr.ptr))){
		if (*(bfr.ptr) == '.' || *(bfr.ptr) == 'e' || *(bfr.ptr) == 'E'){flt=true;}
		++bfr.ptr;
		if (bfr.ptr == bfr.end) break;
	}
	int len = bfr.ptr - strt;
	char *tmpbuf = new char[len +1];
	memcpy(tmpbuf,strt,len);
	tmpbuf[len] = '\0';
	if (flt){
		char *nd;
		double v = strtod(tmpbuf,&nd);
		if (nd != tmpbuf+len) fail=true;
		rv.setnumber(v);
	}else{
		aint v;
		char *nd;
		v=strtoaint(tmpbuf,&nd,10);
		if (nd != tmpbuf+len) fail=true;
		rv.setnumber(v);
	}
	delete [] tmpbuf;
	return !fail;
}
开发者ID:stestagg,项目名称:Personal,代码行数:31,代码来源:parser_UTF8.cpp

示例3: open

 json::value main_frame::open(json::value url, json::value param)
 {
   if( !url.is_string() )
     return json::value(false);
   sciter::main_frame* wnd = new sciter::main_frame(url.to_string().c_str());
   return json::value(wnd != 0);
 }
开发者ID:huxiyu,项目名称:sciter-sdk,代码行数:7,代码来源:sciter.cpp

示例4: readarray

bool UTF_test::readarray(){
	JSON::parser_UTF8 parser("[ \"a\" , \"b\" ]");
	JSON::value a;
	parser.readarray(a);
	if (a.getrawarray().size() != 2){
		return false;
	}

	parser.bfr.mapstring("[ 3 1 4 1 5 9 2 6 5 3]");
	parser.getvalue(a);
	if (a.getrawarray().size() != 10){
		return false;
	}
	if (a[5].getinteger() != 9) return false;

	parser.bfr.mapstring("[ [1,1,2,3,5],[8,13,21,34]]");
	parser.getvalue(a);
	astr tmp;
	a.getstring(tmp);

	if (tmp != A(" [  [ 1 , 1 , 2 , 3 , 5 ]  ,  [ 8 , 13 , 21 , 34 ]  ] ")){
		return false;
	}

	return true;
}
开发者ID:stestagg,项目名称:brokenhub,代码行数:26,代码来源:utf_tests.cpp

示例5: EndTask

void HandleJson::EndTask(json::value jsonObj)
{
    /// Get the value for Json Object.
    int jobId = jsonObj.at(U("JobId")).as_integer();
    int taskId = jsonObj.at(U("TaskId")).as_integer();

    JobTaskDb::GetInstance().EndTask(jobId, taskId);
}
开发者ID:EvanCui,项目名称:whpc-linux-communicator,代码行数:8,代码来源:RemotingExecutor.cpp

示例6: FromJson

StartTaskArgs StartTaskArgs::FromJson(const json::value& j)
{
    StartTaskArgs args(
        JsonHelper<int>::Read("JobId", j.at("m_Item1")),
        JsonHelper<int>::Read("TaskId", j.at("m_Item1")),
        ProcessStartInfo::FromJson(j.at("m_Item2")));

    return std::move(args);
}
开发者ID:coolmay,项目名称:whpc-linux-communicator,代码行数:9,代码来源:StartTaskArgs.cpp

示例7: read_file

bool UTF_test::read_file(){
	JSON::parser_UTF8 parser;
	JSON::value value;
	parser.parsefile(value, "test.json");

	if (parser.fail()) return false;
	return true;
	astr s = value.getchild("Hello").getrawstring();
	if (s != A("world")) return false;
	return true;
}
开发者ID:stestagg,项目名称:brokenhub,代码行数:11,代码来源:utf_tests.cpp

示例8: get_string

static string_t get_string( const json::value& obj, const string_t& key, const string_t& def ) {
	if( !obj.has_field( key ) ) {
		return def;
	}

	json::value val = obj.at( key );
	if( val.is_null( ) ) {
		return def;
	}
	return val.as_string( );
}
开发者ID:smith61,项目名称:gmusicapi-cpp,代码行数:11,代码来源:song.cpp

示例9: __print_scalar

static void __print_scalar (string & result, const json::value & v)
{
    if (v.is_null()) {
        result.append("null");
    } else if (v.is_string()) {
		string r;
		result.append(1, '"');
		result.append(v.get<string>());
		result.append(1, '"');
	} else {
    	result.append(v.get<string>());
    }
}
开发者ID:semenovf,项目名称:pfs-json,代码行数:13,代码来源:pretty_print.cpp

示例10: parser

bool UTF_test::reado1(){
	JSON::parser_UTF8 parser("{a:\"ba\", b:2}");
	astr s;
	JSON::value v;
	parser.parse(v);
	if (parser.errorcount() > 2) return false; // If error 11 is enabled, we don't want to fail here
	astr dst;
	v.getstring(dst,true,false);
	if (
		   (dst != A(" { \"a\" : \"ba\" , \"b\" : 2 } "))
		&& (dst != A(" { \"b\" : 2 , \"a\" : \"ba\" } "))
		){ return false;}
	return true;
}
开发者ID:stestagg,项目名称:brokenhub,代码行数:14,代码来源:utf_tests.cpp

示例11: if

	/*!
	 * \brief Reads an array from the input stream into \p rv
	 */
bool parser_UTF8::readarray(JSON::value &rv){
	rv.setarray();
	if (*bfr.ptr != '[') return false;
	++bfr.ptr;

	bool first=true;
	while (1){
		JSON::value curval;

		skipWS();
		if (bfr.ptr >= bfr.end){
			adderror(5);
			return false;
		}
		
		if (*bfr.ptr == ']'){
			++bfr.ptr;
			return true;
		}else if (*bfr.ptr != ','){
			if (first!=true){adderror(8);}
		}else{
			++bfr.ptr;
			skipWS();
			if (bfr.ptr >= bfr.end){
				adderror(5);
				return false;
			}
			if (*bfr.ptr == ']'){
				++bfr.ptr;
				return true;
			}
		}
		
		skipWS();
		if (bfr.ptr == bfr.end){
			adderror(5); return false;
		}
		
		
		getvalue(curval);
		if (curval.getdatatype() == datatype::_undefined && *(bfr.ptr)!=','){
			adderror(8);
			return false;
		}
		rv.addvalue(curval);
		first=false;
	}
	return true;
}
开发者ID:stestagg,项目名称:Personal,代码行数:52,代码来源:parser_UTF8.cpp

示例12: __print_container

static void __print_container (string & result
        , json::value const & value
        , print_spec const & pspec
        , int indent)
{
    if (value.size() == 0) { 
        __print_open_brace(result, value, pspec);
        __print_close_brace(result, value, pspec);
        return;
    }
    
    json::value::const_iterator it_begin = value.cbegin();
    json::value::const_iterator it_end   = value.cend();
    json::value::const_iterator it       = it_begin;
    json::value::const_iterator it_next  = it_begin;
        
    ++it_next;
    
    indent += pspec.base_indent;
    
    __print_open_brace(result, value, pspec);
    result.append(pspec.new_line); // container content always begin after new line
    
    for (; it != it_end; ++it, ++it_next) {
        if (it == it_begin) {
            __print_indent(result, pspec, indent);
            
            if (pspec.comma_position == json::comma_next_line) {
                __print_indent(result, pspec, pspec.first_item_indent);
            }
        }
        
        if (value.is_object()) {
            __print_value(result, it.key(), *it, pspec, indent);
        } else {
            __print_value(result, *it, pspec, indent);
        }
        
        if (it_next != it_end) {
            __print_comma(result, pspec, indent);
        }
    }
    
    indent -= pspec.base_indent;    
    
    result.append(pspec.new_line);
    __print_indent(result, pspec, indent);
    __print_close_brace(result, value, pspec);
}
开发者ID:semenovf,项目名称:pfs-json,代码行数:49,代码来源:pretty_print.cpp

示例13: set_checkbox_bits

 // sets checkboxes by bit mask 
 inline void set_checkbox_bits(dom::element& el, const json::value& t )
 {
   selected_cb selected;
   dom::element r = el.parent(); // ATTN: I assume here that all checkboxes in the group belong to the same parent!
   r.find_all(&selected, "[type='checkbox'][name='%S']", el.get_attribute("name"));
   int m = 1, v = selected.elements.size()==1?(t.get(false)?1:0):t.get(0);
   for( unsigned int n = 0; n < selected.elements.size(); ++n, m <<= 1 )
   {
     dom::element& e = selected.elements[n];
     if( (v & m) != 0)
         e.set_state(  STATE_CHECKED, 0 ) ;
     else
         e.set_state(  0, STATE_CHECKED ) ;
   }
 }
开发者ID:AllanDragoon,项目名称:dotnetinstaller,代码行数:16,代码来源:htmlayout_controls.hpp

示例14: StartTask

void HandleJson::StartTask(json::value jsonObj, std::string callBackUri)
{
    std::cout << "StartTask ... " << std::endl;

    // Get value from Json Object.
    auto arg = jsonObj.at(U("m_Item1"));
    auto startInfoJson = jsonObj.at(U("m_Item2"));
    int jobId = arg.at(U("JobId")).as_integer();
    int taskId = arg.at(U("TaskId")).as_integer();
    ProcessStartInfo *startInfo = ProcessStartInfo::FromJson(startInfoJson);

    std::cout << "start the task: " << startInfo->commandLine << std::endl;

    JobTaskDb::GetInstance().StartJobAndTask(jobId, taskId, startInfo, callBackUri);
}
开发者ID:EvanCui,项目名称:whpc-linux-communicator,代码行数:15,代码来源:RemotingExecutor.cpp

示例15: __print_value

static void __print_value (string & result
        , string const & key
        , json::value const & value
        , print_spec const & pspec
        , int indent)
{
    result.append(__stringify(key));
    result.append(pspec.ws_before_kvseparator);
    result.append(pspec.key_separator);
    
    if (value.is_scalar()) {
        result.append(pspec.ws_after_kvseparator);
        __print_scalar(result, value);
    } else {
        if (pspec.brace_position == json::brace_same_line) {
            result.append(pspec.ws_after_kvseparator);
        } else if (pspec.brace_position == json::brace_next_line) {
            result.append(pspec.new_line);
            __print_indent(result, pspec, indent);
            __print_brace_indent(result, pspec, pspec.brace_indent);
        }
        
        indent += pspec.brace_indent;
        __print_container(result, value, pspec, indent);
        indent -= pspec.brace_indent;
    }
}
开发者ID:semenovf,项目名称:pfs-json,代码行数:27,代码来源:pretty_print.cpp


注:本文中的json::value类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。