示例#1
0
bool wxRegConfig::DoReadBinary(const wxString& key, wxMemoryBuffer *buf) const
{
    wxCHECK_MSG( buf, false, wxT("wxRegConfig::Read(): NULL param") );

  wxConfigPathChanger path(this, key);

  bool bQueryGlobal = true;

  // if immutable key exists in global key we must check that it's not
  // overriden by the local key with the same name
  if ( IsImmutable(path.Name()) ) {
    if ( TryGetValue(m_keyGlobal, path.Name(), *buf) ) {
      if ( m_keyLocal.Exists() && LocalKey().HasValue(path.Name()) ) {
        wxLogWarning(wxT("User value for immutable key '%s' ignored."),
                   path.Name().c_str());
      }

      return true;
    }
    else {
      // don't waste time - it's not there anyhow
      bQueryGlobal = false;
    }
  }

  // first try local key
  if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), *buf)) ||
       (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), *buf)) ) {
    return true;
  }

  return false;
}
示例#2
0
  bool MapEventManager::RemoveEventEntry (MapEventContext* eventContext)
  {
    DynamicWorldObject& object = eventContext->GetTrigger ();
    MapEvent& event = eventContext->GetMapEventInfo ().GetEvent ();

    auto eventTriggering = events_.TryGetValue (&object);

    if (eventTriggering == nullptr)
      return false;

    auto eventTriggers = eventTriggering->TryGetValue (&event);

    if (eventTriggers == nullptr)
      return false;

    if (!eventTriggers->Remove (eventContext))
      return false;

    if (eventTriggers->IsEmpty ())
      eventTriggering->Remove (&event);

    if (eventTriggering->IsEmpty ())
      events_.Remove (&object);

    return true;
  }
示例#3
0
  bool MapEventManager::AddEventEntry (MapEventContext* eventContext)
  {
    DynamicWorldObject& object = eventContext->GetTrigger ();
    MapEvent& event = eventContext->GetMapEventInfo ().GetEvent ();

    auto eventTriggering = events_.TryGetValue (&object);

    if (eventTriggering == nullptr)
      events_.Add (&object, EventTriggeringType ());

    auto eventTriggers = eventTriggering->TryGetValue (&event);

    if (eventTriggers == nullptr)
    {
      auto triggers = yap::collection::Set<
        MapEventContext*,
        MapEventContextTriggerComparator> ();

      if (!triggers.Add (eventContext))
        return false;

      eventTriggering->Add (
        &event,
        triggers);

      return true;
    }

    return eventTriggers->Add (eventContext);
  }
示例#4
0
const Phobos::Register::Table::Value_s &Phobos::Register::Table::GetValue(const Table *current, const String_t &key)
{
	const Value_s *foundValue = TryGetValue(current, key);
	if(!foundValue)
	{
		std::stringstream stream;
		stream << "Value " << key << " does not exists in " << current->GetName();
		PH_RAISE(OBJECT_NOT_FOUND_EXCEPTION, "Phobos::Register::Table::GetString", stream.str());
	}

	return *foundValue;
}
示例#5
0
文件: main.cpp 项目: CCJY/coliru
	bool TryGetValue ( TContainer& container, TValue& value ) {
		return TryGetValue( std::begin( container ), std::end( container ), value );
	}
示例#6
0
const Phobos::String_t *Phobos::Register::Table::TryGetString(const Table *current, const String_t &key)
{
	const Value_s *value = TryGetValue(current, key);

	return value != NULL ? &value->m_strValue : NULL;
}