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

#include <vector>
#include <Wt/WLocalizedStrings>

namespace Wt {

class WMessageResources;

/*! \class WCombinedLocalizedStrings Wt/WCombinedLocalizedStrings Wt/WCombinedLocalizedStrings
 *  \brief A localized string resolver that bundles multiple string resolvers.
 *
 * This class implements the localized strings interface and delegates
 * WString::tr() string resolution to one or more string
 * resolvers. You will typically use this class if you want to combine
 * different methods of string resolution (e.g. some from files, and
 * other strings using a database).
 *
 * \sa WApplication::setLocalizedStrings()
 */
class WT_API WCombinedLocalizedStrings : public WLocalizedStrings
{
public:
  /*! \brief Constructor.
   */
  WCombinedLocalizedStrings();

  virtual ~WCombinedLocalizedStrings();

  /*! \brief Adds a string resolver.
   *
   * resolveKey() will consult each string resolver in the order they have
   * been added.
   */
  void add(WLocalizedStrings* stringResolver);

  /*! \brief Returns all string resolver
   *
   * Returns the list of all string resolvers that were added by
   * a call to add().
   */
  const std::vector<WLocalizedStrings *> &items() const;

  virtual void refresh();
  virtual void hibernate();

#ifndef WT_TARGET_JAVA
  virtual bool resolveKey(const std::string& key, std::string& result);
#else // WT_TARGET_JAVA
  virtual std::string *resolveKey(const std::string& key) = 0;
#endif // WT_TARGET_JAVA

#ifndef WT_TARGET_JAVA
  virtual bool resolvePluralKey(const std::string& key, 
				std::string& result,
				::uint64_t amount);
#else // WT_TARGET_JAVA
  //TODO make this work for java
  //virtual std::string *resolveKey(const std::string& key) = 0;
#endif // WT_TARGET_JAVA
private:
  std::vector<WLocalizedStrings *> localizedStrings_;
};

}

#endif // WCOMBINED_LOCALIZED_STRINGS_
