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

C++ pushValue函数代码示例

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

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



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

示例1: switch

void 
StyledStreamWriter::writeValue( const Value &value )
{
   switch ( value.type() )
   {
   case nullValue:
      pushValue( "null" );
      break;
   case intValue:
      pushValue( valueToString( value.asInt() ) );
      break;
   case uintValue:
      pushValue( valueToString( value.asUInt() ) );
      break;
   case realValue:
      pushValue( valueToString( value.asDouble() ) );
      break;
   case stringValue:
      pushValue( valueToQuotedString( value.asCString() ) );
      break;
   case booleanValue:
      pushValue( valueToString( value.asBool() ) );
      break;
   case arrayValue:
      writeArrayValue( value);
      break;
   case objectValue:
      {
         Value::Members members( value.getMemberNames() );
         if ( members.empty() )
            pushValue( "{}" );
         else
         {
            writeWithIndent( "{" );
            indent();
            Value::Members::iterator it = members.begin();
            while ( true )
            {
               const std::string &name = *it;
               const Value &childValue = value[name];
               writeCommentBeforeValue( childValue );
               writeWithIndent( valueToQuotedString( name.c_str() ) );
               *document_ << " : ";
               writeValue( childValue );
               if ( ++it == members.end() )
               {
                  writeCommentAfterValueOnSameLine( childValue );
                  break;
               }
               *document_ << ",";
               writeCommentAfterValueOnSameLine( childValue );
            }
            unindent();
            writeWithIndent( "}" );
         }
      }
      break;
   }
}
开发者ID:Epidilius,项目名称:PhysicsHackAndSlash,代码行数:59,代码来源:json_writer.cpp


示例2: pushValue

void
StyledStreamWriter::writeArrayValue ( const Value& value )
{
    unsigned size = value.size ();

    if ( size == 0 )
        pushValue ( "[]" );
    else
    {
        bool isArrayMultiLine = isMultineArray ( value );

        if ( isArrayMultiLine )
        {
            writeWithIndent ( "[" );
            indent ();
            bool hasChildValue = !childValues_.empty ();
            unsigned index = 0;

            while ( true )
            {
                const Value& childValue = value[index];

                if ( hasChildValue )
                    writeWithIndent ( childValues_[index] );
                else
                {
                    writeIndent ();
                    writeValue ( childValue );
                }

                if ( ++index == size )
                    break;

                *document_ << ",";
            }

            unindent ();
            writeWithIndent ( "]" );
        }
        else // output on a single line
        {
            assert ( childValues_.size () == size );
            *document_ << "[ ";

            for ( unsigned index = 0; index < size; ++index )
            {
                if ( index > 0 )
                    *document_ << ", ";

                *document_ << childValues_[index];
            }

            *document_ << " ]";
        }
    }
}
开发者ID:CFQuantum,项目名称:CFQuantumd,代码行数:56,代码来源:json_writer.cpp


示例3: draw

void draw()
{
  background(0);
  drawGrid();
  val = getValue();
  if (val != -1) {
    pushValue(val);
  }
  drawLines();
}
开发者ID:AndyFiore,项目名称:Random-Nerd-Tutorials,代码行数:10,代码来源:Arduino_Poor_mans_oscilloscope_processing_code.c


示例4: VALIDATE

bool VariableRef::readUInt32( uint32& out ) const
{
    VALIDATE();

    pushValue();
    out = (uint32)lua_tonumber(m_ownerContext->getPimpl()->L, -1);
    popValue();

    return true;
}
开发者ID:KamilLelonek,项目名称:frail_pwr,代码行数:10,代码来源:LuaSimpleBinding.cpp


