Aegisub/devel/kanamemo/kana_table.cpp
Amar Takhar aa506bfe40 SVN Transition Step 6/7
1. svn mv OverLua SSATool athenasub avisynth_prs kanamemo \
     motiontracker prs traydict unit_test vsfilter devel/

* See r2749 for full description.

Originally committed to SVN as r2755.
2009-03-08 08:31:54 +00:00

294 lines
7.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (c) 2006, Rodrigo Braz Monteiro
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Aegisub Group nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// -----------------------------------------------------------------------------
//
// AEGISUB
//
// Website: http://aegisub.cellosoft.com
// Contact: mailto:zeratul@cellosoft.com
//
///////////
// Headers
#include "kana_table.h"
///////////////
// Constructor
KanaTable::KanaTable() {
level = 0;
groups[0] = 0;
groups[1] = 0;
BeginGroup();
Insert(L"",L"",L"a");
Insert(L"",L"",L"i");
Insert(L"",L"",L"u");
Insert(L"",L"",L"e");
Insert(L"",L"",L"o");
BeginGroup();
Insert(L"",L"",L"ka");
Insert(L"",L"",L"ki");
Insert(L"",L"",L"ku");
Insert(L"",L"",L"ke");
Insert(L"",L"",L"ko");
BeginGroup();
Insert(L"",L"",L"sa");
Insert(L"",L"",L"shi");
Insert(L"",L"",L"su");
Insert(L"",L"",L"se");
Insert(L"",L"",L"so");
BeginGroup();
Insert(L"",L"",L"ta");
Insert(L"",L"",L"chi");
Insert(L"",L"",L"tsu");
Insert(L"",L"",L"te");
Insert(L"",L"",L"to");
BeginGroup();
Insert(L"",L"",L"na");
Insert(L"",L"",L"ni");
Insert(L"",L"",L"nu");
Insert(L"",L"",L"ne");
Insert(L"",L"",L"no");
BeginGroup();
Insert(L"",L"",L"ha");
Insert(L"",L"",L"hi");
Insert(L"",L"",L"fu");
Insert(L"",L"",L"he");
Insert(L"",L"",L"ho");
BeginGroup();
Insert(L"",L"",L"ma");
Insert(L"",L"",L"mi");
Insert(L"",L"",L"mu");
Insert(L"",L"",L"me");
Insert(L"",L"",L"mo");
BeginGroup();
Insert(L"",L"",L"ya");
Insert(L"",L"",L"yu");
Insert(L"",L"",L"yo");
BeginGroup();
Insert(L"",L"",L"ra");
Insert(L"",L"",L"ri");
Insert(L"",L"",L"ru");
Insert(L"",L"",L"re");
Insert(L"",L"",L"ro");
BeginGroup();
Insert(L"",L"",L"wa");
Insert(L"",L"",L"wo");
BeginGroup();
level--;
Insert(L"",L"",L"n");
BeginGroup();
Insert(L"",L"",L"ga");
Insert(L"",L"",L"gi");
Insert(L"",L"",L"gu");
Insert(L"",L"",L"ge");
Insert(L"",L"",L"go");
BeginGroup();
Insert(L"",L"",L"za");
Insert(L"",L"",L"ji");
Insert(L"",L"",L"zu");
Insert(L"",L"",L"ze");
Insert(L"",L"",L"zo");
BeginGroup();
Insert(L"",L"",L"da");
Insert(L"",L"",L"ji");
Insert(L"",L"",L"zu");
Insert(L"",L"",L"de");
Insert(L"",L"",L"do");
BeginGroup();
Insert(L"",L"",L"ba");
Insert(L"",L"",L"bi");
Insert(L"",L"",L"bu");
Insert(L"",L"",L"be");
Insert(L"",L"",L"bo");
BeginGroup();
Insert(L"",L"",L"pa");
Insert(L"",L"",L"pi");
Insert(L"",L"",L"pu");
Insert(L"",L"",L"pe");
Insert(L"",L"",L"po");
BeginGroup();
Insert(L"きゃ",L"キャ",L"kya");
Insert(L"きゅ",L"キュ",L"kyu");
Insert(L"きょ",L"キョ",L"kyo");
BeginGroup();
Insert(L"しゃ",L"シャ",L"sha");
Insert(L"しゅ",L"シュ",L"shu");
Insert(L"しょ",L"ショ",L"sho");
BeginGroup();
Insert(L"ちゃ",L"チャ",L"cha");
Insert(L"ちゅ",L"チュ",L"chu");
Insert(L"ちょ",L"チョ",L"cho");
BeginGroup();
Insert(L"にゃ",L"ニャ",L"nya");
Insert(L"にゅ",L"ニュ",L"nyu");
Insert(L"にょ",L"ニョ",L"nyo");
BeginGroup();
Insert(L"ひゃ",L"ヒャ",L"hya");
Insert(L"ひゅ",L"ヒュ",L"hyu");
Insert(L"ひょ",L"ヒョ",L"hyo");
BeginGroup();
Insert(L"みゃ",L"ミャ",L"mya");
Insert(L"みゅ",L"ミュ",L"myu");
Insert(L"みょ",L"ミョ",L"myo");
BeginGroup();
Insert(L"りゃ",L"リャ",L"rya");
Insert(L"りゅ",L"リュ",L"ryu");
Insert(L"りょ",L"リョ",L"ryo");
BeginGroup();
Insert(L"ぎゃ",L"ギャ",L"gya");
Insert(L"ぎゅ",L"ギュ",L"gyu");
Insert(L"ぎょ",L"ギョ",L"gyo");
BeginGroup();
Insert(L"じゃ",L"ジャ",L"ja");
Insert(L"じゅ",L"ジュ",L"ju");
Insert(L"じょ",L"ジョ",L"jo");
BeginGroup();
Insert(L"ぢゃ",L"ヂャ",L"ja");
Insert(L"ぢゅ",L"ヂュ",L"ju");
Insert(L"ぢょ",L"ヂョ",L"jo");
BeginGroup();
Insert(L"びゃ",L"ビャ",L"bya");
Insert(L"びゅ",L"ビュ",L"byu");
Insert(L"びょ",L"ビョ",L"byo");
BeginGroup();
Insert(L"ぴゃ",L"ピャ",L"pya");
Insert(L"ぴゅ",L"ピュ",L"pyu");
Insert(L"ぴょ",L"ピョ",L"pyo");
BeginGroup();
Insert(L"",L"ファ",L"fa");
Insert(L"",L"フィ",L"fi");
Insert(L"",L"フェ",L"fe");
Insert(L"",L"フォ",L"fo");
BeginGroup();
Insert(L"",L"ヴァ",L"va");
Insert(L"",L"ヴィ",L"vi");
Insert(L"",L"",L"vu");
Insert(L"",L"ヴェ",L"ve");
Insert(L"",L"ヴォ",L"vo");
}
//////////////
// Destructor
KanaTable::~KanaTable() {
}
///////////////
// Begin group
void KanaTable::BeginGroup() {
curGroup = _T("");
level++;
}
//////////
// Insert
void KanaTable::Insert(wchar_t *hira,wchar_t *kata,wchar_t *hep) {
#ifdef _UNICODE
KanaEntry entry(hira,kata,hep);
if (curGroup.IsEmpty()) curGroup = hep;
entry.group = curGroup;
entry.level = level;
if (!entry.hiragana.IsEmpty() && level > groups[0]) groups[0] = level;
if (!entry.katakana.IsEmpty() && level > groups[1]) groups[1] = level;
entries.push_back(entry);
#endif
}
/////////////////////
// Number of entries
int KanaTable::GetNumberEntries(int level) const {
if (level == -1) return entries.size();
else {
int count = 0;
int n = entries.size();
for (int i=0;i<n;i++) {
if (entries[i].level <= level) count++;
}
return count;
}
}
////////////////////////
// Get a specific entry
const KanaEntry &KanaTable::GetEntry(int i) const {
return entries.at(i);
}
//////////////////////////
// Find a specific romaji
const KanaEntry *KanaTable::FindByRomaji(wxString romaji) const {
int n = entries.size();
for (int i=0;i<n;i++) {
if (entries[i].hepburn == romaji) return &entries[i];
}
return NULL;
}
/////////////////////////////////////////////
// Get number of levels for a specific table
int KanaTable::GetLevels(int table) const {
return groups[table];
}