本文整理汇总了C++中ParamMap类的典型用法代码示例。如果您正苦于以下问题:C++ ParamMap类的具体用法?C++ ParamMap怎么用?C++ ParamMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParamMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitParamMap
bool LuaFeatureDefs::IsDefaultParam(const string& word)
{
if (paramMap.empty()) {
InitParamMap();
}
return (paramMap.find(word) != paramMap.end());
}
示例2: QString
void TwqUser::RA_Prop::doIt(User& u) const {
UserID uid = u.getID();
// 実際にTwitterAPIで問い合わせ
ParamMap pm;
pm.insert(TWAPIKWD::US_LOOKUP::UserId, QString("%1").arg(uid));
sgNet.restAPI(sgUser.GetCB<TwqUser::P_Prop>(uid), TWAPI::US_LOOKUP, pm, QString(), uid);
}
示例3: LINFO
// ##############################################################
void ModelManager::saveConfig(const string& fname) const
{
LINFO("Saving configuration to '%s'", fname.c_str());
ParamMap pmap;
this->writeParamsTo(pmap);
pmap.format(fname);
}
示例4: FeatureDefNewIndex
static int FeatureDefNewIndex(lua_State* L)
{
// not a default value, set it
if (!lua_isstring(L, 2)) {
lua_rawset(L, 1);
return 0;
}
const char* name = lua_tostring(L, 2);
ParamMap::const_iterator it = paramMap.find(name);
// not a default value, set it
if (it == paramMap.end()) {
lua_rawset(L, 1);
return 0;
}
const void* userData = lua_touserdata(L, lua_upvalueindex(1));
const FeatureDef* fd = (const FeatureDef*)userData;
// write-protected
if (!gs->editDefsEnabled) {
luaL_error(L, "Attempt to write FeatureDefs[%d].%s", fd->id, name);
return 0;
}
// Definition editing
const DataElement& elem = it->second;
const char* p = ((const char*)fd) + elem.offset;
switch (elem.type) {
case FUNCTION_TYPE:
case READONLY_TYPE: {
luaL_error(L, "Can not write to %s", name);
return 0;
}
case INT_TYPE: {
*((int*)p) = lua_toint(L, -1);
return 0;
}
case BOOL_TYPE: {
*((bool*)p) = lua_toboolean(L, -1);
return 0;
}
case FLOAT_TYPE: {
*((float*)p) = lua_tofloat(L, -1);
return 0;
}
case STRING_TYPE: {
*((string*)p) = lua_tostring(L, -1);
return 0;
}
case ERROR_TYPE:{
luaL_error(L, "ERROR_TYPE in FeatureDefs __newindex");
}
}
return 0;
}
示例5: UnitDefIndex
static int UnitDefIndex(lua_State* L)
{
// not a default value
if (!lua_isstring(L, 2)) {
lua_rawget(L, 1);
return 1;
}
const char* name = lua_tostring(L, 2);
ParamMap::const_iterator it = paramMap.find(name);
// not a default value
if (it == paramMap.end()) {
lua_rawget(L, 1);
return 1;
}
const void* userData = lua_touserdata(L, lua_upvalueindex(1));
const UnitDef* ud = static_cast<const UnitDef*>(userData);
const DataElement& elem = it->second;
const char* p = ((const char*)ud) + elem.offset;
switch (elem.type) {
case READONLY_TYPE: {
lua_rawget(L, 1);
return 1;
}
case INT_TYPE: {
lua_pushnumber(L, *((int*)p));
return 1;
}
case BOOL_TYPE: {
lua_pushboolean(L, *((bool*)p));
return 1;
}
case FLOAT_TYPE: {
lua_pushnumber(L, *((float*)p));
return 1;
}
case STRING_TYPE: {
lua_pushsstring(L, *((string*)p));
return 1;
}
case FUNCTION_TYPE: {
return elem.func(L, p);
}
case ERROR_TYPE: {
LOG_L(L_ERROR, "[%s] ERROR_TYPE for key \"%s\" in UnitDefs __index", __FUNCTION__, name);
lua_pushnil(L);
return 1;
}
}
return 0;
}
示例6: FeatureDefIndex
static int FeatureDefIndex(lua_State* L)
{
// not a default value
if (!lua_isstring(L, 2)) {
lua_rawget(L, 1);
return 1;
}
const char* name = lua_tostring(L, 2);
ParamMap::const_iterator it = paramMap.find(name);
// not a default value
if (it == paramMap.end()) {
lua_rawget(L, 1);
return 1;
}
const void* userData = lua_touserdata(L, lua_upvalueindex(1));
const FeatureDef* fd = (const FeatureDef*)userData;
const DataElement& elem = it->second;
const char* p = ((const char*)fd) + elem.offset;
switch (elem.type) {
case READONLY_TYPE: {
lua_rawget(L, 1);
return 1;
}
case INT_TYPE: {
lua_pushnumber(L, *((int*)p));
return 1;
}
case BOOL_TYPE: {
lua_pushboolean(L, *((bool*)p));
return 1;
}
case FLOAT_TYPE: {
lua_pushnumber(L, *((float*)p));
return 1;
}
case STRING_TYPE: {
lua_pushsstring(L, *((string*)p));
return 1;
}
case FUNCTION_TYPE: {
return elem.func(L, p);
}
case ERROR_TYPE:{
luaL_error(L, "ERROR_TYPE in FeatureDefs __index");
}
}
return 0;
}
示例7: paramTest
void paramTest(){
const char* url = "http://show.mtty.com/v?p=VwsimgAO6MJ7jEpgW5IA8rszDyLuC4qNGtNxzw&a=0086-ffff-ffff&b=50&c=2546&d=9&e=288&r=3e581c094cf01851&s=9223372032561888060&x=6&tm=1460347546&l=http://click.bes.baidu.com/adx.php?c=cz00NGY1OWJmMDA0MGEzMzFmAHQ9MTQ2MDM0NzU0NgBzZT0xAGJ1PTE4NzA0OTA3AHR1PTkyMjMzNzIwMzI1NjE4ODgwNjAAYWQ9MTQ1ODExOTUyMDUyMDI1NDYAc2l0ZT1odHRwOi8vd3d3Ljh2djguY29tL25ld3MvNzdfMTQuaHRtbAB2PTEAaT05ZDFlOWFjMA&k=dz0zMzYAaD0yODAAY3NpZD0xMjAyNTkwODQzMjE2AHRtPTI2OTA0Njk4NQB0ZD0yMDc5NTQ4AHdpPTE4NzA0OTA3AGZuPTMwMDE0MDg4X2NwcgBmYW49AHVpZD0xODczNzA1NABjaD0wAG9zPTkAYnI9MTAAaXA9MTI0LjEyNi4yMDUuNzgAc3NwPTEAYXBwX2lkPQBhcHBfc2lkPQBzZGtfdmVyc2lvbj0AdHRwPTEAY29tcGxlPTAAc3R5cGU9MABjaG1kPTAAc2NobWQ9MAB4aXA9MTAwLjY1LjQxLjgwAGR0cD0xAGNtYXRjaD0yMDAAZmlyc3RfcmVnaW9uPTEAc2Vjb25kX3JlZ2lvbj0zODIAYWRjbGFzcz0w&url=http%253A%252F%252Fbdtg%2E9377a%2Ecom%252Fsousuotg%2Ephp%253Fid%253D11852%2526uid%253D%257Bmpid%257D_%257Bcid%257D";
//const char* url = "http://show.mtty.com/v?p=-tsCgWZqNjC6xpRl8VwJxQ==&of=3&a=0086-ffff-ffff&b=20000&c=12551&d=8&e=10000&r=g2iwjo7r6xpag&s=8863364436303842593&x=13&tm=1463538785&w=&gz=1";
ParamMap paramMap;
getParamv2(paramMap,url);
typedef typename ParamMap::iterator Iter;
for(Iter iter = paramMap.begin();iter!=paramMap.end();iter++){
cout<<iter->first<<":"<<iter->second<<endl;
}
//DebugMessage("l:",paramMap["l"]);
//char buffer[1024];
//std::string output;
//urlDecode_f(paramMap["l"],output,buffer);
//DebugMessage("after decoded,l:",output);
}
示例8: luaL_checktype
int LuaUtils::Next(const ParamMap& paramMap, lua_State* L)
{
luaL_checktype(L, 1, LUA_TTABLE);
lua_settop(L, 2); // create a 2nd argument if there isn't one
// internal parameters first
if (lua_isnil(L, 2)) {
const string& nextKey = paramMap.begin()->first;
lua_pushsstring(L, nextKey); // push the key
lua_pushvalue(L, 3); // copy the key
lua_gettable(L, 1); // get the value
return 2;
}
// all internal parameters use strings as keys
if (lua_isstring(L, 2)) {
const char* key = lua_tostring(L, 2);
ParamMap::const_iterator it = paramMap.find(key);
if ((it != paramMap.end()) && (it->second.type != READONLY_TYPE)) {
// last key was an internal parameter
++it;
while ((it != paramMap.end()) && (it->second.type == READONLY_TYPE)) {
++it; // skip read-only parameters
}
if ((it != paramMap.end()) && (it->second.type != READONLY_TYPE)) {
// next key is an internal parameter
const string& nextKey = it->first;
lua_pushsstring(L, nextKey); // push the key
lua_pushvalue(L, 3); // copy the key
lua_gettable(L, 1); // get the value (proxied)
return 2;
}
// start the user parameters,
// remove the internal key and push a nil
lua_settop(L, 1);
lua_pushnil(L);
}
}
// user parameter
if (lua_next(L, 1)) {
return 2;
}
// end of the line
lua_pushnil(L);
return 1;
}
示例9: GVX_TRACE
// ######################################################################
void IntegerComplexChannel::writeTo(ParamMap& pmap) const
{
GVX_TRACE(__PRETTY_FUNCTION__);
IntegerChannel::writeTo(pmap);
ChannelFacetMap::writeFacetsTo(pmap);
for (uint i = 0; i < numChans(); ++i)
{
rutz::shared_ptr<ParamMap> submap(new ParamMap);
subChan(i)->writeTo(*submap);
submap->putDoubleParam("weight", rep->subchans[i].weight->getVal());
pmap.putSubpmap(subChan(i)->tagName(), submap);
}
}
示例10: InitParamMap
bool LuaWeaponDefs::PushEntries(lua_State* L)
{
if (paramMap.empty()) {
InitParamMap();
}
const map<string, int>& weaponMap = weaponDefHandler->weaponID;
map<string, int>::const_iterator wit;
for (wit = weaponMap.begin(); wit != weaponMap.end(); ++wit) {
const WeaponDef* wd = &weaponDefHandler->weaponDefs[wit->second];
if (wd == NULL) {
continue;
}
lua_pushnumber(L, wd->id);
lua_newtable(L); { // the proxy table
lua_newtable(L); { // the metatable
HSTR_PUSH(L, "__index");
lua_pushlightuserdata(L, (void*)wd);
lua_pushcclosure(L, WeaponDefIndex, 1);
lua_rawset(L, -3); // closure
HSTR_PUSH(L, "__newindex");
lua_pushlightuserdata(L, (void*)wd);
lua_pushcclosure(L, WeaponDefNewIndex, 1);
lua_rawset(L, -3);
HSTR_PUSH(L, "__metatable");
lua_pushlightuserdata(L, (void*)wd);
lua_pushcclosure(L, WeaponDefMetatable, 1);
lua_rawset(L, -3);
}
lua_setmetatable(L, -2);
}
HSTR_PUSH(L, "pairs");
lua_pushcfunction(L, Pairs);
lua_rawset(L, -3);
HSTR_PUSH(L, "next");
lua_pushcfunction(L, Next);
lua_rawset(L, -3);
lua_rawset(L, -3); // proxy table into WeaponDefs
}
return true;
}
示例11: InitParamMap
bool LuaUnitDefs::PushEntries(lua_State* L)
{
if (paramMap.empty()) {
InitParamMap();
}
const map<string, int>& udMap = unitDefHandler->unitDefIDsByName;
map<string, int>::const_iterator udIt;
for (udIt = udMap.begin(); udIt != udMap.end(); ++udIt) {
const UnitDef* ud = unitDefHandler->GetUnitDefByID(udIt->second);
if (ud == NULL) {
continue;
}
lua_pushnumber(L, ud->id);
lua_newtable(L); { // the proxy table
lua_newtable(L); { // the metatable
HSTR_PUSH(L, "__index");
lua_pushlightuserdata(L, (void*)ud);
lua_pushcclosure(L, UnitDefIndex, 1);
lua_rawset(L, -3); // closure
HSTR_PUSH(L, "__newindex");
lua_pushlightuserdata(L, (void*)ud);
lua_pushcclosure(L, UnitDefNewIndex, 1);
lua_rawset(L, -3);
HSTR_PUSH(L, "__metatable");
lua_pushlightuserdata(L, (void*)ud);
lua_pushcclosure(L, UnitDefMetatable, 1);
lua_rawset(L, -3);
}
lua_setmetatable(L, -2);
}
HSTR_PUSH(L, "pairs");
lua_pushcfunction(L, Pairs);
lua_rawset(L, -3);
HSTR_PUSH(L, "next");
lua_pushcfunction(L, Next);
lua_rawset(L, -3);
lua_rawset(L, -3); // proxy table into UnitDefs
}
return true;
}
示例12: InitParamMap
bool LuaFeatureDefs::PushEntries(lua_State* L)
{
if (paramMap.empty()) {
InitParamMap();
}
lua_newtable(L); { // the metatable
HSTR_PUSH_CFUNC(L, "__index", FeatureDefTableIndex);
HSTR_PUSH_CFUNC(L, "__newindex", FeatureDefTableNewIndex);
HSTR_PUSH_CFUNC(L, "__metatable", FeatureDefTableMetatable);
}
lua_setmetatable(L, -2);
return true;
}
示例13: ASSERT
// ##############################################################
bool ModelManager::parseCommandLine(const int argc,
const char** argv,
const char* usage,
const int minarg,
const int maxarg)
{
ASSERT(rep != 0);
// export options if that hasn't been done already
if (this->hasBeenExported() == false)
exportOptions(MC_RECURSE);
// let's get our application name:
if (argc <= 0)
LFATAL("expected argc >= 1, got argc=%d", argc);
string procname(argv[0]);
uint ii = procname.rfind('/'); // skip the path; get just the filename:
if (ii < procname.size()) procname = procname.substr(ii + 1);
// if we wanted to automatically load a config from ~/.execname,
// let's do that now:
if (rep->autoLoadConfig && getenv("HOME"))
{
string fname = string(getenv("HOME")) + "/." + procname;
FILE* tryit = fopen(fname.c_str(), "r");
if (tryit) { // config file exists; let's load it:
fclose(tryit);
LINFO("Autoloading configuration from '%s'", fname.c_str());
ParamMap pmap;
pmap.load(fname.c_str());
readParamsFrom(pmap);
}
}
return rep->com.parseCommandLine(argc, argv, usage, minarg, maxarg);
}
示例14:
/*!
*/
bool
RCSSParamParser::parse( ParamMap & param_map )
{
if ( M_str_pairs.empty() )
{
return false;
}
int n_params = 0;
for ( StrPairVec::iterator it = M_str_pairs.begin();
it != M_str_pairs.end();
++it )
{
// get parameter entry from map
ParamPtr param_ptr = param_map.findLongName( it->first );
// analyze value string
if ( param_ptr
&& param_ptr->analyze( it->second ) )
{
++n_params;
}
else
{
std::cerr << "***ERROR*** RCSSParamParser. "
<< "unknown parameter name or invalid value. name=["
<< it->first << "] value=[" << it->second << "]"
<< std::endl;
}
}
#ifdef DEBUG
std::cerr << "RCSSParamParser. [" << M_param_name
<< "] read " << n_params << " params."
<< std::endl;
#endif
return true;
}
示例15: saveIni
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void Var::saveIni( ParamMap &ini ) {
if ( type == Var_Float ) { ini.setFloat(name, var_float() ); }
if ( type == Var_Int ) { ini.setInt(name, var_int() ); }
if ( type == Var_String ) { ini.setString(name, var_string() ); }
}