void paramTest(){ const char* url = "v=1.0&d=9&k=1&y=7&t1=ererwrwer3&t2="; //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); }
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); }
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; }