GreekCasing.h (1547B)
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 6 #ifndef GreekCasing_h_ 7 #define GreekCasing_h_ 8 9 #include <stdint.h> 10 #include "mozilla/Attributes.h" 11 12 namespace mozilla { 13 14 class GreekCasing { 15 // When doing an Uppercase transform in Greek, we need to keep track of the 16 // current state while iterating through the string, to recognize and process 17 // diphthongs correctly. For clarity, we define a state for each vowel and 18 // each vowel with accent, although a few of these do not actually need any 19 // special treatment and could be folded into kStart. 20 private: 21 enum GreekStates { 22 kStart, 23 kInWord, 24 kAlpha, 25 kEpsilon, 26 kEta, 27 kIota, 28 kOmicron, 29 kUpsilon, 30 kOmega, 31 kAlphaAcc, 32 kEpsilonAcc, 33 kEtaAcc, 34 kEtaAccMarked, 35 kIotaAcc, 36 kOmicronAcc, 37 kUpsilonAcc, 38 kOmegaAcc, 39 kOmicronUpsilon, 40 kDiaeresis 41 }; 42 43 public: 44 class State { 45 public: 46 State() : mState(kStart) {} 47 48 MOZ_IMPLICIT State(const GreekStates& aState) : mState(aState) {} 49 50 void Reset() { mState = kStart; } 51 52 operator GreekStates() const { return mState; } 53 54 private: 55 GreekStates mState; 56 }; 57 58 static uint32_t UpperCase(uint32_t aCh, State& aState, bool& aMarkEtaPos, 59 bool& aUpdateMarkedEta); 60 }; 61 62 } // namespace mozilla 63 64 #endif