Example #1
0
//============================================================================
//		NCache::SetValue : Set a value.
//----------------------------------------------------------------------------
void NCache::SetValue(const NCacheKey &theKey, NCacheValue *theValue)
{


	// Validate our parameters
	NN_ASSERT(theValue->GetCost() >= 0);



	// Prepare to set
	if (HasKey(theKey))
		RemoveKey(theKey);

	if (NeedsPurge())
		Purge();



	// Set the value
	mCache[theKey] = theValue;
	mCacheCost    += theValue->GetCost();

	theValue->SetAccessTime();
	theValue->Retain();
}
Example #2
0
 inline
 void MoveKeyTo(const std::string &k, SVMap &other) {
   if (OK_LIKELY(HasKey(k))) {
     other.entrymap_[k] = std::move(this->entrymap_.at(k));
     ClearKey(k);
   }
 }
Example #3
0
string SDP::GetStreamName() {
	if (!HasKey(SDP_SESSION))
		return "";
	if (!(*this)[SDP_SESSION].HasKey(SDP_S))
		return "";
	return (string) (*this)[SDP_SESSION][SDP_S];
}
Example #4
0
void ConfigFile::SetStringList(CTSTR lpSection, CTSTR lpKey, StringList &StrList)
{
    while(HasKey(lpSection, lpKey))
        Remove(lpSection, lpKey);

    for(unsigned int i=0; i<StrList.Num(); i++)
        AddString(lpSection, lpKey, StrList[i]);
}
Example #5
0
void ConfigFile::SetColorList(CTSTR lpSection, CTSTR lpKey, List<Color4> &ColorList)
{
    while(HasKey(lpSection, lpKey))
        Remove(lpSection, lpKey);

    for(unsigned int i=0; i<ColorList.Num(); i++)
        AddColor(lpSection, lpKey, ColorList[i]);
}
Example #6
0
void ConfigFile::SetFloatList(CTSTR lpSection, CTSTR lpKey, List<float> &FloatList)
{
    while(HasKey(lpSection, lpKey))
        Remove(lpSection, lpKey);

    for(unsigned int i=0; i<FloatList.Num(); i++)
        AddFloat(lpSection, lpKey, FloatList[i]);
}
Example #7
0
std::vector<plString> plKeysAndValues::GetAllValues(const plString & key)
{
    std::vector<plString> result;
    if (HasKey(key))
        for (Values::const_iterator vi=fKeys[key].begin(); vi!=fKeys[key].end(); ++vi)
            result.push_back(*vi);
    return result;
}
Example #8
0
void ConfigFile::SetIntList(CTSTR lpSection, CTSTR lpKey, List<int> &IntList)
{
    while(HasKey(lpSection, lpKey))
        Remove(lpSection, lpKey);

    for(unsigned int i=0; i<IntList.Num(); i++)
        AddInt(lpSection, lpKey, IntList[i]);
}
Example #9
0
ISkinObj* SSkinPool::GetSkin(LPCWSTR strSkinName)
{
    if(!HasKey(strSkinName))
    {
        return NULL;
    }
    return GetKeyObject(strSkinName);
}
Example #10
0
bool plKeysAndValues::AddValue(const std::string & key, const std::string & value, KAddValueMode mode)
{
    switch (mode)
    {
    case kFailIfExists:
        if (HasKey(key))
            return false;
        break;
    case kReplaceIfExists:
        if (HasKey(key))
            RemoveKey(key);
        break;
    default:
        break;
    }
    fKeys[key.c_str()].push_front(value.c_str());
    return true;
}
Example #11
0
std::vector<std::string> plKeysAndValues::GetAllValues(const std::string & key)
{
    std::vector<std::string> result;
    xtl::istring xkey = key.c_str();
    if (HasKey(key))
        for (Values::const_iterator vi=fKeys[xkey].begin(); vi!=fKeys[xkey].end(); ++vi)
            result.push_back(vi->c_str());
    return result;
}
Example #12
0
bool ConfigAPI::HasKey(const ConfigData &data, QString key) const
{
    if (data.file.isEmpty() || data.section.isEmpty())
    {
        LogWarning("ConfigAPI::HasKey: ConfigData does not have enough information (file, and section).");
        return false;
    }
    return HasKey(data.file, data.section, key);
}
Example #13
0
LPCTSTR DuiStringPool::Get( UINT uID )
{
    m_strTmp=_T("");
    if(HasKey(uID))
    {
        m_strTmp=GetKeyObject(uID);
        BuildString(m_strTmp);
    }
    return m_strTmp;
}
void execAttributesCheck() {

auto c = TClass::GetClass("TestDictProperties");
for (auto dm: *c->GetListOfDataMembers()){
   auto dmAM = static_cast<TDataMember*>(dm)->GetAttributeMap();
   for (auto const key : {"mapping","persistency"}){
      if (dmAM->HasKey(key)) std::cout << "Found property \"" << key << "\" and its value is " << dmAM->GetPropertyAsString(key)  << "\n"; 
   }
}

}
Example #15
0
void Dictionary<TKey, TValue>::Add(const TKey &key, const TValue &value)
{
	// if the key has already been added
	if (!dic_bAllowDuplicateKeys && HasKey(key)) {
		ASSERT(false);
		return;
	}

	// add it
	dic_saPairs.Push(new DictionaryPair<TKey, TValue>(key, value));
}
Example #16
0
    void DictionaryValue::SetWithoutPathExpansion(const std::string& key,
        Value* in_value)
    {
        // 如果值存在需要先删除, 因为拥有子对象的所有权.
        if(HasKey(key))
        {
            DCHECK(dictionary_[key] != in_value); // 只是一个假设.
            delete dictionary_[key];
        }

        dictionary_[key] = in_value;
    }
