Mandarin // Indentation Changes to Xcode Default.

This commit is contained in:
ShikiSuen 2022-02-11 18:39:28 +08:00
parent e502daf3b3
commit 78047c9c2e
2 changed files with 1573 additions and 1573 deletions

View File

@ -26,7 +26,7 @@ namespace Taiyan {
namespace Mandarin { namespace Mandarin {
class PinyinParseHelper { class PinyinParseHelper {
public: public:
static const bool ConsumePrefix(std::string& target, static const bool ConsumePrefix(std::string& target,
const std::string& prefix) { const std::string& prefix) {
if (target.length() < prefix.length()) { if (target.length() < prefix.length()) {
@ -44,13 +44,13 @@ class PinyinParseHelper {
}; };
class BopomofoCharacterMap { class BopomofoCharacterMap {
public: public:
static const BopomofoCharacterMap& SharedInstance(); static const BopomofoCharacterMap& SharedInstance();
std::map<BPMF::Component, std::string> componentToCharacter; std::map<BPMF::Component, std::string> componentToCharacter;
std::map<std::string, BPMF::Component> characterToComponent; std::map<std::string, BPMF::Component> characterToComponent;
protected: protected:
BopomofoCharacterMap(); BopomofoCharacterMap();
}; };
@ -733,9 +733,9 @@ const BPMF BPMF::FromPHT(const std::string& str) {
BPMF::Component toneComponent = 0; BPMF::Component toneComponent = 0;
#define IF_CONSUME1(k, v) \ #define IF_CONSUME1(k, v) \
else if (PinyinParseHelper::ConsumePrefix(pht, k)) { \ else if (PinyinParseHelper::ConsumePrefix(pht, k)) { \
firstComponent = v; \ firstComponent = v; \
} }
// consume the first part // consume the first part
if (0) { if (0) {
@ -761,9 +761,9 @@ const BPMF BPMF::FromPHT(const std::string& str) {
IF_CONSUME1("h", BPMF::H) IF_CONSUME1("h", BPMF::H)
#define IF_CONSUME2(k, v) \ #define IF_CONSUME2(k, v) \
else if (PinyinParseHelper::ConsumePrefix(pht, k)) { \ else if (PinyinParseHelper::ConsumePrefix(pht, k)) { \
secondComponent = v; \ secondComponent = v; \
} }
// consume the second part // consume the second part
if (0) { if (0) {
} else if (PinyinParseHelper::ConsumePrefix(pht, "ing")) { } else if (PinyinParseHelper::ConsumePrefix(pht, "ing")) {
@ -920,11 +920,11 @@ const BPMF BPMF::FromComposedString(const std::string& str) {
const std::string BPMF::composedString() const { const std::string BPMF::composedString() const {
std::string result; std::string result;
#define APPEND(c) \ #define APPEND(c) \
if (syllable_ & c) \ if (syllable_ & c) \
result += \ result += \
(*BopomofoCharacterMap::SharedInstance().componentToCharacter.find( \ (*BopomofoCharacterMap::SharedInstance().componentToCharacter.find( \
syllable_ & c)) \ syllable_ & c)) \
.second .second
APPEND(ConsonantMask); APPEND(ConsonantMask);
APPEND(MiddleVowelMask); APPEND(MiddleVowelMask);
APPEND(VowelMask); APPEND(VowelMask);
@ -990,14 +990,14 @@ BopomofoCharacterMap::BopomofoCharacterMap() {
} }
#define ASSIGNKEY1(m, vec, k, val) \ #define ASSIGNKEY1(m, vec, k, val) \
m[k] = (vec.clear(), vec.push_back((BPMF::Component)val), vec) m[k] = (vec.clear(), vec.push_back((BPMF::Component)val), vec)
#define ASSIGNKEY2(m, vec, k, val1, val2) \ #define ASSIGNKEY2(m, vec, k, val1, val2) \
m[k] = (vec.clear(), vec.push_back((BPMF::Component)val1), \ m[k] = (vec.clear(), vec.push_back((BPMF::Component)val1), \
vec.push_back((BPMF::Component)val2), vec) vec.push_back((BPMF::Component)val2), vec)
#define ASSIGNKEY3(m, vec, k, val1, val2, val3) \ #define ASSIGNKEY3(m, vec, k, val1, val2, val3) \
m[k] = (vec.clear(), vec.push_back((BPMF::Component)val1), \ m[k] = (vec.clear(), vec.push_back((BPMF::Component)val1), \
vec.push_back((BPMF::Component)val2), \ vec.push_back((BPMF::Component)val2), \
vec.push_back((BPMF::Component)val3), vec) vec.push_back((BPMF::Component)val3), vec)
static BopomofoKeyboardLayout* CreateStandardLayout() { static BopomofoKeyboardLayout* CreateStandardLayout() {
std::vector<BPMF::Component> vec; std::vector<BPMF::Component> vec;
@ -1249,3 +1249,4 @@ const BopomofoKeyboardLayout* BopomofoKeyboardLayout::HanyuPinyinLayout() {
} // namespace Mandarin } // namespace Mandarin
} // namespace Taiyan } // namespace Taiyan

View File

@ -29,7 +29,7 @@ namespace Taiyan {
namespace Mandarin { namespace Mandarin {
class BopomofoSyllable { class BopomofoSyllable {
public: public:
typedef uint16_t Component; typedef uint16_t Component;
explicit BopomofoSyllable(Component syllable = 0) : syllable_(syllable) {} explicit BopomofoSyllable(Component syllable = 0) : syllable_(syllable) {}
@ -116,9 +116,9 @@ class BopomofoSyllable {
const BopomofoSyllable operator+(const BopomofoSyllable& another) const { const BopomofoSyllable operator+(const BopomofoSyllable& another) const {
Component newSyllable = syllable_; Component newSyllable = syllable_;
#define OP_SOVER(mask) \ #define OP_SOVER(mask) \
if (another.syllable_ & mask) { \ if (another.syllable_ & mask) { \
newSyllable = (newSyllable & ~mask) | (another.syllable_ & mask); \ newSyllable = (newSyllable & ~mask) | (another.syllable_ & mask); \
} }
OP_SOVER(ConsonantMask); OP_SOVER(ConsonantMask);
OP_SOVER(MiddleVowelMask); OP_SOVER(MiddleVowelMask);
OP_SOVER(VowelMask); OP_SOVER(VowelMask);
@ -129,9 +129,9 @@ class BopomofoSyllable {
BopomofoSyllable& operator+=(const BopomofoSyllable& another) { BopomofoSyllable& operator+=(const BopomofoSyllable& another) {
#define OPE_SOVER(mask) \ #define OPE_SOVER(mask) \
if (another.syllable_ & mask) { \ if (another.syllable_ & mask) { \
syllable_ = (syllable_ & ~mask) | (another.syllable_ & mask); \ syllable_ = (syllable_ & ~mask) | (another.syllable_ & mask); \
} }
OPE_SOVER(ConsonantMask); OPE_SOVER(ConsonantMask);
OPE_SOVER(MiddleVowelMask); OPE_SOVER(MiddleVowelMask);
OPE_SOVER(VowelMask); OPE_SOVER(VowelMask);
@ -191,7 +191,7 @@ class BopomofoSyllable {
ENG = 0x0600, ERR = 0x0680, Tone1 = 0x0000, Tone2 = 0x0800, ENG = 0x0600, ERR = 0x0680, Tone1 = 0x0000, Tone2 = 0x0800,
Tone3 = 0x1000, Tone4 = 0x1800, Tone5 = 0x2000; Tone3 = 0x1000, Tone4 = 0x1800, Tone5 = 0x2000;
protected: protected:
Component syllable_; Component syllable_;
}; };
@ -207,7 +207,7 @@ typedef std::map<char, std::vector<BPMF::Component> > BopomofoKeyToComponentMap;
typedef std::map<BPMF::Component, char> BopomofoComponentToKeyMap; typedef std::map<BPMF::Component, char> BopomofoComponentToKeyMap;
class BopomofoKeyboardLayout { class BopomofoKeyboardLayout {
public: public:
static const BopomofoKeyboardLayout* StandardLayout(); static const BopomofoKeyboardLayout* StandardLayout();
static const BopomofoKeyboardLayout* ETenLayout(); static const BopomofoKeyboardLayout* ETenLayout();
static const BopomofoKeyboardLayout* HsuLayout(); static const BopomofoKeyboardLayout* HsuLayout();
@ -247,9 +247,9 @@ class BopomofoKeyboardLayout {
BPMF::Component c; BPMF::Component c;
char k; char k;
#define STKS_COMBINE(component) \ #define STKS_COMBINE(component) \
if ((c = component)) { \ if ((c = component)) { \
if ((k = componentToKey(c))) sequence += std::string(1, k); \ if ((k = componentToKey(c))) sequence += std::string(1, k); \
} }
STKS_COMBINE(syllable.consonantComponent()); STKS_COMBINE(syllable.consonantComponent());
STKS_COMBINE(syllable.middleVowelComponent()); STKS_COMBINE(syllable.middleVowelComponent());
STKS_COMBINE(syllable.vowelComponent()); STKS_COMBINE(syllable.vowelComponent());
@ -361,7 +361,7 @@ class BopomofoKeyboardLayout {
return syllable; return syllable;
} }
protected: protected:
bool endAheadOrAheadHasToneMarkKey(std::string::const_iterator ahead, bool endAheadOrAheadHasToneMarkKey(std::string::const_iterator ahead,
std::string::const_iterator end) const { std::string::const_iterator end) const {
if (ahead == end) return true; if (ahead == end) return true;
@ -398,7 +398,7 @@ class BopomofoKeyboardLayout {
}; };
class BopomofoReadingBuffer { class BopomofoReadingBuffer {
public: public:
explicit BopomofoReadingBuffer(const BopomofoKeyboardLayout* layout) explicit BopomofoReadingBuffer(const BopomofoKeyboardLayout* layout)
: layout_(layout), pinyin_mode_(false) { : layout_(layout), pinyin_mode_(false) {
if (layout == BopomofoKeyboardLayout::HanyuPinyinLayout()) { if (layout == BopomofoKeyboardLayout::HanyuPinyinLayout()) {
@ -494,8 +494,7 @@ class BopomofoReadingBuffer {
const BPMF syllable() const { return syllable_; } const BPMF syllable() const { return syllable_; }
const std::string standardLayoutQueryString() const { const std::string standardLayoutQueryString() const {
return BopomofoKeyboardLayout::StandardLayout()->keySequenceFromSyllable( return BopomofoKeyboardLayout::StandardLayout()->keySequenceFromSyllable(syllable_);
syllable_);
} }
const std::string absoluteOrderQueryString() const { const std::string absoluteOrderQueryString() const {
@ -504,7 +503,7 @@ class BopomofoReadingBuffer {
bool hasToneMarker() const { return syllable_.hasToneMarker(); } bool hasToneMarker() const { return syllable_.hasToneMarker(); }
protected: protected:
const BopomofoKeyboardLayout* layout_; const BopomofoKeyboardLayout* layout_;
BPMF syllable_; BPMF syllable_;