Mandarin // Indentation Changes to Xcode Default.

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

View File

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

View File

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