1 // -*- C++ -*- 2 /* GG is a GUI for OpenGL. 3 Copyright (C) 2003-2008 T. Zachary Laine 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public License 7 as published by the Free Software Foundation; either version 2.1 8 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with this library; if not, write to the Free 17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 02111-1307 USA 19 20 If you do not wish to comply with the terms of the LGPL please 21 contact the author as other terms are available for a fee. 22 23 Zach Laine 24 whatwasthataddress@gmail.com */ 25 26 /** \file UnicodeCharsets.h \brief Contains the UnicodeCharsets class, and 27 functions related to the character sets defined in the Unicode 28 standard. */ 29 30 #ifndef _UnicodeCharsets_h_ 31 #define _UnicodeCharsets_h_ 32 33 #include <GG/Base.h> 34 35 #include <set> 36 #include <vector> 37 38 39 namespace GG { 40 41 /** \brief Represents the name and character range of a set of Unicode 42 characters. 43 44 Such sets are known as "scripts" in Unicode parlance. Note that the last 45 character in the range is actually one past the last character, in the style 46 of the STL. */ 47 struct GG_API UnicodeCharset 48 { 49 UnicodeCharset(); 50 UnicodeCharset(std::string script_name, std::uint32_t first_char, std::uint32_t last_char); 51 52 std::string m_script_name; 53 std::uint32_t m_first_char; 54 std::uint32_t m_last_char; 55 }; 56 57 /** Returns true iff all of \a lhs's and \a rhs's members compare equal. */ 58 GG_API bool operator==(const UnicodeCharset& lhs, const UnicodeCharset& rhs); 59 60 /** Returns true iff \a lhs.m_first_char < \a rhs.m_first_char. */ 61 GG_API bool operator<(const UnicodeCharset& lhs, const UnicodeCharset& rhs); 62 63 64 /** Returns a vector containing all defined UnicodeCharset's. */ 65 GG_API const std::vector<UnicodeCharset>& AllUnicodeCharsets(); 66 67 /** Returns the set of the UnicodeCharset's required to render \a str. */ 68 GG_API std::set<UnicodeCharset> UnicodeCharsetsToRender(const std::string& str); 69 70 /** Returns the UnicodeCharset in which \a c can be found, or 0 if no such 71 UnicodeCharset exists. */ 72 GG_API const UnicodeCharset* CharsetContaining(std::uint32_t c); 73 74 /** Returns the UnicodeCharset called \a name, or 0 if no such UnicodeCharset 75 exists. */ 76 GG_API const UnicodeCharset* CharsetWithName(const std::string& name); 77 78 } // namespace GG 79 80 #endif 81