int QIniFileImpl::GetBool(const char* lpSection, const char* lpKeyName, int* pBool) { char Buffer[16]; const char* Value[]= { "true", "false", "1", "0", "yes", "no" }; int nResult = false; if (GetKeyValue(lpSection, lpKeyName, Buffer, 1)) { for (int i = 0; i < sizeof(Value) / sizeof(const char*); i++) { #ifdef unix if (!strcasecmp(Buffer, Value[i])) #else if (!stricmp(Buffer, Value[i])) #endif { *pBool = ((i % 2) == 0); nResult = true; break; } } } return nResult; }
//--------------------------------------------------------------------------- // 函数: GetInteger2 // 功能: 读取2个整数,整数之间用逗号分割。 // 参数: lpSection 节名 // lpKeyName 建名 // pnValue1 返回值1 // pnValue2 返回值2 // 返回: void //--------------------------------------------------------------------------- BOOL KIniFile::GetInteger2( LPCSTR lpSection, // points to section name LPCSTR lpKeyName, // points to key name int *pnValue1, // value 1 int *pnValue2 // value 2 ) { char Buffer[32]; char* pChar = Buffer; if (GetKeyValue(lpSection, lpKeyName, Buffer, sizeof(Buffer))) { while (*pChar) { if (',' == *pChar) { *pChar++ = 0; break; } pChar++; } *pnValue1 = atoi(Buffer); *pnValue2 = atoi(pChar); return TRUE; } return FALSE; }
unsigned char ReadDatasFromSIM300_OKstr(unsigned char *rcv_buf,unsigned long size,unsigned long sec,unsigned char *OKstr) { u8 keyval; u8 *p; u32 pos; kmy_USART2ReceiveReset(); sec*=1000; pos = 0; if(size)size--; else return 5; p=rcv_buf; while(1) { pos=ReadDatasFromtty(fd_ttyS1,p,size,0,100*1000); p+=pos; size-=pos; *p=0; sec-=100; if(strstr((char const*)rcv_buf, (char const*)OKstr))return 0; else if(strstr((char const*)rcv_buf,"ERROR"))return 1; if(sec<=0)return 3; keyval=GetKeyValue(); if(keyval==KEY_ReturnInitInterface)return 2; } }
idStr CModInfo::GetModCompletedString() { if (modName == "training_mission") { return common->Translate( "#str_02511" ); // Not completable } idStr diffStr; bool anyCompleted = false; for (int i = 0; i < DIFFICULTY_COUNT; ++i) { bool diffCompleted = GetKeyValue(va("mission_completed_%d", i)) == "1"; if (diffCompleted) { diffStr += diffStr.Length() > 0 ? ", " : ""; diffStr += gameLocal.m_DifficultyManager.GetDifficultyName(i); anyCompleted = true; } } if (anyCompleted) { return va( common->Translate( "#str_02513" ), diffStr.c_str()); // "Yes (%s)" } else { return common->Translate( "#str_02512" ); // Not yet } }
Namespace *SKS::GetNamespace(Position &pos, bool noName) { Namespace *name = new Namespace(); if(!noName) name->SetName(GetName(pos)); while(true) { if(islineEndOfFile(pos)) { break; } SkipComment(pos); if(isLineNamespaceEnd(pos)) { ExitNamespace(pos); break; } else if(isLineNamespace(pos)) { name->AddNamespace(GetNamespace(pos)); } else if(isLineKeyValue(pos)) { name->AddKeyValue(GetKeyValue(pos)); } else break; } return name; }
int Ardb::HashGet(Context& ctx, ValueObject& meta, Data& field, Data& value) { if (meta.meta.encoding != COLLECTION_ECODING_ZIPMAP) { ValueObject vv; vv.key.type = HASH_FIELD; vv.key.db = meta.key.db; vv.key.key = meta.key.key; vv.key.element = field; int err = GetKeyValue(ctx, vv.key, &vv); if (0 == err) { value = vv.element; } return err; } else { DataMap::iterator fit = meta.meta.zipmap.find(field); if (fit == meta.meta.zipmap.end()) { return ERR_NOT_EXIST; } value = fit->second; return 0; } }
float *KeyboardControl::GetValuePtr(const char *name) { KeyValue *key = GetKeyValue(name); if (key) return key->GetValuePtr(); else return NULL; }
float KeyboardControl::GetMaxValue(const char *name) { KeyValue *key = GetKeyValue(name); if (key) return key->GetMaxValue(); else return 0.0f; }
const wxString& IniParser::GetKeyValue(int group, const wxString& key) const { static wxString empty; int keyIdx = FindKeyByName(group, key); if (keyIdx == -1) return empty; return GetKeyValue(group, keyIdx); }
nsresult nsDOMStorageDBWrapper::GetKeyValue(DOMStorageImpl* aStorage, const nsAString& aKey, nsAString& aValue, bool* aSecure) { IMPL_FORWARDER(GetKeyValue(aStorage, aKey, aValue, aSecure)); }
std::string CContactPersonalDetailInfo::GetInfo(EnInfoType enInfoType) const { std::string strKey = GetInfoTypeKey(enInfoType); if (strKey.empty()) return strKey; return GetKeyValue(strKey); }
int Ardb::DeleteKey(Context& ctx, const Slice& key) { ValueObject meta; meta.key.type = KEY_META; meta.key.db = ctx.currentDB; meta.key.key = key; if (0 != GetKeyValue(ctx, meta.key, &meta)) { return 0; } switch (meta.type) { case SET_META: { SClear(ctx, meta); break; } case LIST_META: { LClear(ctx, meta); break; } case ZSET_META: { ZClear(ctx, meta); break; } case HASH_META: { HClear(ctx, meta); break; } case STRING_META: { DelKeyValue(ctx, meta.key); break; } case BITSET_META: { BitClear(ctx, meta); break; } default: { return 0; } } if (meta.meta.expireat > 0) { KeyObject expire; expire.type = KEY_EXPIRATION_ELEMENT; expire.db = ctx.currentDB; expire.key = key; expire.score.SetInt64(meta.meta.expireat); DelKeyValue(ctx, expire); } return 1; }
void CContactDetailInfoUtils::GetAreaName(const KeyValueMap_t& profileMap, std::string& strCountryName, std::string& strProvinceName, std::string& strCityName) { //地域字段由于存储方式的特别,所以这里特殊处理一下 std::string strCountryCode = GetKeyValue(profileMap, COUNTRY_KEYWORD_ID); std::string strProvinceCode = GetKeyValue(profileMap, PROVINCE_KEYWORD_ID); std::string strCityCode = GetKeyValue(profileMap, CITY_KEYWORD_ID); //country的parent code是0 strCountryName = m_contactInfoCollectionUtils.GetNameByCodeInAreaMap("0", strCountryCode); if (strCountryName.empty()) return; strProvinceName = m_contactInfoCollectionUtils.GetNameByCodeInAreaMap(strCountryCode, strProvinceCode); if (strProvinceName.empty()) return; strCityName = m_contactInfoCollectionUtils.GetNameByCodeInAreaMap(strProvinceCode, strCityCode); }
bool CModInfo::ModCompleted( int difficultyLevel ) { bool anyCompleted = false; for( int i = 0; i < DIFFICULTY_COUNT; ++i ) { bool diffCompleted = GetKeyValue( va( "mission_completed_%d", i ) ) == "1"; if( difficultyLevel == i ) { return diffCompleted; } // Accumulate the information anyCompleted |= diffCompleted; } return anyCompleted; }
void CContactDetailInfoUtils::MakeContactDetailInfo(const KeyValueMap_t& profileMap, CContactPersonalDetailInfo& detailInfo) { //递归detailinfo的InfoType map,根据key得到profileMap里的值 //这个profileMap里的值可能是code也可能是直接是值 //如果key是area相关的,则特殊处理 //先到contactInfoCollections里去寻找值 //如果找不到值,则就是值 //如果找到,则设置为值 const CContactPersonalDetailInfo::InfoTypeKeyMap_t& infoTypeKeyMap = detailInfo.GetInfoTypeKeyMap(); do { CContactPersonalDetailInfo::InfoTypeKeyMap_t::const_iterator b = infoTypeKeyMap.begin(); CContactPersonalDetailInfo::InfoTypeKeyMap_t::const_iterator e = infoTypeKeyMap.end(); for (; b != e; ++b) { CContactPersonalDetailInfo::EnInfoType infoType = b->first; const std::string& strKey = b->second; std::string strProfileMapValue = GetKeyValue(profileMap, strKey); if (infoType == CContactPersonalDetailInfo::GENDER_INFO && strProfileMapValue.empty()) { strProfileMapValue = "0"; //性别为保密 } std::string strValue = strProfileMapValue; //strProfileMapValue可能就是值(譬如生日字段),也可能是个code(譬如性别字段),如果是code则需要二次查询对应的值 //去contactinfocollections里去查询 if (strKey != COUNTRY_KEYWORD_ID && strKey != PROVINCE_KEYWORD_ID && strKey != CITY_KEYWORD_ID) { std::string strNameByCode = m_contactInfoCollectionUtils.GetNameByCodeInNormalInfoMap(strKey, strProfileMapValue); if (!strNameByCode.empty()) strValue = strNameByCode; //如果非空,则表示strProfileMapValue真的是个code,而不是个值 } detailInfo.SetInfo(infoType, strValue); } std::string strCountryName, strProvinceName, strCityName; GetAreaName(profileMap, strCountryName, strProvinceName, strCityName); detailInfo.SetAreaInfo(strCountryName, strProvinceName, strCityName); } while (0); }
QString FhoReg::GetKeyValue(HKEY parentKey, QString &parentSubKeyName, QString &valueName) { HKEY k = OpenKey(parentKey, parentSubKeyName, KEY_QUERY_VALUE); QString value; if (k != 0) { value = GetKeyValue(k, valueName); CloseKey(k); } return value; }
//--------------------------------------------------------------------------- // 函数: GetString // 功能: 读取一个字符串 // 参数: lpSection 节名 // lpKeyName 建名 // lpDefault 缺省值 // lpRString 返回值 // dwSize 返回字符串的最大长度 //--------------------------------------------------------------------------- int QIniFileImpl::GetString( const char* lpSection, // points to section name const char* lpKeyName, // points to key name const char* lpDefault, // points to default string char* lpRString, // points to destination buffer unsigned int dwSize // size of string buffer ) { if (GetKeyValue(lpSection, lpKeyName, lpRString, dwSize)) return true; QStrCpyLen(lpRString, lpDefault, dwSize); return false; }
//--------------------------------------------------------------------------- // 函数: GetString // 功能: 读取一个字符串 // 参数: lpSection 节名 // lpKeyName 建名 // lpDefault 缺省值 // lpRString 返回值 // dwSize 返回字符串的最大长度 // 返回: void //--------------------------------------------------------------------------- BOOL KIniFile::GetString( LPCSTR lpSection, // points to section name LPCSTR lpKeyName, // points to key name LPCSTR lpDefault, // points to default string LPSTR lpRString, // points to destination buffer DWORD dwSize // size of string buffer ) { if (GetKeyValue(lpSection, lpKeyName, lpRString, dwSize)) return TRUE; g_StrCpyLen(lpRString, lpDefault, dwSize); return FALSE; }
PIN_Number PIN_GameControllerManager::GetUpdatedGameKey(PIN_GameControllerEntry* ctrl, PIN_ControllerKeyComboSet* combo) { std::string strFormula(combo->ComboString); PIN_ControllerKeyComboList::iterator it; //printf("CMB === %s\n",combo->ComboString); for(it = combo->ComboKeys.begin(); it != combo->ComboKeys.end(); ++it) { PIN_GameControllerKeyInfo code = *it; boost::replace_first( strFormula, PIN_KEYFORMAT, boost::lexical_cast<std::string>(GetKeyValue(ctrl, code)) /*? PIN_KEYON : PIN_KEYOFF*/); if(code.KeyType == PIN_GKT_AXIS && code.AxisDirection == PIN_GAD_BOTH) { //do it again boost::replace_first( strFormula, PIN_KEYFORMAT, boost::lexical_cast<std::string>(GetKeyValue(ctrl, code)) /*? PIN_KEYON : PIN_KEYOFF*/); } } //printf("FRM == %s\n",strFormula.c_str()); char* res = _comboParser.parse(strFormula.c_str()); //printf("RES = %s\n",res); PIN_Number nRes = (*res) - 48; return nRes; }
NTSTATUS GetLangFile(PUNICODE_STRING LangFile, ULONG LangIndex, PCWSTR SubKey) { BOOL Success; WCHAR LangIndexBuffer[16]; NTSTATUS Status; PKEY_VALUE_PARTIAL_INFORMATION FileName; swprintf(LangIndexBuffer, L"%04x", LangIndex); Status = GetKeyValue(REGKEY_ROOT, SubKey, LangIndexBuffer, &FileName); FAIL_RETURN(Status); Success = RtlCreateUnicodeString(LangFile, (PWSTR)FileName->Data); FreeMemoryP(FileName); return Success ? STATUS_SUCCESS : STATUS_NO_MEMORY; }
//获取多个int值 int QIniFileImpl::GetMultiInteger(const char* lpSection, const char* lpKeyName, int *pValues, int nCount) { int nReadCount = 0; if (nCount > 0 && nCount <= INI_MAX_SUPPORT_MULTI_VALUE_COUNT) { char Buffer[INI_MAX_SUPPORT_VALUE_SIZE]; if (GetKeyValue(lpSection, lpKeyName, Buffer, sizeof(Buffer))) { const char *pcszTemp = Buffer; do { pValues[nReadCount++] = g_StringGetInt(&pcszTemp, 0); }while((nReadCount < nCount) && g_StringSkipSymbol(&pcszTemp, ',')); } } return nReadCount; }
__s32 GetFileListNum(__hdle hConfig, __u32 *Num) { __u32 ret; if ((NULL == hConfig) || (NULL == Num)) { return EPDK_FAIL; } ret = GetKeyValue((HCONFIG)hConfig, (s8 *)FILE_LIST_SECTION_NAME, (s8 *)FILE_LIST_SECTION_COUNT_NAME, Num); if (ret != OK) { __inf("GetKeyValue failed\n"); return EPDK_FAIL; } return EPDK_OK; }
// 如果从文件中没有取到对应的Section 和 Key则 pRect里面的值不变 void KIniFile::GetRect(LPCSTR lpSection, LPCSTR lpKeyName, RECT *pRect) { char Buffer[256]; if (GetKeyValue(lpSection, lpKeyName, Buffer, sizeof(Buffer))) { const char *pcszTemp = Buffer; pRect->left = KSG_StringGetInt(&pcszTemp, 0); KSG_StringSkipSymbol(&pcszTemp, ','); pRect->top = KSG_StringGetInt(&pcszTemp, 0); KSG_StringSkipSymbol(&pcszTemp, ','); pRect->right = KSG_StringGetInt(&pcszTemp, 0); KSG_StringSkipSymbol(&pcszTemp, ','); pRect->bottom = KSG_StringGetInt(&pcszTemp, 0); //sscanf(Buffer, "%d,%d,%d,%d", &(pRect->left), &(pRect->top), &(pRect->right), &(pRect->bottom)); } }
//--------------------------------------------------------------------------- // 函数: GetInteger // 功能: 读取一个整数 // 参数: lpSection 节名 // lpKeyName 建名 // nDefault 缺省值 // pnValue 返回值 //--------------------------------------------------------------------------- int QIniFileImpl::GetInteger( const char* lpSection, // points to section name const char* lpKeyName, // points to key name int nDefault, // default value int *pnValue // points to value ) { char Buffer[32]; if (GetKeyValue(lpSection, lpKeyName, Buffer, sizeof(Buffer))) { *pnValue = atoi(Buffer); return true; } else { *pnValue = nDefault; return false; } }
//--------------------------------------------------------------------------- // 函数: GetFloat // 功能: 读取1个浮点数 // 参数: lpSection 节名 // lpKeyName 建名 // fDefault 缺省值 // pfValue 返回值 // 返回: //--------------------------------------------------------------------------- int QIniFileImpl::GetFloat( const char* lpSection, // points to section name const char* lpKeyName, // points to key name float fDefault, // default value float *pfValue // return value ) { char Buffer[32]; if (GetKeyValue(lpSection, lpKeyName, Buffer, sizeof(Buffer))) { *pfValue = (float)atof(Buffer); return true; } else { *pfValue = fDefault; return false; } }
//--------------------------------------------------------------------------- // 函数: GetInteger // 功能: 读取一个整数 // 参数: lpSection 节名 // lpKeyName 建名 // nDefault 缺省值 // pnValue 返回值 // 返回: void //--------------------------------------------------------------------------- BOOL KIniFile::GetInteger( LPCSTR lpSection, // points to section name LPCSTR lpKeyName, // points to key name int nDefault, // default value int *pnValue // points to value ) { char Buffer[32]; if (GetKeyValue(lpSection, lpKeyName, Buffer, sizeof(Buffer))) { *pnValue = atoi(Buffer); return TRUE; } else { *pnValue = nDefault; return FALSE; } }
unsigned char send_at_cmd_and_receive(unsigned char * CmdBuff,int CmdBuffSize,int Ms,const unsigned char *OkStr) { int i,ret,size,pos; unsigned char retval=TCP_SendAtTimeout; kmy_USART2ReceiveReset(); SetAutoExitTime(0); Ms/=20; send_at_cmd(CmdBuff); *CmdBuff=0; for(pos=i=0,size=CmdBuffSize;i<Ms;i++) { ret= ReadDatasFromtty(fd_ttyS1,CmdBuff+pos,size,0,20000); if(ret) { pos+=ret; size-=ret; } else { if(strstr((char const*)CmdBuff,(char const*)OkStr))break; retval=GetKeyValue(); if(retval!=KEY_NONE) { if(retval==KEY_ReturnInitInterface||retval==KEY_ReturnPrevious){retval=TCP_UserSelfReturn;break;} } } } if(i<Ms)retval=TCP_OK; printf("SendAtCmd receive-->%d %s\r\n",pos,CmdBuff); return retval; }
char* cngplpGetData(cngplpData *data, int id) { char *ret = NULL; if(id == ID_PPD_OPTION){ ret = GetAllOptionID(data); }else if(id < ID_COMMON_OPTION){ ret = GetDataPPDOption(data, id); }else if(id < ID_IMAGE_OPTION){ ret = GetDataCommonOption(data, id); }else if(id < ID_TEXT_OPTION){ ret = GetDataImageOption(data, id); }else if(id < ID_HPGL_OPTION){ ret = GetDataTextOption(data, id); }else if(id < ID_BOTTON_EVENT){ ret = GetDataHPGLOption(data, id); }else if(id == ID_KEY_VALUE){ ret = GetKeyValue(data); } return ret; }
bool KeyBindConfig::ReadFromFile(const std::string path, char* data) { KeyConverter kc; int count = 0; int index = 0; std::ifstream read; read.open(path); if(!read.is_open()) return false; while(!read.eof() && count < KEY_CAP) { std::string line; char key[52]; char command[52]; std::getline(read, line); TrimAndSet(line); sscanf_s(line.c_str(), "%s = ", key, sizeof(key)); sscanf_s(line.c_str(), (std::string(key) + " = %s").c_str(), &command, sizeof(command)); index = GetKeyValue(command); char keyAdd = kc.ConvertToChar(key); if(keyAdd == '\0') keyAdd = key[0]; if(index != -1) data[index] = keyAdd; count++; } read.close(); return true; }
//--------------------------------------------------------------------------- // 函数: GetFloat2 // 功能: 读取2个浮点数,之间用逗号分割。 // 参数: lpSection 节名 // lpKeyName 建名 // pfValue1 返回值1 // pfValue2 返回值2 // 返回: //--------------------------------------------------------------------------- int QIniFileImpl::GetFloat2( const char* lpSection, // points to section name const char* lpKeyName, // points to key name float *pfValue1, // value 1 float *pfValue2 // value 2 ) { char Buffer[64]; if (GetKeyValue(lpSection, lpKeyName, Buffer, sizeof(Buffer))) { char* pSplit = strchr(Buffer, ','); if (pSplit) { *pSplit = '\0'; *pfValue2 = (float)atof(pSplit + 1); } *pfValue1 = (float)atof(Buffer); return (pSplit != NULL); } return false; }