• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ value类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: check

encoder operator<<(encoder e, const value& v) {
    data edata = e.data();
    if (edata == v.data_) throw conversion_error("cannot insert into self");
    data vdata = v.decode().data();
    check(edata.append(vdata), e.pn_object());
    return e;
}
开发者ID:Barba-studio,项目名称:qpid-proton,代码行数:7,代码来源:encoder.cpp


示例2: sql

object sqlite3::compile(flusspferd::string sql_in, value bind ) {
    local_root_scope scope;

    size_t n_bytes = sql_in.length() * 2;
    sqlite3_stmt * sth = 0;
    js_char16_t * tail = 0; // uncompiled part of the sql (when multiple stmts)
    
    if (sqlite3_prepare16_v2(db, sql_in.data(), n_bytes, &sth, (const void**)&tail) != SQLITE_OK)
    {
        raise_sqlite_error(db);
    }

    object cursor = create<sqlite3_cursor>(fusion::make_vector(sth));

    string tail_str;
    if (tail) {
        tail_str = string(tail);
    }
    
    string sql = sql_in.substr( 0, sql_in.size() - tail_str.size() );

    cursor.define_property("sql", sql);
    cursor.define_property("tail", tail_str);        

    if ( !bind.is_undefined_or_null() ) {
        cursor.call("bind", bind );
    }
    
    return cursor;
}
开发者ID:Flusspferd,项目名称:flusspferd,代码行数:30,代码来源:sqlite.cpp


示例3: switch

  value value::multiply(const value& that) const
  {
    if (that.is(m_type))
    {
      switch (m_type)
      {
        case type::number:
          return multiply_number(*m_value_number, *that.m_value_number);

        case type::vector:
          return multiply_vector(*m_value_vector, *that.m_value_vector);

        default:
          break;
      }
    }

    throw error(
      error::type::type,
      U"Cannot multiply " +
      type_description(that.m_type) +
      U" with " +
      type_description(m_type)
    );
  }
开发者ID:peelonet,项目名称:laskin,代码行数:25,代码来源:multiply.cpp


示例4: coerce