示例5: setupListener

        //// Listener settings ////
        void setupListener()
        {
            auto listener_node = *m_dev->emplace(m_dev->children().cend(), "listener");

            auto listener_pos_node = *listener_node->emplace(listener_node->children().cend(), "pos");

            add_position(listener_pos_node,
                         make_parameter(
                             [&] () { return m_scene.listener().Position(); },
                             [&] (const auto& elt) { m_scene.listener().Position(elt); }));

            auto listener_orient_node = *listener_node->emplace(listener_node->children().cend(), "orientation");
            auto listener_orient_addr = listener_orient_node->createAddress(OSSIA::Value::Type::TUPLE); // [ at_x at_y at_z up_x at_y at_z ]

            auto tupl = new OSSIA::Tuple;

            const auto& orient = m_scene.listener().Orientation();
            tupl->value.push_back(new OSSIA::Float(orient.At()[0]));
            tupl->value.push_back(new OSSIA::Float(orient.At()[1]));
            tupl->value.push_back(new OSSIA::Float(orient.At()[2]));
            tupl->value.push_back(new OSSIA::Float(orient.Up()[0]));
            tupl->value.push_back(new OSSIA::Float(orient.Up()[1]));
            tupl->value.push_back(new OSSIA::Float(orient.Up()[2]));
            listener_orient_addr->pushValue(tupl);

            listener_orient_addr->addCallback([&] (const OSSIA::Value* val) {
                auto tpl = dynamic_cast<const OSSIA::Tuple*>(val);
                if(tpl->value.size() != 6)
                    return;

                auto at_x = dynamic_cast<const OSSIA::Float*>(tpl->value[0]);
                auto at_y = dynamic_cast<const OSSIA::Float*>(tpl->value[1]);
                auto at_z = dynamic_cast<const OSSIA::Float*>(tpl->value[2]);
                auto up_x = dynamic_cast<const OSSIA::Float*>(tpl->value[3]);
                auto up_y = dynamic_cast<const OSSIA::Float*>(tpl->value[4]);
                auto up_z = dynamic_cast<const OSSIA::Float*>(tpl->value[5]);
                if(!at_x || !at_y || !at_z || !up_x || !up_y || !up_z)
                    return;

                m_scene.listener().Orientation(at_x->value, at_y->value, at_z->value, up_x->value, up_y->value, up_z->value);
            });

            auto listener_orient_at_node = *listener_orient_node->emplace(listener_orient_node->children().cend(), "at");
            add_position(listener_orient_at_node,
                         make_parameter(
                             [&] () { return m_scene.listener().OrientationAt(); },
                             [&] (const auto& elt) { m_scene.listener().Orientation(elt, m_scene.listener().OrientationUp()); }
            ));
            auto listener_orient_up_node = *listener_orient_node->emplace(listener_orient_node->children().cend(), "up");
            add_position(listener_orient_up_node,
                         make_parameter(
                             [&] () { return m_scene.listener().OrientationUp(); },
                             [&] (const auto& elt) { m_scene.listener().Orientation(m_scene.listener().OrientationAt(), elt); }
            ));
        }
开发者ID:jcelerier,项目名称:qt-openal-demo,代码行数:56,代码来源:main.cpp


示例6: luaopen_input

        int luaopen_input(lua_State* L)
        {
            luaL_register(L, "input", inputlib_f);

            // event table
            lua_pushstring(L, "event");

            lua_newtable(L);

            lua_pushstring(L, "key");
            pushValue(L, W_INPUT.KeyEvent);
            lua_settable(L, -3);

            lua_pushstring(L, "mouseButton");
            pushValue(L, W_INPUT.MouseButtonEvent);
            lua_settable(L, -3);

            lua_pushstring(L, "cursorPos");
            pushValue(L, W_INPUT.CursorPositionEvent);
            lua_settable(L, -3);

            lua_settable(L, -3);
            // end event table

            lua_pushstring(L, "action");
            push_action_constants(L);
            lua_settable(L, -3);

            lua_pushstring(L, "key");
            push_keyboard_constants(L);
            lua_settable(L, -3);

            lua_pushstring(L, "mouse");
            push_mouse_constants(L);
            lua_settable(L, -3);

            lua_pushstring(L, "cursorMode");
            push_cursor_mode_constants(L);
            lua_settable(L, -3);

            return 1;
        }
开发者ID:redxdev,项目名称:Wake,代码行数:42,代码来源:luainput.cpp


示例7: pushValue

		int pushValue(lua_State* state, const std::vector<T>& vec)
		{
			lua_createtable(state, vec.size(), 0);

			for(std::size_t i = 0; i < vec.size(); i++)
			{
				pushValue(state, vec[i]);
				lua_rawseti(state, -2, i + 1);
			}

			return 1;
		}
开发者ID:dabbertorres,项目名称:Swift2,代码行数:12,代码来源:Details.hpp


示例8: pushArray

