tagparser/localeawarestring.h

88 lines
1.9 KiB
C
Raw Normal View History

#ifndef TAG_PARSER_LOCALEAWARESTRING_H
#define TAG_PARSER_LOCALEAWARESTRING_H
2015-04-22 19:22:01 +02:00
2016-08-29 15:43:05 +02:00
#include "./global.h"
2015-04-22 19:22:01 +02:00
#include <string>
#include <vector>
namespace TagParser {
2015-04-22 19:22:01 +02:00
2015-11-10 21:27:40 +01:00
/*!
* \brief The LocaleAwareString class is a standard string with locale information (languages, countries).
*/
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT LocaleAwareString : public std::string {
2015-04-22 19:22:01 +02:00
public:
LocaleAwareString(const std::string &value = std::string());
2015-11-10 21:27:40 +01:00
LocaleAwareString(std::string &&value);
2015-04-22 19:22:01 +02:00
~LocaleAwareString();
const std::vector<std::string> &languages() const;
std::vector<std::string> &languages();
const std::vector<std::string> &countries() const;
std::vector<std::string> &countries();
private:
std::vector<std::string> m_languages;
2015-11-10 21:20:12 +01:00
std::vector<std::string> m_countries;
2015-04-22 19:22:01 +02:00
};
2015-11-10 21:27:40 +01:00
/*!
* \brief Constructs a new LocaleAwareString from the specified standard string.
*/
2018-03-07 01:17:50 +01:00
inline LocaleAwareString::LocaleAwareString(const std::string &value)
: std::string(value)
{
}
2015-04-22 19:22:01 +02:00
2015-11-10 21:27:40 +01:00
/*!
* \brief Constructs a new LocaleAwareString from the specified standard string.
*/
2018-03-07 01:17:50 +01:00
inline LocaleAwareString::LocaleAwareString(std::string &&value)
: std::string(value)
{
}
2015-11-10 21:27:40 +01:00
/*!
* \brief Destroys the instance.
*/
2015-04-22 19:22:01 +02:00
inline LocaleAwareString::~LocaleAwareString()
2018-03-07 01:17:50 +01:00
{
}
2015-04-22 19:22:01 +02:00
2015-11-10 21:27:40 +01:00
/*!
* \brief Returns associated languages.
*/
2015-04-22 19:22:01 +02:00
inline const std::vector<std::string> &LocaleAwareString::languages() const
{
return m_languages;
}
2015-11-10 21:27:40 +01:00
/*!
* \brief Returns associated languages.
*/
2015-04-22 19:22:01 +02:00
inline std::vector<std::string> &LocaleAwareString::languages()
{
return m_languages;
}
2015-11-10 21:27:40 +01:00
/*!
* \brief Returns associated countries.
*/
2015-04-22 19:22:01 +02:00
inline const std::vector<std::string> &LocaleAwareString::countries() const
{
2015-11-10 21:20:12 +01:00
return m_countries;
2015-04-22 19:22:01 +02:00
}
2015-11-10 21:27:40 +01:00
/*!
* \brief Returns associated countries.
*/
2015-04-22 19:22:01 +02:00
inline std::vector<std::string> &LocaleAwareString::countries()
{
2015-11-10 21:20:12 +01:00
return m_countries;
2015-04-22 19:22:01 +02:00
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser
2015-04-22 19:22:01 +02:00
#endif // TAG_PARSER_LOCALEAWARESTRING_H