Example #17
0
QVariant ConfigAPI::DeclareSetting(const QString &file, const QString &section, const QString &key, const QVariant &defaultValue)
{
    if (HasKey(file, section, key))
    {
        return Read(file, section, key);
    }
    else
    {
        Write(file, section, key, defaultValue);
        return defaultValue;
    }
}
Example #18
0
pugi::xml_node SObjDefAttr::_GetDefAttribute(LPCWSTR pszClassName )
{
    if(!HasKey(pszClassName))
    {
        LPCWSTR pszBaseClassName=SApplication::getSingleton().BaseClassNameFromClassName(pszClassName);
        if(!pszBaseClassName) return pugi::xml_node();
        return _GetDefAttribute(pszBaseClassName);
    }else
    {
        return GetKeyObject(pszClassName);
    }
}
Example #19
0
PdfObject* PdfDictionary::GetKey( const PdfName & key )
{
    TIKeyMap it;

    if( HasKey( key ) )
    {
        it = m_mapKeys.find( key );
        return (*it).second;
    }
    
    return NULL;
}
Example #20
0
void Dictionary<TKey, TValue>::Add(const TKey &key, const TValue &value)
{
  // if the key has already been added
  if(!dic_bAllowDuplicateKeys && HasKey(key)) {
    ASSERT(FALSE);
    return;
  }

  // add it
  dic_saKeys.Push() = key;
  dic_saValues.Push() = value;
}
Example #21
0
bool PdfDictionary::RemoveKey( const PdfName & identifier )
{
    if( HasKey( identifier ) )
    {
        delete m_mapKeys[identifier];

        m_mapKeys.erase( identifier );
        m_bDirty = true;
        return true;
    }

    return false;
}
Example #22
0
LPCWSTR SWindowFactoryMgr::BaseClassNameFromClassName( LPCWSTR pszClassName )
{
    if(!HasKey(pszClassName))
    {
        STraceW(L"BaseClassNameFromClassName, Warning: no window type:%s in SOUI!!",pszClassName);
        return NULL;
    }
    LPCWSTR pszBaseClassName=GetKeyObject(pszClassName)->SWindowBaseName();
    if(!pszBaseClassName) return NULL;
    //注意,baseClassName可能与ClassName相同,为了避免死循环,这里需要判断一下。
    if(wcscmp(pszBaseClassName,pszClassName)==0) return NULL;
    return pszBaseClassName;
}
std::int64_t AudioService::getCurrentPlaybackTrackId() const
{

	auto settingsValues = Windows::Storage::ApplicationData::Current->LocalSettings->Values;
	if (!settingsValues->HasKey(L"CurrentPlaybackTrackId")) {
		return -1;
	}
	auto box = dynamic_cast<Platform::IBox<std::int64_t>^> (settingsValues->Lookup(L"CurrentPlaybackTrackId"));
	if (!box) {
		return -1;
	}
	return box->Value;
}
Example #24
0
/** \fn Action::AddKey(const QString&)
 *  \brief Add a key sequence to this action.
 *
 *   We don't add empty keys nor duplicates, and cannot
 *   add more than kMaximumNumberOfBindings. If any of
 *   these restrictions are a problem we return false and
 *   do not add the binding.
 *
 *  \param key The key to add to the action.
 *  \return true if the key was added otherwise, false.
 */