//------------------------------------------------------------------------------
void SN_API pushArray(HSQUIRRELVM vm, const Variant::Array & a)
{
	sq_newarray(vm, a.size());
	for (size_t i = 0; i < a.size(); ++i)
	{
		sq_pushinteger(vm, i);
		pushValue(vm, a[i]);
		if (SQ_FAILED(sq_set(vm, -3)))
		{
			SN_WARNING("Variant => Squirrel: failed to set array index " << i);
		}
	}
}
开发者ID:Zylann,项目名称:SnowfeetEngine,代码行数:14,代码来源:variant_squirrel.cpp


示例9: pushValue

void 
StyledWriter::writeArrayValue( const Value &value )
{
   unsigned size = value.size();
   if ( size == 0 )
      pushValue( "[]" );
   else
   {
      bool isArrayMultiLine = isMultineArray( value );
      if ( isArrayMultiLine )
      {
         writeWithIndent( "[" );
         indent();
         bool hasChildValue = !childValues_.empty();
         unsigned index =0;
         for (;;)
         {
            const Value &childValue = value[index];
            writeCommentBeforeValue( childValue );
            if ( hasChildValue )
               writeWithIndent( childValues_[index] );
            else
            {
               writeIndent();
               writeValue( childValue );
            }
            if ( ++index == size )
            {
               writeCommentAfterValueOnSameLine( childValue );
               break;
            }
            document_ += ",";
            writeCommentAfterValueOnSameLine( childValue );
         }
         unindent();
         writeWithIndent( "]" );
      }
      else // output on a single line
      {
         assert( childValues_.size() == size );
         document_ += "[ ";
         for ( unsigned index =0; index < size; ++index )
         {
            if ( index > 0 )
               document_ += ", ";
            document_ += childValues_[index];
         }
         document_ += " ]";
      }
   }
}
开发者ID:vateran,项目名称:todengine,代码行数:51,代码来源:json_writer.cpp


示例10: s_implementation

static void s_implementation(gnative_Object *obj, gnative_Function *function, gnative_Value *parameters)
{
	if (L == NULL)
		return;

	gnative_Class *cls = gnative_ObjectGetClass(obj);
	
	lua_pushlightuserdata(L, &keyClasses);
	lua_gettable(L, LUA_REGISTRYINDEX);
	
	lua_pushlightuserdata(L, cls);
	lua_gettable(L, -2);
	
	lua_remove(L, -2);

	lua_pushstring(L, "__functions");
	lua_rawget(L, -2);

	lua_pushlightuserdata(L, function);
	lua_gettable(L, -2);
	
	gnative_Value v;
	v.obj = obj;
	pushValue(L, v, GNATIVE_TYPE_OBJECT, false);

	int parameterCount = gnative_FunctionGetParameterCount(function);
	
	gnative_Type *parameterTypes = gnative_FunctionGetParameterTypes(function);

	for (int i = 0; i < parameterCount; ++i)
		pushValue(L, parameters[i], parameterTypes[i], false);

	lua_call(L, 1 + parameterCount, 0);
	
	lua_pop(L, 2);
}
开发者ID:Nlcke,项目名称:gideros,代码行数:36,代码来源:nativebinder.cpp


示例11: switch

void BuiltStyledStreamWriter::writeValue(Value const& value) {
  switch (value.type()) {
  case nullValue:
    pushValue(nullSymbol_);
    break;
  case intValue:
    pushValue(valueToString(value.asLargestInt()));
    break;
  case uintValue:
    pushValue(valueToString(value.asLargestUInt()));
    break;
  case realValue:
    pushValue(valueToString(value.asDouble()));
    break;
  case stringValue:
    pushValue(valueToQuotedString(value.asCString()));
    break;
  case booleanValue:
    pushValue(valueToString(value.asBool()));
    break;
  case arrayValue:
    writeArrayValue(value);
    break;
  case objectValue: {
    Value::Members members(value.getMemberNames());
    if (members.empty())
      pushValue("{}");
    else {
      writeWithIndent("{");
      indent();
      Value::Members::iterator it = members.begin();
      for (;;) {
        std::string const& name = *it;
        Value const& childValue = value[name];
        writeCommentBeforeValue(childValue);
        writeWithIndent(valueToQuotedString(name.c_str()));
        sout_ << colonSymbol_;
        writeValue(childValue);
        if (++it == members.end()) {
          writeCommentAfterValueOnSameLine(childValue);
          break;
        }
        sout_ << ",";
        writeCommentAfterValueOnSameLine(childValue);
      }
      unindent();
      writeWithIndent("}");
    }
  } break;
  }
}
开发者ID:robsonswiss,项目名称:OSVR-user-settings,代码行数:51,代码来源:json_writer.cpp


