本文整理汇总了C++中WideString::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ WideString::push_back方法的具体用法?C++ WideString::push_back怎么用?C++ WideString::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WideString
的用法示例。
在下文中一共展示了WideString::push_back方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
WideString
utf8_read_wstring (std::istream &is, ucs4_t delim, bool rm_delim)
{
WideString str;
ucs4_t wc;
while ((wc = utf8_read_wchar (is)) > 0) {
if (wc != delim)
str.push_back (wc);
else {
if (!rm_delim)
str.push_back (wc);
break;
}
}
return str;
}
示例2:
void
ArrayInstance::create_lookup_table_labels(int page_size)
{
WideString trail;
trail.push_back(0x20);
m_lookup_table_labels.clear();
for (int i = 0; i < page_size; i++)
{
trail [0] = (ucs4_t) int_to_ascii ((i % 10) + 1);
if ((i % 10) >= 9)
trail [0] = (ucs4_t) int_to_ascii (0);
m_lookup_table_labels.push_back(trail);
}
}
示例3: beep
bool
ThaiInstance::process_key_event (const KeyEvent& key)
{
if (key.is_key_release()
|| key.code == 0
|| __is_context_intact_key (key.code))
{
return false;
}
if (key.mask & (SCIM_KEY_AllMasks
& ~(SCIM_KEY_ShiftMask | SCIM_KEY_CapsLockMask)) ||
__is_context_lost_key (key.code))
{
_forget_previous_chars ();
return false;
}
KeyEvent thai_key = m_keymap.map_key (key);
ucs4_t thai_uni = thai_key.get_unicode_code ();
if (!th_wcistis (thai_uni))
return false;
thchar_t thai_tis = th_uni2tis (thai_uni);
thcell_t context_cell = _get_previous_cell ();
thinpconv_t conv;
if (th_validate (context_cell, thai_tis, &conv))
{
if (conv.offset < 0)
if (!delete_surrounding_text (conv.offset, -conv.offset))
return false;
_forget_previous_chars ();
_remember_previous_char (thai_tis);
WideString str;
for (int i = 0; conv.conv [i]; i++)
str.push_back (th_tis2uni (conv.conv [i]));
commit_string (str);
}
else
{
beep ();
}
return true;
}
示例4: while
void
HangulInstance::flush()
{
SCIM_DEBUG_IMENGINE(2) << "flush.\n";
hide_preedit_string();
WideString wstr = m_preedit;
const ucschar *str = hangul_ic_flush(m_hic);
while (*str != 0)
wstr.push_back (*str++);
if (wstr.length())
commit_string(wstr);
delete_candidates ();
m_preedit.clear();
}
示例5: createDirectoryRecursive
//--------------------------------
bool Utils::createDirectoryRecursive( const WideString &pathString )
{
if (pathString.length() == 0)
return false;
WideString path = pathString;
if (path[path.length()-1] != '/' && path[path.length()-1] != '\\')
path.push_back('\\');
std::list<WideString> paths;
size_t offset = WideString::npos;
while ((offset != 0) && (offset = pathString.find_last_of(L"/\\", offset)) != WideString::npos)
{
paths.push_front(pathString.substr(0, offset + 1));
if (offset != 0) --offset;
}
bool pathExists = true;
const wchar_t* currentPath = _wgetcwd(0, 0);
for (std::list<WideString>::const_iterator iPath = paths.begin(); iPath != paths.end(); ++iPath)
{
// if path exists
if (_wchdir((*iPath).c_str()) == 0)
continue;
// path does not exist, try to create it
_wmkdir((*iPath).c_str());
if (_wchdir((*iPath).c_str()) != 0)
{
pathExists = false;
break;
}
}
// Restore current path
_wchdir(currentPath);
return pathExists;
}
示例6: self_learn
void self_learn (GenericTableLibrary &lib, const char *file)
{
std::vector <ucs4_t> buffer;
std::ifstream ifs(file);
if (!ifs) return;
uint32 byte = 0;
uint32 kb = 0;
WideString str;
std::vector <uint32> phrases;
std::vector <uint32>::const_iterator pit;
uint32 maxlen = lib.get_max_phrase_length ();
ucs4_t wc;
bool skip;
char wheel [] = {'-', '\\', '|', '/', 0};
int wheel_state;
buffer.reserve (1048576*32);
skip = false;
wheel_state = 0;
while (!ifs.eof()) {
buffer.clear ();
// Read a line
while (!ifs.eof ()) {
if ((wc = utf8_read_wchar (ifs)) == 0) break;
if (wc == L'\n') break;
else if (iswpunct (wc) || iswspace (wc) || iswdigit (wc) ) {
if (!skip) {
buffer.push_back (0);
skip = true;
}
} else {
buffer.push_back (wc);
skip = false;
}
}
buffer.push_back (0);
for (int i=0; i<buffer.size (); i++) {
str = WideString ();
for (int j=0; j<maxlen; j++) {
if (buffer [j+i] == 0)
break;
str.push_back (buffer [j+i]);
phrases.clear ();
if (lib.find_phrase (phrases, str)) {
for (pit = phrases.begin (); pit != phrases.end (); ++ pit)
lib.set_phrase_frequency (*pit, lib.get_phrase_frequency (*pit) + 1);
}
}
byte ++;
if (byte == 1024) {
byte = 0;
kb ++;
std::cout << "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
std::cout << kb << "\tK ("
<< wheel [wheel_state/2] << ") " << std::flush;
wheel_state = (wheel_state+1) % 8;
}
}
}
std::cout << std::endl;
}
示例7: while
bool
ComposeKeyInstance::process_key_event (const KeyEvent& key)
{
if (key.is_key_release ()) return false;
// Ignore modifier key presses.
if (std::binary_search (__scim_compose_ignores, __scim_compose_ignores + SCIM_NUM_COMPOSE_IGNORES, (uint16) key.code))
return false;
// Ignore the key if ctrl or alt is down.
if (key.is_control_down () || key.is_alt_down ())
return false;
int n_compose = 0;
while (m_compose_buffer [n_compose] != 0 && n_compose < SCIM_MAX_COMPOSE_LEN)
++ n_compose;
// The buffer is full, then reset the buffer first.
if (n_compose == SCIM_MAX_COMPOSE_LEN) {
reset ();
n_compose = 0;
}
m_compose_buffer [n_compose] = (uint32) key.code;
const ComposeSequence *it = std::lower_bound (__scim_compose_seqs,
__scim_compose_seqs + SCIM_NUM_COMPOSE_SEQS,
m_compose_buffer,
ComposeSequenceLessByKeys ());
// Not result found, reset the buffer and return false.
if (it == __scim_compose_seqs + SCIM_NUM_COMPOSE_SEQS) {
reset ();
return false;
}
// Check if the compose sequence is match.
for (n_compose = 0; n_compose < SCIM_MAX_COMPOSE_LEN; ++ n_compose) {
if (m_compose_buffer [n_compose] == 0)
break;
// Not match, reset the buffer and return.
// If it's the first key press, then return false to forward it.
// Otherwise return true to ignore it.
if (m_compose_buffer [n_compose] != it->keys [n_compose]) {
reset ();
return n_compose != 0;
}
}
// Match exactly, commit the result.
if (n_compose == SCIM_MAX_COMPOSE_LEN || it->keys [n_compose] == 0) {
WideString wstr;
wstr.push_back (it->unicode);
commit_string (wstr);
reset ();
}
return true;
}
示例8: hasWildcard
int
ArrayInstance::create_lookup_table (int mapSelect)
{
String mbs_code;
ucs4_t ucs_code;
WideString trail;
WideString wstr;
m_lookup_table.clear ();
m_lookup_table_labels.clear ();
trail.push_back(0x20);
bool isHaveWildcard = false;
isHaveWildcard = hasWildcard(m_preedit_string);
vector<string> candidatesVec;
int rcount = 0;
if (isHaveWildcard)
{
rcount = m_factory->arrayCins[mapSelect]->getWordsVectorWithWildcard(
utf8_wcstombs(m_preedit_string), candidatesVec);
}
else
{
rcount = m_factory->arrayCins[mapSelect]->getWordsVector(
utf8_wcstombs(m_preedit_string), candidatesVec);
}
if (rcount)
{
for (int i = 0; i < candidatesVec.size(); i++)
{
trail [0] = (ucs4_t) int_to_ascii ((i % 10) + 1);
if ((i % 10) >= 9)
trail [0] = (ucs4_t) int_to_ascii (0);
m_lookup_table.append_candidate(utf8_mbstowcs(candidatesVec[i]));
m_lookup_table_labels.push_back(trail);
}
}
else
{
trail [0] = (ucs4_t) int_to_ascii (0);
m_lookup_table.append_candidate(utf8_mbstowcs(SCIM_ARRAY_EMPTY_CHAR));
m_lookup_table_labels.push_back(trail);
}
if (m_lookup_table_labels.size() <= 10)
m_lookup_table.set_page_size (m_lookup_table_labels.size());
else
m_lookup_table.set_page_size(10);
if (mapSelect == _ScimArray::Array_Phrases)
{
m_lookup_table.fix_page_size(false);
}
create_lookup_table_labels(m_lookup_table.get_current_page_size());
m_lookup_table.set_candidate_labels (m_lookup_table_labels);
return m_lookup_table_labels.size ();
}
示例9: reset
bool
ArrayInstance::process_key_event (const KeyEvent& rawkey)
{
KeyEvent key = rawkey.map_to_layout(SCIM_KEYBOARD_Default);
if (key.is_key_release ()) return false;
// English/Chinese change mode key
if ( match_key_event(m_factory->m_ench_key, key))
{
trigger_property(SCIM_PROP_STATUS);
return true;
}
// Full/Half width chang mode key
if ( match_key_event(m_factory->m_full_half_key, key))
{
trigger_property(SCIM_PROP_LETTER);
return true;
}
// if in forward mode
if (m_forward)
{
if ( key.code >= SCIM_KEY_space && key.code <= SCIM_KEY_asciitilde)
{
if (m_full_width_letter)
{
char widthc = key.get_ascii_code();
WideString outws;
outws.push_back(scim_wchar_to_full_width(widthc));
commit_string(outws);
return true;
}
else
return false;
}
else
return false;
}
//reset key
if (key.code == SCIM_KEY_Escape && key.mask == 0) {
// Do not catch ESC while no key input for VI users
if (m_preedit_string.size() == 0)
return false;
reset ();
return true;
}
//delete key
if (key.code == SCIM_KEY_BackSpace && key.mask == 0 &&
m_preedit_string.size () != 0)
{
m_preedit_string.erase (m_preedit_string.length () - 1, 1);
pre_update_preedit_string (m_preedit_string);
process_preedit_string ();
commit_press_count = 0; // reset to 0 to avoid output error
return true;
}
// valid keys
if (((key.code >= SCIM_KEY_a && key.code <= SCIM_KEY_z) ||
(key.code == SCIM_KEY_comma) || (key.code == SCIM_KEY_period) ||
(key.code == SCIM_KEY_semicolon) || (key.code == SCIM_KEY_slash))
&&
(key.mask == 0))
{
if (m_preedit_string.length () >= m_max_preedit_len)
return true;
if (commit_press_count == 1)
{
WideString str = m_lookup_table.get_candidate_in_current_page (0);
if (str.length() && str.compare(utf8_mbstowcs(SCIM_ARRAY_EMPTY_CHAR)) != 0 ) {
send_commit_string(m_preedit_string,
m_lookup_table.get_candidate_in_current_page(0));
}
else
reset();
}
if (m_preedit_string.length () == 0)
{
hide_aux_string ();
show_preedit_string ();
}
ucs4_t ascii = (ucs4_t) tolower (key.get_ascii_code ());
m_preedit_string.push_back (ascii);
pre_update_preedit_string (m_preedit_string);
process_preedit_string ();
return true;
}
// apostrophe key for end of phrases
if (m_use_phrases && key.code == SCIM_KEY_apostrophe
&& m_preedit_string.length())
{
//.........这里部分代码省略.........