GreekCasing.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef GreekCasing_h_
  6. #define GreekCasing_h_
  7. #include <stdint.h>
  8. #include "mozilla/Attributes.h"
  9. namespace mozilla {
  10. class GreekCasing {
  11. // When doing an Uppercase transform in Greek, we need to keep track of the
  12. // current state while iterating through the string, to recognize and process
  13. // diphthongs correctly. For clarity, we define a state for each vowel and
  14. // each vowel with accent, although a few of these do not actually need any
  15. // special treatment and could be folded into kStart.
  16. private:
  17. enum GreekStates {
  18. kStart,
  19. kAlpha,
  20. kEpsilon,
  21. kEta,
  22. kIota,
  23. kOmicron,
  24. kUpsilon,
  25. kOmega,
  26. kAlphaAcc,
  27. kEpsilonAcc,
  28. kEtaAcc,
  29. kIotaAcc,
  30. kOmicronAcc,
  31. kUpsilonAcc,
  32. kOmegaAcc,
  33. kOmicronUpsilon,
  34. kDiaeresis
  35. };
  36. public:
  37. class State {
  38. public:
  39. State()
  40. : mState(kStart)
  41. {
  42. }
  43. MOZ_IMPLICIT State(const GreekStates& aState)
  44. : mState(aState)
  45. {
  46. }
  47. void Reset()
  48. {
  49. mState = kStart;
  50. }
  51. operator GreekStates() const
  52. {
  53. return mState;
  54. }
  55. private:
  56. GreekStates mState;
  57. };
  58. static uint32_t UpperCase(uint32_t aCh, State& aState);
  59. };
  60. } // namespace mozilla
  61. #endif