示例12: pushKey

    void LuaModule::pushJsonScalarValue(const Json::Value &key,
                                        const Json::Value &val, lua_State * stack) {
        if (val.isObject() || val.isArray()) {
            throw std::runtime_error("Not a scalar value");
        }

        if (key.isString()) {
            pushKey(key, stack);
        }
        pushValue(val, stack);
        if (key.isNumeric()) {
            lua_rawseti(stack, -2, key.asInt() + 1);
        } else if (key.isString()) {
            lua_settable(stack, -3);
        }
    }
开发者ID:achernakov,项目名称:flugegeheimen,代码行数:16,代码来源:LuaModule.cpp


示例13: pushValue

void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
  unsigned size = value.size();
  if (size == 0)
    pushValue("[]");
  else {
    bool isMultiLine = (cs_ == CommentStyle::All) || isMultineArray(value);
    if (isMultiLine) {
      writeWithIndent("[");
      indent();
      bool hasChildValue = !childValues_.empty();
      unsigned index = 0;
      for (;;) {
        Value const& childValue = value[index];
        writeCommentBeforeValue(childValue);
        if (hasChildValue)
          writeWithIndent(childValues_[index]);
        else {
          if (!indented_) writeIndent();
          indented_ = true;
          writeValue(childValue);
          indented_ = false;
        }
        if (++index == size) {
          writeCommentAfterValueOnSameLine(childValue);
          break;
        }
        sout_ << ",";
        writeCommentAfterValueOnSameLine(childValue);
      }
      unindent();
      writeWithIndent("]");
    } else // output on a single line
    {
      assert(childValues_.size() == size);
      sout_ << "[";
      if (!indentation_.empty()) sout_ << " ";
      for (unsigned index = 0; index < size; ++index) {
        if (index > 0)
          sout_ << ", ";
        sout_ << childValues_[index];
      }
      if (!indentation_.empty()) sout_ << " ";
      sout_ << "]";
    }
  }
}
开发者ID:robsonswiss,项目名称:OSVR-user-settings,代码行数:46,代码来源:json_writer.cpp


示例14: pushGlobalVariable

void Lua::callFunction(const char* name, const std::vector<Data>& args, std::vector<Data>* result) {
	pushGlobalVariable(name);
	for (const auto& arg: args) {
		pushValue(arg);
	}

	std::size_t numReturn = result ? result->size() : 0;
	handleError(lua_pcall(handle, args.size(), numReturn, 0));

	if (result) {
		std::size_t stackSize = lua_gettop(handle);
		assert(stackSize >= numReturn);

		for (std::size_t i = 0; i < numReturn; ++i) {
			(*result)[i] = getValue(stackSize - numReturn + i + 1);
		}

		pop(numReturn);
	}
}
开发者ID:dtbinh,项目名称:car-game,代码行数:20,代码来源:Lua.cpp


示例15: pushTable

//------------------------------------------------------------------------------
void SN_API pushTable(HSQUIRRELVM vm, const Variant::Dictionary & d)
{
	sq_newtable(vm);
	for (auto it = d.begin(); it != d.end(); ++it)
	{
		// Push key
		const std::string & key = it->first;
		sq_pushstring(vm, key.c_str(), key.size());

		// Push value
		const Variant & value = it->second;
		pushValue(vm, value);

		// Set or create
		if (SQ_FAILED(sq_newslot(vm, -3, SQFalse)))
		{
			SN_WARNING("Variant => Squirrel: failed to set key " << key);
		}
	}
}
开发者ID:Zylann,项目名称:SnowfeetEngine,代码行数:21,代码来源:variant_squirrel.cpp


示例16: assert

