UnicodeRange.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #ifndef ROCKETCOREUNICODERANGE_H
  28. #define ROCKETCOREUNICODERANGE_H
  29. namespace Rocket {
  30. namespace Core {
  31. class UnicodeRange;
  32. typedef std::vector< UnicodeRange > UnicodeRangeList;
  33. /**
  34. */
  35. class UnicodeRange
  36. {
  37. public:
  38. UnicodeRange();
  39. UnicodeRange(int min_codepoint, int max_codepoint);
  40. /// Initialises the range from a unicode range in string form.
  41. /// @param[in] unicode_range The string specified the unicode range.
  42. /// @return True if the range is valid, false otherwise.
  43. bool Initialise(const String& unicode_range);
  44. /// Builds up a list of unicode ranges from a comma-separated list of unicode ranges in string form.
  45. /// @param[out] list The returned list.
  46. /// @param[in] unicode_range The comma-separated list of unicode ranges.
  47. /// @return True if all values were parsed successfully and at least one value is returned in the list, false otherwise.
  48. static bool BuildList(UnicodeRangeList& list, const String& unicode_range);
  49. /// Returns true if this range is wholly contained within another range.
  50. /// @param[in] rhs The range to check against.
  51. bool IsContained(const UnicodeRange& rhs);
  52. /// Returns true if this range is wholly contained within another range list.
  53. /// @param[in] rhs The range list to check against.
  54. bool IsContained(const UnicodeRangeList& rhs);
  55. /// Returns true if this range is contained or contiguous with another range.
  56. /// @param[in] rhs The range to check against.
  57. /// @return True if the ranges are contiguous, false otherwise.
  58. bool IsContiguous(const UnicodeRange& rhs);
  59. /// Joins this range with another that it is contiguous with.
  60. /// @param[in] rhs The range to join with this range.
  61. /// @return The new, joined, range containing both the original ranges.
  62. UnicodeRange Join(const UnicodeRange& rhs);
  63. unsigned int min_codepoint;
  64. unsigned int max_codepoint;
  65. };
  66. }
  67. }
  68. #endif