/// Like coerce(const value&) but assigns the value to a reference
/// instead of returning it.  May be more efficient for complex values
/// (arrays, maps, etc.)
///
/// @related proton::value
template<class T> void coerce(const value& v, T& x) {
    codec::decoder d(v, false);
    if (type_id_is_scalar(v.type())) {
        scalar s;
        d >> s;
        x = internal::coerce<T>(s);
    } else {
开发者ID:irinabov,项目名称:debian-qpid-proton,代码行数:12,代码来源:value.hpp


示例5: raw_open

object fs_base::raw_open(char const* name, value mode, value perms) {
  // TODO: Deal with permissions somewhere :)
  if (!perms.is_undefined_or_null())
    throw exception("rawOpen: permissions not yet supported");

  return create_native_object<io::file>(object(), name, mode);
}
开发者ID:,项目名称:,代码行数:7,代码来源:


示例6: get_version

 unsigned get_version(quickbook::state& state, bool using_docinfo,
         value version)
 {
     unsigned result = 0;
 
     if (!version.empty()) {
         value_consumer version_values(version);
         bool before_docinfo = version_values.optional_consume(
             doc_info_tags::before_docinfo).check();
         int major_verison = version_values.consume().get_int();
         int minor_verison = version_values.consume().get_int();
         version_values.finish();
 
         if (before_docinfo || using_docinfo) {
             result = ((unsigned) major_verison * 100) +
                 (unsigned) minor_verison;
         
             if(result < 100 || result > 107)
             {
                 detail::outerr(state.current_file->path)
                     << "Unknown version: "
                     << major_verison
                     << "."
                     << minor_verison
                     << std::endl;
                 ++state.error_count;
             }
         }
     }
     
     return result;
 }
开发者ID:CytoComp,项目名称:ethereum-ObjectiveC,代码行数:32,代码来源:doc_info_actions.cpp


示例7: run

// ==========================================================================
// METHOD IconRequestHandler::run
// ==========================================================================
int IconRequestHandler::run (string &uri, string &postbody, value &inhdr,
							 string &out, value &outhdr, value &env,
							 tcpsocket &s)
{
	bool isdown = (uri.strstr ("/down/") >= 0);
	string uuid = uri.copyafterlast ("/");
	uuid.cropat ('.');
	
	app->log (log::debug, "httpicon", "Request for <%s>" %format (uuid));
	
	if (inhdr.exists ("If-Modified-Since"))
	{
		s.puts ("HTTP/1.1 304 NOT CHANGED\r\n"
				"Connection: %s\r\n"
				"Content-length: 0\r\n\r\n"
				%format (env["keepalive"].bval() ? "keep-alive" : "close"));
		
		env["sentbytes"] = 0;
		return -304;
	}
	
	if (! app->mdb->classExistsUUID (uuid))
	{
		string orgpath;
		
		if (isdown)
		{
			orgpath = "/var/openpanel/http/images/icons/down_%s.png" %format (uuid);
		}
		else
		{
			orgpath = "/var/openpanel/http/images/icons/%s.png" %format (uuid);
		}
		if (fs.exists (orgpath))
		{
			out = fs.load (orgpath);
			outhdr["Content-type"] = "image/png";
			return 200;
		}
		return 404;
	}
	CoreClass &c = app->mdb->getClassUUID (uuid);
	string path;
	if (isdown)
	{
		path = "%s/down_%s" %format (c.module.path, c.icon);
	}
	else
	{
		path = "%s/%s" %format (c.module.path, c.icon);
	}
	
	app->log (log::debug, "httpicon", "Loading %s" %format (path));
	
	if (! fs.exists (path)) return 404;
	
	outhdr["Content-type"] = "image/png";
	out = fs.load (path);
	return 200;
}
开发者ID:CloudVPS,项目名称:openpanel-opencore,代码行数:63,代码来源:rpcrequesthandler.cpp


示例8: domain_error

BigInt::reference BigInt::operator/= ( value o )
{
    if ( o == zero )
        throw std::domain_error ( "Division by zero" );

    bool rsign = false;

    if ( sign_ )
    {
        abs();
        rsign = true;
    }
    if ( o.sign_ )
    {
        o.abs();
        rsign = !rsign;
    }

    BigInt q = zero;
    while ( *this >= 0 )
    {
        operator-= ( o );
        ++q;
    }
    // now, *this + o = r
    --q;

    buffer= q.buffer;
    sign_ = rsign;

    return normalize();
}
开发者ID:masimun,项目名称:AMFBach,代码行数:32,代码来源:BigInt.cpp


示例9:

void LLCCEP::IRGenerator::insertTop(value out)
{
	IR_GENERATOR_OK;

	::std::fprintf(output, "top %s\n", out.getMnemonic().c_str());

	IR_GENERATOR_OK;
}
开发者ID:Andrew-Bezzubtsev,项目名称:LLCCEP,代码行数:8,代码来源:IR.cpp


示例10: can_convert_from

 static bool can_convert_from(const value& val) {
     if (val.type() != value_type::vector_type) {
         return false;
     }
     const auto& vec = val.get<value_vector_type>();
     return vec.size() == sizeof...(T)
         && tuple_value_converter<T...>::types_match(vec, 0);
 }
开发者ID:respu,项目名称:lightconf,代码行数:8,代码来源:value_type_info.hpp


示例11: switch_

 switch_instruction switch_(value const & cond, label const & default_)
 {
   llvm::IRBuilder<> & bldr = current_builder();
   llvm::SwitchInst * rv = SPRITE_APICALL(
       bldr.CreateSwitch(cond.ptr(), default_.ptr())
     );
   return switch_instruction(rv);
 }
开发者ID:andyjost,项目名称:Sprite-3,代码行数:8,代码来源:operations.cpp


示例12: get_byte

static int get_byte(value byte_) {
  int byte;
  if (byte_.is_int()) {
    byte = byte_.get_int();
    if (byte < 0 || byte > 255)
      throw exception("Byte is outside the valid range for bytes");
    return byte;
  }
  object byte_o = byte_.to_object();
  if (byte_o.is_null())
    throw exception("Not a valid byte");
  binary &byte_bin = flusspferd::get_native<binary>(byte_o);
  if (byte_bin.get_length() != 1)
    throw exception("Byte must not be a non single-element Binary");
  byte = byte_bin.get_const_data()[0];
  return byte;
}
开发者ID:Flusspferd,项目名称:flusspferd,代码行数:17,代码来源:binary.cpp


示例13: parse

object base_parser::parse(value source) {
  if (source.is_object()) {
    object o = source.get_object();

    if (is_native<io::stream>(o)) {
      io::stream &s = flusspferd::get_native<io::stream>(o);

      // TODO: Work out if the stream is readable or not!
      std::ifstream stream;
      dynamic_cast<std::ios&>(stream).rdbuf( s.streambuf() );
      sax_source is;
      is.setByteStream(stream);
      return parse_source(is);
    }
    /*else if (is_native<binary>(o)) {
      // Couldn't get this working. Compile errors
      binary &b = flusspferd::get_native<flusspferd::binary>(o);

      call_context c;
      c.arg.push_back(b);
      create<io::binary_stream>(c);
      root_object s(b_s);

      std::ifstream stream;
      dynamic_cast<std::ios&>(stream).rdbuf( b_s.streambuf() );
      sax_source is;
      is.setByteStream(stream);
      return parse_source(is);
    }*/
  }

  std::string str = source.to_std_string();

  security &sec = security::get();
  if (!sec.check_path(str, security::READ)) {
    throw exception(
      format("xml.Parser#parse: could not open file: 'denied by security' (%s)")
             % str
    );
  }

  sax_source is;
  is.setSystemId(str);

  return parse_source(is);
}
开发者ID:Flusspferd,项目名称:flusspferd,代码行数:46,代码来源:parser.cpp


示例14: traverse

void traverse(const value&                                           tree,
              const std::function<void (const path&, const value&)>& func,
              const path&                                            base_path,
              bool                                                   leafs_only
             )
{
    if (!leafs_only || tree.empty() || (tree.kind() != kind::array && tree.kind() != kind::object))
        func(base_path, tree);
    
    if (tree.kind() == kind::object)
    {
        for (const auto& field : tree.as_object())
        {
            traverse(field.second,
                     func,
                     base_path + field.first,
                     leafs_only
                    );
        }
    }
    else if (tree.kind() == kind::array)
    {
        for (value::size_type idx = 0; idx < tree.size(); ++idx)
            traverse(tree[idx],
                     func,
                     base_path + idx,
                     leafs_only
                    );
    }
}
开发者ID:poseidon1214,项目名称:vanilla-rtb,代码行数:30,代码来源:algorithm_traverse.cpp


示例15: print

void print(value &v){
    stringstream ss;
    v.serialize(ss);
    string str;
    getline(ss, str);
    for(int i = 0 ; i < (int)str.size() ; i++)
        cout << setw(2) << setfill('0') << hex << (((int)str[i])&255) << ' ';
    cout << endl;
}
开发者ID:Microsheep,项目名称:Opencv_photo_background_removal,代码行数:9,代码来源:main.cpp


示例16: property_op

void named_node_map::property_op(property_mode mode, value const &id, value &x) {
  int index;
  if (id.is_int()) {
    index = id.get_int();
  } else {
    this->native_object_base::property_op(mode, id, x);
    return;
  }

  if (index < 0 || std::size_t(index) >= impl_.getLength())
    throw exception("Out of bounds on NamedNodeMap", "RangeError");

  switch (mode) {
  case property_get:
    x = item(index);
  default: break;
  };
}
开发者ID:Flusspferd,项目名称:flusspferd,代码行数:18,代码来源:named_node_map.cpp


示例17: toValue

void ValueObjectStreamOut::toValue(value &v)
{
   int offset = (int)&data[0];
   int len = data.size();

   value::global("Module").call<void>("unrealize", v, offset, len, value::null() );
   if (count)
      v.set("handles", handleArray);
}
开发者ID:madrazo,项目名称:nme,代码行数:9,代码来源:JsPrime.cpp


示例18: get

	static PostingJoinOperatorConfiguration get( value const &v )
	{
		PostingJoinOperatorConfiguration c;
		if( v.type( ) != is_object ) {
			throw bad_value_cast( );
		}		
		c.name = v.get<std::string>( "name" );
		c.description = v.get<std::string>( "description" );
		return c;
	}
开发者ID:Eurospider,项目名称:strusWebService,代码行数:10,代码来源:other.hpp


示例19: delete_property

void object::delete_property(value const &id) {
  if (is_null())
    throw exception("Could not delete property (object is null)");
  local_root_scope scope;
  string name = id.to_string();
  jsval dummy;
  if (!JS_DeleteUCProperty2(Impl::current_context(), get(),
                            (jschar*)name.data(), name.length(), &dummy))
    throw exception("Could not delete property");
}
开发者ID:mmason930,项目名称:kinslayer-mud,代码行数:10,代码来源:object.cpp


示例20: get

	static MetadataDefiniton get( value const &v )
	{
		MetadataDefiniton m;
		if( v.type( ) != is_object) {
			throw bad_value_cast( );
		}
		m.name = v.get<std::string>( "name" );
		m.type = v.get<std::string>( "type" );
		return m;
	}
开发者ID:Eurospider,项目名称:strusWebService,代码行数:10,代码来源:index.hpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ value_type类代码示例发布时间:2022-05-31
下一篇:
C++ valtype类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap