BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Types | Public Member Functions | Protected Member Functions
BeeeOn::Translator Class Referenceabstract
Inheritance diagram for BeeeOn::Translator:
BeeeOn::NoTranslator

Public Types

typedef Poco::SharedPtr
< Translator
Ptr
 

Public Member Functions

template<typename... Rest>
std::string formatSure (const std::string &key, const Rest &...rest)
 
template<typename... Rest>
std::string format (const std::string &key, const std::string &def, const Rest &...rest)
 
std::string vformat (const std::string &key, const std::string &def, const std::vector< Poco::Dynamic::Var > &args)
 

Protected Member Functions

void prepareArg (std::vector< Poco::Dynamic::Var > &tmp, const char *first)
 
template<typename Type >
void prepareArg (std::vector< Poco::Dynamic::Var > &tmp, const Type &value)
 
void formatCollect (std::vector< Poco::Dynamic::Var > &)
 
template<typename First , typename... Rest>
void formatCollect (std::vector< Poco::Dynamic::Var > &tmp, const First &first, const Rest &...rest)
 
virtual std::string formatImpl (const std::string &key, const std::vector< Poco::Dynamic::Var > &args)=0
 
std::string formatFallback (const std::string &def, const std::vector< Poco::Dynamic::Var > &args) const
 

Member Function Documentation

template<typename... Rest>
std::string BeeeOn::Translator::format ( const std::string &  key,
const std::string &  def,
const Rest &...  rest 
)
inline

Format the message identified by given key. If the key is not found, it returns the given def formatted via formatFallback(). The method calls formatImpl internally.

string Translator::formatFallback ( const std::string &  def,
const std::vector< Poco::Dynamic::Var > &  args 
) const
protected

It uses the def as a fallback format. The fallback assumes using of the Poco::format() where the Poco::Dynamic::Var is converted to Poco::Any on fly.

virtual std::string BeeeOn::Translator::formatImpl ( const std::string &  key,
const std::vector< Poco::Dynamic::Var > &  args 
)
protectedpure virtual

Implements the actual key lookup and formatting.

Implemented in BeeeOn::NoTranslator.

template<typename... Rest>
std::string BeeeOn::Translator::formatSure ( const std::string &  key,
const Rest &...  rest 
)
inline

Format the message identified by given key. This method should be used only for translations where it is sure that the translation exists otherwise a messy string could be returned easily. The method calls formatImpl internally.

std::string BeeeOn::Translator::vformat ( const std::string &  key,
const std::string &  def,
const std::vector< Poco::Dynamic::Var > &  args 
)
inline

Format the message identified by given key. If the key is not found, it returns the given def formatted via formatFallback(). The method calls formatImpl internally.


The documentation for this class was generated from the following files: