// This may look like C code, but it's really -*- C++ -*-
/*
 * Copyright (C) 2005 Koen Deforche, Kessel-Lo, Belgium.
 *
 * See the LICENSE file for terms of use.
 */
#ifndef WMESSAGE_RESOURCES_
#define WMESSAGE_RESOURCES_

#include <string>
#include <vector>
#include <map>

namespace Wt {

class WString;

class WMessageResources
{
public:
  WMessageResources(const std::string path, bool loadInMemory = true);

  void hibernate();

  const std::string path() const { return path_; }

  bool getValue(const WString& message, std::wstring& value);

  void refresh();

  typedef std::map<std::string, std::wstring> KeyValueMap;

private:
  const bool loadInMemory_;
  bool loaded_;
  const std::string path_;

  KeyValueMap local_;
  KeyValueMap defaults_;

  bool readResourceFile(std::string locale, KeyValueMap& valueMap);
  bool getValue(const std::string& key,
		const std::vector<std::wstring>& args,
		std::wstring& result);

  static void substitute(std::wstring& result,
			 const std::vector<std::wstring>& args);
};

}

#endif // WMESSAGE_RESOURCES_
