Пример #1
0
/* Check if input and last word is the same.
 * @param: ustring last_word - Ustring representation of the string last written by the user.
 * @return: int - Returns 0 on equal w/kanji, returns 1 on equal w/kana only, returns 2 on false w/kanji, returns 3 on false w/kana only.
 */
int Mode_eng_jap::equals(ustring lword) 
{
    if (kana(lword)) {
	ustring last_wd = last->get_wd2();//Get last corret word hir/kat
	if (lword.bytes() != last_wd.bytes()) return 3;
	const char* u_c_str = lword.c_str();
	const char* l_cor_c_str = last_wd.c_str();
	int place;
	for  (place = 0; (unsigned int) place < lword.bytes(); place++) {
	    if (u_c_str[place] != l_cor_c_str[place]) return 3;
	}
	return 1;

    } else {
	ustring last_wd_kji = last->get_wd2_alt(); //Get last corret Kanji
	if (lword.bytes() != last_wd_kji.bytes()) return 2;
	cout << "Checking Kanji" << endl;
	const char* u_c_str = lword.c_str();
	const char* l_cor_kji = last_wd_kji.c_str();

	int place;
	for (place = 0; (unsigned int) place < last_wd_kji.bytes(); place++) {
	    if (u_c_str[place] != l_cor_kji[place]) return 2;
	} 
	return 0;
    }    
}
Пример #2
0
/* Check if the in string contains kana characters only.
 * @param: ustring last_word - Ustring representation of the string last written by the user.
 * @return: boolean - contains only kana.
 */
bool Mode_eng_jap::kana(ustring lword)
{
    if ((lword.bytes()) % 3 == 0){
	const char * larr = lword.c_str();
	int x;
	for (x = 0; (unsigned int) x < lword.bytes(); x += 3) {
	    if ( ((int) larr[x]) != -29) return false;
	}
	return true;
    }
    return false;
}
Пример #3
0
void DataValue::parseStrList(const ustring &text, void *value) {
	int l = text.bytes();
	char *buf = new char[l+1], *sb = buf;
	strcpy(buf, text.c_str());
	if(*buf == '#') {
		buf++;
		if(*buf) {
			StringList list;
			do {
				int n = atoi(getTok(&buf, ':'));
				ustring s = ustring(buf, n);
				list << s;
				buf += s.bytes();	// data
				buf ++;		// | delimiter
			} while(*buf);
			*(ustring *)value = list;
		}
		else
			*(ustring *)value = "";
	}
	else {
		*(ustring *)value = buf;
	}

	delete sb;
}
Пример #4
0
void StringList::setText(const ustring &text)
{
    char *buf = new char[text.bytes() + 1], *sbuf = buf;
    strcpy(buf, text.c_str());

    loadFromChar(buf);

    delete[] sbuf;
}
Пример #5
0
void DataValue::parseFont(const ustring &text, void *value) {
	int l = text.bytes();
	char *buf = new char[l+1], *sb = buf;
	strcpy(buf, text.c_str());
	buf++;
	((FontRecord*)value)->name = getTok(&buf, ',');
	((FontRecord*)value)->size = atoi(getTok(&buf, ','));
	((FontRecord*)value)->style = atoi(getTok(&buf, ','));
	((FontRecord*)value)->color = atoi(getTok(&buf, ','));
	((FontRecord*)value)->charset = atoi(getTok(&buf, ']'));
	delete sb;
}