Пример #1
0
	static const T &load(const std::string &resourceName, Args... args){
		typename std::map<std::string, T>::iterator p = _resources.lower_bound(resourceName);
		if(p == _resources.end() || p->first != resourceName){
			cout<<"WARNING: Resource: "+resourceName+" not found. Loading..."<<endl;
			p = _resources.emplace_hint(p, std::piecewise_construct, std::forward_as_tuple(resourceName), std::forward_as_tuple(args...));
		}
		return p->second;
	}
Пример #2
0
	///////////////////////
	/// Devuelve el recurso asociado con el nombre, si no está trata de crearlo usando un constructor por defecto e inicializarlo luego llamando a la funcion f con los parametros args
	//////////////////////
	static const T &loadFromFile(const std::string &fileName){
		typename std::map<std::string, T>::iterator p = _resources.lower_bound(fileName);
		if(p == _resources.end() || p->first != fileName){
			p = _resources.emplace_hint(p, std::piecewise_construct, std::forward_as_tuple(fileName), std::forward_as_tuple());
			if(!p->second.loadFromFile(fileName)){
				cout<<"ERROR: Couldn't load file: "<<fileName<<endl;
			}
		}
		return p->second;
	}
Пример #3
0
  //! Loading for std::map<std::string, std::string>
  template <class Archive, class C, class A> inline
  void load( Archive & ar, std::map<std::string, std::string, C, A> & map )
  {
    map.clear();

    auto hint = map.begin();
    while( true )
    {
      const auto namePtr = ar.getNodeName();

      if( !namePtr )
        break;

      std::string key = namePtr;
      std::string value; ar( value );
      hint = map.emplace_hint( hint, std::move( key ), std::move( value ) );
    }
  }
Пример #4
0
            traits::EnableIf<traits::is_text_archive<Archive>::value> = traits::sfinae> inline
  void load( Archive & ar, std::map<std::string, T, C, A> & map )
  {
    map.clear();

    auto hint = map.begin();
    while( true )
    {
      const auto namePtr = ar.getNodeName();

      if( !namePtr )
        break;

      std::string key = namePtr;
      T value;
      ar( value );
      hint = map.emplace_hint( hint, std::move( key ), std::move( value ) );
    }
  }
Пример #5
0
		UTF16String *CreateValue(const wchar_t *pwszName){
			xKey Key(pwszName, std::wcslen(pwszName));
			const auto iterHint = xm_mapValues.upper_bound(Key);
			return &(xm_mapValues.emplace_hint(iterHint, std::move(Key), UTF16String())->second);
		}
Пример #6
0
		Package *CreatePackage(const wchar_t *pwszName){
			xKey Key(pwszName, std::wcslen(pwszName));
			const auto iterHint = xm_mapPackages.upper_bound(Key);
			return &(xm_mapPackages.emplace_hint(iterHint, std::move(Key), Package())->second);
		}