Boost.Locale: boost/locale/gnu_gettext.hpp Source File

| Boost.Locale

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List

boost/locale/gnu_gettext.hpp

    00001 //
    00002 //  Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
    00003 //
    00004 //  Distributed under the Boost Software License, Version 1.0. (See
    00005 //  accompanying file LICENSE_1_0.txt or copy at
    00006 //  http://www.boost.org/LICENSE_1_0.txt)
    00007 //
    00008 #ifndef BOOST_LOCLAE_GNU_GETTEXT_HPP
    00009 #define BOOST_LOCLAE_GNU_GETTEXT_HPP
    00010
    00011 #include <boost/locale/message.hpp>
    00012 #include <boost/function.hpp>
    00013 #include <stdexcept>
    00014
    00015 namespace boost {
    00016 namespace locale {
    00019
    00020
    00024 namespace gnu_gettext {
    00025
    00034     struct messages_info {
    00035         messages_info() :
    00036             language("C"),
    00037             locale_category("LC_MESSAGES")
    00038         {
    00039         }
    00040
    00041         std::string language;
    00042         std::string country;
    00043         std::string variant;
    00044         std::string encoding;
    00045
    00046         std::string locale_category;
    00047
    00048
    00049
    00050
    00051
    00052
    00053
    00054
    00055         struct domain {
    00056
    00057             std::string name;
    00058             std::string encoding;
    00059             domain() {}
    00066             domain(std::string const &n)
    00067             {
    00068                 size_t pos = n.find("/");
    00069                 if(pos==std::string::npos) {
    00070                     name = n;
    00071                     encoding = "UTF-8";
    00072                 }
    00073                 else {
    00074                     name = n.substr(0,pos);
    00075                     encoding = n.substr(pos+1);
    00076                 }
    00077
    00078             }
    00079
    00083             bool operator==(domain const &other) const
    00084             {
    00085                 return name==other.name;
    00086             }
    00090             bool operator!=(domain const &other) const
    00091             {
    00092                 return !(*this==other);
    00093             }
    00094
    00095         };
    00096
    00097         typedef std::vector<domain> domains_type;
    00098
    00099         domains_type domains;
    00100
    00101         std::vector<std::string> paths;
    00102
    00103
    00114         typedef function<
    00115                     std::vector<char>(
    00116                         std::string const &file_name,
    00117                         std::string const &encoding
    00118                     )
    00119                 > callback_type;
    00120
    00125         callback_type callback;
    00126
    00127     };
    00128
    00133
    00134     template<typename CharType>
    00135     message_format<CharType> *create_messages_facet(messages_info const &info);
    00136
    00138
    00139     template<>
    00140     BOOST_LOCALE_DECL message_format<char> *create_messages_facet(messages_info const &info);
    00141
    00142     template<>
    00143     BOOST_LOCALE_DECL message_format<wchar_t> *create_messages_facet(messages_info const &info);
    00144
    00145     #ifdef BOOST_HAS_CHAR16_T
    00146     template<>
    00147     BOOST_LOCALE_DECL message_format<char16_t> *create_messages_facet(messages_info const &info);
    00148     #endif
    00149
    00150     #ifdef BOOST_HAS_CHAR32_T
    00151     template<>
    00152     BOOST_LOCALE_DECL message_format<char32_t> *create_messages_facet(messages_info const &info);
    00153     #endif
    00154
    00156
    00157 } // gnu_gettext
    00158
    00160
    00161 } // locale
    00162 } // boost
    00163
    00164 #endif
    00165
    00166 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
    00167