bool Action::AddKey(const QString &key)
{
    if (key.isEmpty() || HasKey(key) ||
        ((uint)m_keys.size() >= kMaximumNumberOfBindings))
    {
        return false;
    }

    QString tmp = key;
    tmp.detach();
    m_keys.push_back(tmp);

    return true;
}
Example #25
0
/** \fn Action::ReplaceKey(const QString&, const QString&)
 *  \brief Replace a key.
 *  \param newkey The new key.
 *  \param oldkey The old key, which is being replaced.
 */
bool Action::ReplaceKey(const QString &newkey, const QString &oldkey)
{
    // make sure that the key list doesn't already have the new key
    if (HasKey(newkey))
        return false;

    int idx = m_keys.indexOf(oldkey);
    if (idx < 0)
        return false;

    QString tmp = newkey;
    tmp.detach();
    m_keys[idx] = tmp;
    return true;
}
api::TrackInfo AudioService::getCurrentPlaybackTrack() const
{
	auto settingsValues = Windows::Storage::ApplicationData::Current->LocalSettings->Values;
	if (!settingsValues->HasKey(L"CurrentPlaybackTrack")) {
		api::TrackInfo ti;
		ti.id = -1;
		return ti;
	}
	else {
		auto jsonString = dynamic_cast<Platform::String^>(settingsValues->Lookup(L"CurrentPlaybackTrack"));
		tools::strings::WindowsWIStream stream(jsonString);
		auto jsonVal = web::json::value::parse(stream);
		return api::TrackInfo(jsonVal);
	}
}
Example #27
0
SWindow * SWindowFactoryMgr::CreateWindowByName( LPCWSTR pszClassName )
{
    if(!HasKey(pszClassName))
    {
        STraceW(L"Warning: no window type:%s in SOUI!!",pszClassName);
        return NULL;
    }
    SWindow * pRet = GetKeyObject(pszClassName)->NewWindow();
    SASSERT(pRet);
    if(pRet)
    {
        SetSwndDefAttr(pRet);
    }
    return pRet;
}
Example #28
0
    const Data& Data::operator[](const Data& key) const
    {
	if(!IsList())
	    throw Error::Invalid("Data::operator[](const Data&)","Not a dictionary.");

	if(!HasKey(key))
	    return Null;

	bool is_old;
	size_t i;

	i=KeyLookup(key,is_old);
		
	return ((const cow_vector<Data>&)(vec))[size_t(i)][1];
    }
Example #29
0
	char KeyWait(int col, int row)
	{
		// Clear keyboard and keywait
    get_console(1);
		unsigned t = 0;
		while(!HasKey())
		{
			if (read_ticks() > t + 1000)
			{
				DisplayBattery(col, row);
				t = read_ticks();
			}
			SVC_WAIT(50);
		}

		return GetKey();
	}
Example #30
0
void SObjDefAttr::BuildClassAttribute( pugi::xml_node & xmlNode, LPCWSTR pszClassName)
{
    LPCWSTR pszBaseClassName=SApplication::getSingleton().BaseClassNameFromClassName(pszClassName);
    if(!pszBaseClassName) return;

    if(HasKey(pszBaseClassName))
    {
        pugi::xml_node xmlNodeAttrs = GetKeyObject(pszBaseClassName);
        pugi::xml_attribute attr=xmlNodeAttrs.first_attribute();
        while(attr)
        {
            if(!xmlNode.attribute(attr.name()))
                xmlNode.append_attribute(attr.name()).set_value(attr.value());
            attr=attr.next_attribute();
        }
    }
    BuildClassAttribute(xmlNode,pszBaseClassName);
}