wxString wxWidgetsGUI::GetAppClassName(const wxString& Source,wxsCodingLang Lang) { switch ( Lang ) { case wxsCPP: { // Doing some trick - searching for IMPLEMENT_APP macro followed // by '(' and class name - here we can fetch name of application class int Pos = Source.Find(_T("IMPLEMENT_APP")); if ( Pos<0 ) return wxEmptyString; Pos += 13;// strlen("IMPLEMENT_APP") while ( IsWhite(Source,Pos) ) Pos++; if ( Pos >= (int)Source.Length() ) return wxEmptyString; if ( Source[Pos++] != _T('(') ) return wxEmptyString; while ( IsWhite(Source,Pos) ) Pos++; wxString ClassName; static const wxString AllowedChars(_T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_")); while ( (Pos < (int)Source.Length()) && (AllowedChars.Find(Source[Pos])>=0) ) { ClassName += Source[Pos]; Pos++; } while ( IsWhite(Source,Pos) ) Pos++; if ( Pos >= (int)Source.Length() ) return wxEmptyString; if ( Source[Pos] != _T(')') ) return wxEmptyString; return ClassName; } default: ; } return wxEmptyString; }
WORD NoSpaces ( void ) { BYTE lineptr = 0; for (;IsWhite(line[lineptr]); lineptr++); strcpy (line, line+lineptr); for (;(strlen(line)>0) && IsWhite(line[strlen(line)-1]); line[strlen(line)-1]=0); strupr (line); }
/* #508936 - CSS class naming for -clean option */ Bool ParseCSS1Selector( TidyDocImpl* doc, const TidyOptionImpl* option ) { char buf[256] = {0}; uint i = 0; uint c = SkipWhite( &doc->config ); while ( i < sizeof(buf)-2 && c != EndOfStream && !IsWhite(c) ) { buf[i++] = (tmbchar) c; c = AdvanceChar( &doc->config ); } buf[i] = '\0'; if ( i == 0 || !IsCSS1Selector(buf) ) { ReportBadArgument( doc, option->name ); return no; } buf[i++] = '-'; /* Make sure any escaped Unicode is terminated */ buf[i] = 0; /* so valid class names are generated after */ /* Tidy appends last digits. */ SetOptionValue( doc, option->id, buf ); return yes; }
void cParsing::GetToken(OUT char * _out) { int nReadCount = 0; while (true) { char c = fgetc(m_fp); if (feof(m_fp)) break; if (IsWhite(c)) { if (nReadCount == 0) continue; break; } m_szToken[nReadCount++] = c; } if (_out && nReadCount == 0) { strcpy_s(_out, strlen("\0"),"\0"); } m_szToken[nReadCount] = '\0'; m_length = strlen(m_szToken); if(_out) strcpy_s(_out, m_length, m_szToken); }
void TextView::OnEnter(GKey &K) { OnInsertText("\n"); OnMoveCursor(1, 0, TRUE); if (bAutoIndent) { GCursor S = User; S.MoveY(-1); S.SetX(0); char *c = S; int Len = 0; while (IsWhite(*c) AND Len < S.LineLength()) { Len++; c++; } if (Len > 0) { OnInsertText(S, Len); OnMoveCursor(Len, 0, TRUE); } } }
Bool ParseRepeatAttr( TidyDocImpl* doc, const TidyOptionImpl* option ) { Bool status = yes; tmbchar buf[64] = {0}; uint i = 0; TidyConfigImpl* cfg = &doc->config; tchar c = SkipWhite( cfg ); while (i < sizeof(buf)-1 && c != EndOfStream && !IsWhite(c)) { buf[i++] = (tmbchar) c; c = AdvanceChar( cfg ); } buf[i] = '\0'; if ( tmbstrcasecmp(buf, "keep-first") == 0 ) cfg->value[ TidyDuplicateAttrs ].v = TidyKeepFirst; else if ( tmbstrcasecmp(buf, "keep-last") == 0 ) cfg->value[ TidyDuplicateAttrs ].v = TidyKeepLast; else { ReportBadArgument( doc, option->name ); status = no; } return status; }
/* cr, lf or crlf */ Bool ParseNewline( TidyDocImpl* doc, const TidyOptionImpl* entry ) { int nl = -1; tmbchar work[ 16 ] = {0}; tmbstr cp = work, end = work + sizeof(work); TidyConfigImpl* cfg = &doc->config; tchar c = SkipWhite( cfg ); while ( c!=EndOfStream && cp < end && !IsWhite(c) && c != '\r' && c != '\n' ) { *cp++ = (tmbchar) c; c = AdvanceChar( cfg ); } *cp = 0; if ( tmbstrcasecmp(work, "lf") == 0 ) nl = TidyLF; else if ( tmbstrcasecmp(work, "crlf") == 0 ) nl = TidyCRLF; else if ( tmbstrcasecmp(work, "cr") == 0 ) nl = TidyCR; if ( nl < TidyLF || nl > TidyCR ) ReportBadArgument( doc, entry->name ); else SetOptionInt( doc, entry->id, nl ); return ( nl >= TidyLF && nl <= TidyCR ); }
Bool ParseCharEnc( TidyDocImpl* doc, const TidyOptionImpl* option ) { tmbchar buf[64] = {0}; uint i = 0; int enc = ASCII; Bool validEncoding = yes; tchar c = SkipWhite( &doc->config ); while ( i < sizeof(buf)-2 && c != EndOfStream && !IsWhite(c) ) { buf[i++] = (tmbchar) ToLower( c ); c = AdvanceChar( &doc->config ); } buf[i] = 0; enc = CharEncodingId( buf ); #ifdef TIDY_WIN32_MLANG_SUPPORT /* limit support to --input-encoding */ if (option->id != TidyInCharEncoding && enc > WIN32MLANG) enc = -1; #endif if ( enc < 0 ) { validEncoding = no; ReportBadArgument( doc, option->name ); } else SetOptionInt( doc, option->id, enc ); if ( validEncoding && option->id == TidyCharEncoding ) AdjustCharEncoding( doc, enc ); return validEncoding; }
void StorageBase::AddedToContainer(Object const &container) { if (container.GetHandle() == GetHandle()) KAI_THROW_1(InternalError, "Can't add a container to itself"); containers.push_back(container.GetHandle()); if (IsWhite()) SetGrey(); }
std::vector<int> Chessboard::GetFeature(int color) { std::vector<int> feature; for (int i = 0; i < BOARDSIZE; ++i) for (int j = 0; j < BOARDSIZE; ++j) { feature.push_back(color == BLACK ? IsBlack(i, j) : IsWhite(i, j)); feature.push_back(color == WHITE ? IsWhite(i, j) : IsBlack(i, j)); feature.push_back(IsEmpty(i, j)); feature.push_back(CountOpenThree(i, j, color)); feature.push_back(CountSimpleThree(i, j, color)); feature.push_back(CountOpenFour(i, j, color)); feature.push_back(CountSimpleFour(i, j, color)); feature.push_back(CountOpenTwo(i, j, color)); feature.push_back(IsFive(i, j, color)); feature.push_back(CountOpenThree(i, j, color ^ 1)); feature.push_back(CountSimpleThree(i, j, color ^ 1)); feature.push_back(CountOpenFour(i, j, color ^ 1)); feature.push_back(CountSimpleFour(i, j, color ^ 1)); feature.push_back(CountOpenTwo(i, j, color ^ 1)); feature.push_back(IsFive(i, j, color ^ 1)); } return feature; }
Bool nodeHasText( TidyDocImpl* doc, Node* node ) { if ( doc && node ) { uint ix; Lexer* lexer = doc->lexer; for ( ix = node->start; ix < node->end; ++ix ) { /* whitespace */ if ( !IsWhite( lexer->lexbuf[ix] ) ) return yes; } } return no; }
/* doctype: omit | auto | strict | loose | <fpi> where the fpi is a string similar to "-//ACME//DTD HTML 3.14159//EN" */ Bool ParseDocType( TidyDocImpl* doc, const TidyOptionImpl* option ) { tmbchar buf[ 32 ] = {0}; uint i = 0; Bool status = yes; TidyDoctypeModes dtmode = TidyDoctypeAuto; TidyConfigImpl* cfg = &doc->config; tchar c = SkipWhite( cfg ); /* "-//ACME//DTD HTML 3.14159//EN" or similar */ if ( c == '"' || c == '\'' ) { status = ParseString(doc, option); if (status) SetOptionInt( doc, TidyDoctypeMode, TidyDoctypeUser ); return status; } /* read first word */ while ( i < sizeof(buf)-1 && c != EndOfStream && !IsWhite(c) ) { buf[i++] = (tmbchar) c; c = AdvanceChar( cfg ); } buf[i] = '\0'; if ( tmbstrcasecmp(buf, "auto") == 0 ) dtmode = TidyDoctypeAuto; else if ( tmbstrcasecmp(buf, "omit") == 0 ) dtmode = TidyDoctypeOmit; else if ( tmbstrcasecmp(buf, "strict") == 0 ) dtmode = TidyDoctypeStrict; else if ( tmbstrcasecmp(buf, "loose") == 0 || tmbstrcasecmp(buf, "transitional") == 0 ) dtmode = TidyDoctypeLoose; else { ReportBadArgument( doc, option->name ); status = no; } if ( status ) SetOptionInt( doc, TidyDoctypeMode, dtmode ); return status; }
/* a string excluding whitespace */ Bool ParseName( TidyDocImpl* doc, const TidyOptionImpl* option ) { tmbchar buf[ 1024 ] = {0}; uint i = 0; uint c = SkipWhite( &doc->config ); while ( i < sizeof(buf)-2 && c != EndOfStream && !IsWhite(c) ) { buf[i++] = (tmbchar) c; c = AdvanceChar( &doc->config ); } buf[i] = 0; if ( i == 0 ) ReportBadArgument( doc, option->name ); else SetOptionValue( doc, option->id, buf ); return ( i > 0 ); }
/* skip over line continuations to start of next property */ static uint NextProperty( TidyConfigImpl* config ) { do { /* skip to end of line */ while ( config->c != '\n' && config->c != '\r' && config->c != EndOfStream ) config->c = GetC( config ); /* treat \r\n \r or \n as line ends */ if ( config->c == '\r' ) config->c = GetC( config ); if ( config->c == '\n' ) config->c = GetC( config ); } while ( IsWhite(config->c) ); /* line continuation? */ return config->c; }
Bool ParseString( TidyDocImpl* doc, const TidyOptionImpl* option ) { TidyConfigImpl* cfg = &doc->config; tmbchar buf[8192]; uint i = 0; tchar delim = 0; Bool waswhite = yes; tchar c = SkipWhite( cfg ); if ( c == '"' || c == '\'' ) { delim = c; c = AdvanceChar( cfg ); } while ( i < sizeof(buf)-2 && c != EndOfStream && c != '\r' && c != '\n' ) { if ( delim && c == delim ) break; if ( IsWhite(c) ) { if ( waswhite ) { c = AdvanceChar( cfg ); continue; } c = ' '; } else waswhite = no; buf[i++] = (tmbchar) c; c = AdvanceChar( cfg ); } buf[i] = '\0'; SetOptionValue( doc, option->id, buf ); return yes; }
char* AseLoader::GetToken() { int readCount = 0; bool isQuote = false; while(true) { char c = fgetc(filePointer); if (feof(filePointer)) break; if( c == '\"' ) { if (isQuote) { break; } isQuote = true; continue; } if(!isQuote && IsWhite(c)) { if ( readCount == 0 ) continue; break; } token[readCount++] = c; } if ( readCount == 0 ) return nullptr; token[readCount] = '\0'; return token; }
void PyrGC::ScanFrames() { VMGlobals *g = mVMGlobals; PyrFrame* frame = g->frame; while (frame) { #if 1 // this is more incremental if (IsWhite(frame)) { ToGrey2(frame); } #else // this is more efficient if (!IsBlack(frame)) { ToBlack(frame); int32 size = ScanSize(frame); PyrSlot *slots = ((PyrObject*)frame)->slots; ScanSlots(slots, size); } #endif frame = slotRawFrame(&frame->caller); } }
void TwitterTask::Entry(TaskServer &server, const std::atomic<bool> &cancel) { // 初回実行時のみ // 自分の最後のツイート以降でフィルタする if (m_since_id == 0) { m_since_id = GetInitialSinceId(); logger.Log(LogLevel::Info, "Initial since_id: %" PRIu64, m_since_id); } // ホームタイムラインを取得 auto twitter = system::Get().twitter; auto json = twitter.Statuses_HomeTimeline({ {"since_id", std::to_string(m_since_id)}, {"count", "200"}}); auto log_tweet = [](const json11::Json &status, std::time_t timestamp) { logger.Log(LogLevel::Info, "id=%s time=%s local=%s screen=%s name=%s", status["id_str"].string_value().c_str(), status["created_at"].string_value().c_str(), util::DateTimeStr(timestamp).c_str(), status["user"]["screen_name"].string_value().c_str(), status["user"]["name"].string_value().c_str()); logger.Log(LogLevel::Info, "%s", status["text"].string_value().c_str()); }; for (const auto &status : json.array_items()) { // ID uint64_t id = util::to_uint64(status["id_str"].string_value()); // ローカルタイムに変換 std::time_t timestamp = util::StrToTimeTwitter( status["created_at"].string_value()); struct tm local; ::localtime_r(×tamp, &local); // 自分のツイートには反応しない if (util::to_uint64(status["id_str"].string_value()) == twitter.MyId()) { continue; } // リツイートには反応しない if (!status["retweeted_status"].is_null()) { continue; } if (IsWhite(status)) { logger.Log(LogLevel::Info, "Find White"); log_tweet(status, timestamp); std::string msg = u8"@"; msg += status["user"]["screen_name"].string_value(); msg += ' '; msg += u8"ホワイト!"; twitter.Tweet(msg, status["id_str"].string_value()); m_since_id = std::max(id, m_since_id); } if (IsBlack(status)) { logger.Log(LogLevel::Info, "Find Black"); log_tweet(status, timestamp); std::string msg = u8"@"; msg += status["user"]["screen_name"].string_value(); msg += ' '; msg += u8"ブラック"; twitter.Tweet(msg, status["id_str"].string_value()); m_since_id = std::max(id, m_since_id); } } }
/* skip over leading white space */ void SkipWhite(void) { while(IsWhite(Look)) { GetChar(); } }
static tchar SkipWhite( TidyConfigImpl* config ) { while ( IsWhite(config->c) && !IsNewline(config->c) ) config->c = GetC( config ); return config->c; }
void SkipWhite(){ while(IsWhite(Look)) GetChar(); }
inline bool StoneBoard::IsOccupied(HexPoint cell) const { BenzeneAssert(Const().IsLocation(cell)); return (IsBlack(cell) || IsWhite(cell)); }
inline bool wxWidgetsGUI::IsWhite(const wxString& Str,int Pos) { if ( Pos>=(int)Str.Length() ) return false; return IsWhite(Str[Pos]); }
/* open the file and parse its contents */ int ParseConfigFileEnc( TidyDocImpl* doc, ctmbstr file, ctmbstr charenc ) { uint opterrs = doc->optionErrors; tmbstr fname = (tmbstr) ExpandTilde( file ); TidyConfigImpl* cfg = &doc->config; FILE* fin = fopen( fname, "r" ); int enc = CharEncodingId( charenc ); if ( fin == NULL || enc < 0 ) { FileError( doc, fname, TidyConfig ); return -1; } else { tchar c; cfg->cfgIn = FileInput( doc, fin, enc ); c = FirstChar( cfg ); for ( c = SkipWhite(cfg); c != EndOfStream; c = NextProperty(cfg) ) { uint ix = 0; tmbchar name[ TIDY_MAX_NAME ] = {0}; /* // or # start a comment */ if ( c == '/' || c == '#' ) continue; while ( ix < sizeof(name)-1 && c != '\n' && c != EndOfStream && c != ':' ) { name[ ix++ ] = (tmbchar) c; /* Option names all ASCII */ c = AdvanceChar( cfg ); } if ( c == ':' ) { const TidyOptionImpl* option = lookupOption( name ); c = AdvanceChar( cfg ); if ( option ) option->parser( doc, option ); else { if (NULL != doc->pOptCallback) { TidyConfigImpl* cfg = &doc->config; tmbchar buf[8192]; uint i = 0; tchar delim = 0; Bool waswhite = yes; tchar c = SkipWhite( cfg ); if ( c == '"' || c == '\'' ) { delim = c; c = AdvanceChar( cfg ); } while ( i < sizeof(buf)-2 && c != EndOfStream && c != '\r' && c != '\n' ) { if ( delim && c == delim ) break; if ( IsWhite(c) ) { if ( waswhite ) { c = AdvanceChar( cfg ); continue; } c = ' '; } else waswhite = no; buf[i++] = (tmbchar) c; c = AdvanceChar( cfg ); } buf[i] = '\0'; if (no == (*doc->pOptCallback)( name, buf )) ReportUnknownOption( doc, name ); } else ReportUnknownOption( doc, name ); } } } fclose( fin ); MemFree( (void *)cfg->cfgIn->source.sourceData ); /* fix for bug #810259 */ freeStreamIn( cfg->cfgIn ); cfg->cfgIn = NULL; } if ( fname != (tmbstr) file ) MemFree( fname ); AdjustConfig( doc ); /* any new config errors? If so, return warning status. */ return (doc->optionErrors > opterrs ? 1 : 0); }
bool wxWidgetsGUI::AddSmithToApp(const wxString& RelativeFileName,wxsCodingLang Lang) { if ( !IsAppSourceManaged(RelativeFileName,Lang) ) { wxString FullPath = GetProjectPath()+RelativeFileName; // Need to create some extra blocks of code. wxFontEncoding Encoding; bool UseBOM; wxString Source = wxsCoder::Get()->GetFullCode(FullPath,Encoding,UseBOM); if ( Source.empty() ) return false; switch ( Lang ) { case wxsCPP: { // First thing we need is to add new includes section // It is added right before IMPLEMENT_APP() macro int Pos = Source.Find(_T("IMPLEMENT_APP")); while ( Pos>0 && Source[Pos]!=_T('\n') ) Pos--; if ( Pos>0 ) Pos++; // TODO: Get valid EOL mode Source.insert(Pos, wxsCodeMarks::Beg(wxsCPP,_T("AppHeaders")) + _T("\n") + wxsCodeMarks::End(wxsCPP) + _T("\n\n")); wxString ClassName = GetAppClassName(Source,wxsCPP); if ( ClassName.empty() ) return false; // Searching for ::OnInit member wxString SourceCpy = Source; Pos = 0; while ( !SourceCpy.empty() ) { int ClassPos = SourceCpy.Find(ClassName); if ( ClassPos<0 ) return false; ClassPos += ClassName.Length(); Pos += ClassPos; SourceCpy.Remove(0,ClassPos); int MemberPos = 0; while ( IsWhite(SourceCpy,MemberPos) ) MemberPos++; if ( MemberPos+1>=(int)(SourceCpy.Length()) ) continue; if ( SourceCpy[MemberPos]!=_T(':') && SourceCpy[MemberPos+1]!=_T(':') ) continue; MemberPos+=2; while ( IsWhite(SourceCpy,MemberPos) ) MemberPos++; if ( SourceCpy.Mid(MemberPos,6) != _T("OnInit") ) continue; MemberPos += 6; while ( IsWhite(SourceCpy,MemberPos) ) MemberPos++; if ( !Match(SourceCpy,MemberPos,_T('(')) ) continue; MemberPos++; while ( IsWhite(SourceCpy,MemberPos) ) MemberPos++; if ( !Match(SourceCpy,MemberPos,_T(')')) ) continue; MemberPos++; while ( IsWhite(SourceCpy,MemberPos) ) MemberPos++; if ( !Match(SourceCpy,MemberPos,_T('{')) ) continue; MemberPos++; // Ok, we're at function beginning, calculating indentation of { Pos += MemberPos; break; } if ( SourceCpy.empty() ) return false; // Calculating indentation of source int IndentPos = Pos; while ( IndentPos>0 && Source[IndentPos-1]!=_T('\n') && Source[IndentPos-1]!='\r' ) IndentPos--; wxString Indent; while ( IndentPos<Pos && (Source[IndentPos]==_T(' ') || Source[IndentPos]==_T('\t')) ) Indent += Source[IndentPos++]; Indent.Append(_T("\t")); // Inserting AppInitializeBlock Source = Source(0,Pos) + _T("\n") + Indent + wxsCodeMarks::Beg(wxsCPP,_T("AppInitialize")) + _T("\n") + Indent + wxsCodeMarks::End(wxsCPP) + _T("\n") + Indent + _T("return wxsOK;\n") + Indent + Source.Mid(Pos); // Writing new source back to files / editor wxsCoder::Get()->PutFullCode(FullPath,Source,Encoding,UseBOM); break; } default: ; } } // Applying default configuration m_AppFile = RelativeFileName; m_LoadedResources.Clear(); m_MainResource.Clear(); m_CallInitAll = true; m_CallInitAllNecessary = true; m_AppLanguage = Lang; OnRebuildApplicationCode(); NotifyChange(); return true; }
/* a space or comma separated list of tag names */ Bool ParseTagNames( TidyDocImpl* doc, const TidyOptionImpl* option ) { TidyConfigImpl* cfg = &doc->config; tmbchar buf[1024]; uint i = 0, nTags = 0; uint c = SkipWhite( cfg ); UserTagType ttyp = tagtype_null; switch ( option->id ) { case TidyInlineTags: ttyp = tagtype_inline; break; case TidyBlockTags: ttyp = tagtype_block; break; case TidyEmptyTags: ttyp = tagtype_empty; break; case TidyPreTags: ttyp = tagtype_pre; break; default: ReportUnknownOption( doc, option->name ); return no; } SetOptionValue( doc, option->id, NULL ); FreeDeclaredTags( doc, ttyp ); cfg->defined_tags |= ttyp; do { if (c == ' ' || c == '\t' || c == ',') { c = AdvanceChar( cfg ); continue; } if ( c == '\r' || c == '\n' ) { uint c2 = AdvanceChar( cfg ); if ( c == '\r' && c2 == '\n' ) c = AdvanceChar( cfg ); else c = c2; if ( !IsWhite(c) ) { buf[i] = 0; UngetChar( c, cfg->cfgIn ); UngetChar( '\n', cfg->cfgIn ); break; } } /* if ( c == '\n' ) { c = AdvanceChar( cfg ); if ( !IsWhite(c) ) { buf[i] = 0; UngetChar( c, cfg->cfgIn ); UngetChar( '\n', cfg->cfgIn ); break; } } */ while ( i < sizeof(buf)-2 && c != EndOfStream && !IsWhite(c) && c != ',' ) { buf[i++] = (tmbchar) c; c = AdvanceChar( cfg ); } buf[i] = '\0'; if (i == 0) /* Skip empty tag definition. Possible when */ continue; /* there is a trailing space on the line. */ /* add tag to dictionary */ DeclareUserTag( doc, option->id, ttyp, buf ); i = 0; ++nTags; } while ( c != EndOfStream ); if ( i > 0 ) DeclareUserTag( doc, option->id, ttyp, buf ); return ( nTags > 0 ); }
bool MmlParser::FeedChar(int ch) { bool continueFlag; if ('a' <= ch && ch <= 'z') ch = ch - 'a' + 'A'; do { continueFlag = false; if (_stat == STAT_Begin) { if (IsEOD(ch)) { // nothing to do } else if ('A' <= ch && ch <= 'G') { _operator = ch; _operatorSub = '\0'; _numAccum = 0; _cntDot = 0; _stat = STAT_Note; } else if (ch == 'R') { _operator = ch; _numAccum = 0; _cntDot = 0; _stat = STAT_RestLengthPre; } else if (ch == '&') { _operator = ch; } else if (ch == 'O') { _operator = ch; _numAccum = 0; _stat = STAT_OctavePre; } else if (ch == '>') { _operator = ch; if (_octave < 255) _octave++; } else if (ch == '<') { _operator = ch; if (_octave > 0) _octave--; } else if (ch == 'L') { _operator = ch; _numAccum = 0; _cntDot = 0; _stat = STAT_LengthPre; } else if (ch == 'V') { _operator = ch; _numAccum = 0; _stat = STAT_VolumePre; } else if (ch == '@') { _operator = ch; _numAccum = 0; _stat = STAT_TonePre; } else if (ch == 'T') { _operator = ch; _numAccum = 0; _stat = STAT_TempoPre; } else { // nothing to do } } else if (_stat == STAT_Note) { // -------- Note -------- if (ch == '#' || ch == '+' || ch == '-') { _operatorSub = ch; _stat = STAT_NoteLengthPre; } else if (IsDigit(ch)) { continueFlag = true; _stat = STAT_NoteLength; } else if (IsWhite(ch)) { // nothing to do } else { continueFlag = true; _stat = STAT_NoteFix; } } else if (_stat == STAT_NoteLengthPre) { if (IsDigit(ch)) { continueFlag = true; _stat = STAT_NoteLength; } else if (IsWhite(ch)) { // nothing to do } else { continueFlag = true; _stat = STAT_NoteFix; } } else if (_stat == STAT_NoteLength) { if (IsDigit(ch)) { _numAccum = _numAccum * 10 + (ch - '0'); } else if (ch == '.') { _cntDot++; } else { continueFlag = true; _stat = STAT_NoteFix; } } else if (_stat == STAT_NoteFix) { static const unsigned char noteTbl[] = { 9, 11, 0, 2, 4, 5, 7, }; unsigned char note = noteTbl[_operator - 'A'] + _octave * 12; if (_operatorSub == '#' || _operatorSub == '+') { if (note < 127) note++; } else if (_operatorSub == '-') { if (note > 0) note--; } else { // nothing to do } int length = CalcLength(_numAccum, _cntDot, _lengthDefault); _handler.MmlNote(*this, note, length); continueFlag = true; _stat = STAT_Begin; } else if (_stat == STAT_RestLengthPre) {// -------- Rest -------- if (IsDigit(ch)) { continueFlag = true; _stat = STAT_RestLength; } else if (IsWhite(ch)) { // nothing to do } else { continueFlag = true; _stat = STAT_RestFix; } } else if (_stat == STAT_RestLength) { if (IsDigit(ch)) { _numAccum = _numAccum * 10 + (ch - '0'); } else if (ch == '.') { _cntDot++; } else { continueFlag = true; _stat = STAT_RestFix; } } else if (_stat == STAT_RestFix) { int length = CalcLength(_numAccum, _cntDot, _lengthDefault); _handler.MmlRest(*this, length); continueFlag = true; _stat = STAT_Begin; } else if (_stat == STAT_OctavePre) { // -------- Octave -------- if (IsDigit(ch)) { continueFlag = true; _stat = STAT_Octave; } else if (IsWhite(ch)) { // nothing to do } else { continueFlag = true; _stat = STAT_OctaveFix; } } else if (_stat == STAT_Octave) { if (IsDigit(ch)) { _numAccum = _numAccum * 10 + (ch - '0'); } else { continueFlag = true; _stat = STAT_OctaveFix; } } else if (_stat == STAT_OctaveFix) { _octave = _numAccum; continueFlag = true; _stat = STAT_Begin; } else if (_stat == STAT_LengthPre) { // -------- Length -------- if (IsDigit(ch)) { continueFlag = true; _stat = STAT_Length; } else if (IsWhite(ch)) { // nothing to do } else { continueFlag = true; _stat = STAT_LengthFix; } } else if (_stat == STAT_Length) { if (IsDigit(ch)) { _numAccum = _numAccum * 10 + (ch - '0'); } else if (ch == '.') { _cntDot++; } else { continueFlag = true; _stat = STAT_LengthFix; } } else if (_stat == STAT_LengthFix) { _lengthDefault = CalcLength(_numAccum, _cntDot, _lengthDefault); continueFlag = true; _stat = STAT_Begin; } else if (_stat == STAT_VolumePre) { // -------- Volume -------- if (IsDigit(ch)) { continueFlag = true; _stat = STAT_Volume; } else if (IsWhite(ch)) { // nothing to do } else { continueFlag = true; _stat = STAT_VolumeFix; } } else if (_stat == STAT_Volume) { if (IsDigit(ch)) { _numAccum = _numAccum * 10 + (ch - '0'); } else { continueFlag = true; _stat = STAT_VolumeFix; } } else if (_stat == STAT_VolumeFix) { _volume = _numAccum; continueFlag = true; _stat = STAT_Begin; } else if (_stat == STAT_TonePre) { // ------- Tone -------- if (IsDigit(ch)) { continueFlag = true; _stat = STAT_Tone; } else if (IsWhite(ch)) { // nothing to do } else { continueFlag = true; _stat = STAT_ToneFix; } } else if (_stat == STAT_Tone) { if (IsDigit(ch)) { _numAccum = _numAccum * 10 + (ch - '0'); } else { continueFlag = true; _stat = STAT_ToneFix; } } else if (_stat == STAT_ToneFix) { _tone = _numAccum; continueFlag = true; _stat = STAT_Begin; } else if (_stat == STAT_TempoPre) { // -------- Tempo -------- if (IsDigit(ch)) { continueFlag = true; _stat = STAT_Tempo; } else if (IsWhite(ch)) { // nothing to do } else { continueFlag = true; _stat = STAT_TempoFix; } } else if (_stat == STAT_Tempo) { if (IsDigit(ch)) { _numAccum = _numAccum * 10 + (ch - '0'); } else { continueFlag = true; _stat = STAT_TempoFix; } } else if (_stat == STAT_TempoFix) { _tempo = _numAccum; continueFlag = true; _stat = STAT_Begin; } } while (continueFlag); return true; }