void LuaInterface::clearTable(int index)
{
    assert(hasIndex(index) && isTable(index));
    pushNil(); // table, nil
    bool stop = false;
    while(next(index-1)) { // table, key, value
        pop(); // table, key
        pushValue(); // table, key, key
        if(next(index-2)) { // table, key, nextkey, value
            pop(); // table, key, nextkey
            insert(-2); // table, nextkey, key
            pushNil(); // table, nextkey, key, nil
            rawSet(index-3); // table, nextkey
        } else { // table, key
            pushNil(); // table, key, nil
            rawSet(index-2); // table
            break;
        }
    }
}
开发者ID:Ablankzin,项目名称:otclient,代码行数:20,代码来源:luainterface.cpp


示例17: pushValue

void Feature::updateWithValue(double value, bool computeStats, int numFrames)
{
	if (std::isnan(value) || std::isinf(value))
		value = 0.0;

	pushValue(value);
	if (computeStats)
	{
		m_accLtf(value);

		m_accStf = doubleAcc();
		for (int idx = 0; idx < std::min<int>(numFrames, m_history.size()); idx++)
		{
			m_accStf(m_history[idx]);
		}

		m_means.push_back(acc::mean(m_accStf));
		m_stds.push_back(sqrt(acc::variance(m_accStf)));
	}
}
开发者ID:cadet,项目名称:estia,代码行数:20,代码来源:Feature.cpp


示例18: add_position

void add_position(std::shared_ptr<OSSIA::Node> node, Parameter_t&& param)
{
    static auto modify_i = [=] (int i) {
        return [=] (const OSSIA::Value* val) {
            auto float_val = dynamic_cast<const OSSIA::Float*>(val);
            if(!float_val)
                return;

            auto elt = param.get();
            elt[i] = float_val->value;
            param.set(elt);
        };
    };

    auto addr = node->createAddress(OSSIA::Value::Type::TUPLE); // [ x y z ]
    auto tupl = new OSSIA::Tuple;
    tupl->value.push_back(new OSSIA::Float(param.get()[0]));
    tupl->value.push_back(new OSSIA::Float(param.get()[1]));
    tupl->value.push_back(new OSSIA::Float(param.get()[2]));
    addr->pushValue(tupl);

    addr->addCallback([=] (const OSSIA::Value* val) {
        auto tpl = dynamic_cast<const OSSIA::Tuple*>(val);
        if(tpl->value.size() != 3)
            return;

        auto x = dynamic_cast<const OSSIA::Float*>(tpl->value[0]);
        auto y = dynamic_cast<const OSSIA::Float*>(tpl->value[1]);
        auto z = dynamic_cast<const OSSIA::Float*>(tpl->value[2]);
        if(!x || !y || !z)
            return;

        param.set(oalplus::Vec3f{x->value, y->value, z->value});
    });

    add_float_child(node, "x", modify_i(0));
    add_float_child(node, "y", modify_i(1));
    add_float_child(node, "z", modify_i(2));
}
开发者ID:jcelerier,项目名称:qt-openal-demo,代码行数:39,代码来源:main.cpp


示例19: applyProperties

//------------------------------------------------------------------------------
void applyProperties(HSQUIRRELVM vm, const Variant::Dictionary & o, SQInteger objectIndex)
{
	if (objectIndex < 0)
		objectIndex -= 2; // Key + value stack offset

	for (auto it = o.begin(); it != o.end(); ++it)
	{
		// Push key
		const std::string & key = it->first;
		sq_pushstring(vm, key.c_str(), key.size());

		// Push value
		// TODO If the value is a table, go recursively instead of overwriting the previous value
		const Variant & value = it->second;
		pushValue(vm, value);

		// Set
		if (SQ_FAILED(sq_set(vm, objectIndex)))
		{
			SN_WARNING("Variant => Squirrel: failed to set key " << key);
		}
	}
}
开发者ID:Zylann,项目名称:SnowfeetEngine,代码行数:24,代码来源:variant_squirrel.cpp


示例20: sizeof

void EntityTemplateInterpreter::readInt64(std::vector<char>& code, int& i) {
    int64_t *val = reinterpret_cast<int64_t*>(&code[i]);
    i += sizeof(int64_t);
    pushValue(val);
}
开发者ID:EmeraldGit,项目名称:elias_broschin_tup,代码行数:5,代码来源:EntityTemplateInterpreter.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ push_array函数代码示例发布时间:2022-05-30
下一篇:
C++ pushState函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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