/** * Parse the BlueFly Vario parameter values. * Sent Upon a BST request. */ bool BlueFlyDevice::ParseSET(const char *content, NMEAInfo &info) { // e.g. SET 0 100 20 1 1 1 180 1000 100 400 100 20 5 5 100 50 0 10 21325 207 1 0 1 34 const char *values, *token; unsigned long value; if (!settings.version || !settings_keys) /* we did not receive the previous BFV and BST, abort */ return true; token = StringToken(settings_keys, " "); values = content; /* the first value should be ignored */ if (!ParseUlong(&values, value)) return true; mutex_settings.Lock(); while (token && ParseUlong(&values, value)) { settings.Parse(token, value); token = StringToken(nullptr, " "); } settings_ready = true; settings_cond.broadcast(); mutex_settings.Unlock(); return true; }
kexVec4 kexLexer::GetVectorString4(void) { kexVec4 vec; GetString(); sscanf(StringToken(), "%f %f %f %f", &vec.x, &vec.y, &vec.z, &vec.w); return vec; }
kexVec3 kexLexer::GetVectorString3(void) { kexVec3 vec; GetString(); sscanf(StringToken(), "%f %f %f", &vec.x, &vec.y, &vec.z); return vec; }
void Textbox::addNewLine() { currentLineNumber++; currHorizontalOffset = 0.0f; tokens.push_back( StringToken( "", currHorizontalOffset, currentLineNumber, textColor ) ); // any time a new line is added, go to bottom of textbox firstLineInView = 0; if ( currentLineNumber >= getNumLinesThatFit() ) { firstLineInView = currentLineNumber + 1 - getNumLinesThatFit(); } updateScrollBar(); }
void Textbox::appendText( std::string newText, glm::vec3 color ) { // get edges GLuint leftEdge = pos.x + paddingHorizontal + borderSize; GLuint rightEdge = pos.x + size.x - paddingHorizontal - borderSize - btnSize.x; // loop through each token of text std::string delimiter = " "; GLfloat delimOffset = getStringWidth( " " ); std::string token; GLuint start = 0; GLuint end = newText.find( delimiter ); while ( end != std::string::npos ) { // get the next token token = newText.substr( start, end - start ); // calculate the width of the token GLfloat width = getStringWidth( token ); // check to see if token fits on the same line if ( leftEdge + currHorizontalOffset + width > rightEdge ) { addNewLine(); } tokens.push_back( StringToken( token, currHorizontalOffset, currentLineNumber, color ) ); // move horizontal offset currHorizontalOffset += width + delimOffset; start = end + delimiter.length(); end = newText.find( delimiter, start ); } token = newText.substr( start, newText.size() ); GLfloat width = getStringWidth( token ); if ( leftEdge + currHorizontalOffset + width > rightEdge ) { addNewLine(); } tokens.push_back( StringToken( token, currHorizontalOffset, currentLineNumber, color ) ); currHorizontalOffset += width + delimOffset; }
/* NextToken - read the next token */ static int NextToken(ParseContext *c) { int ch, tkn; /* skip leading blanks */ ch = SkipSpaces(c); /* remember the start of the current token */ c->tokenOffset = (int)(c->sys->linePtr - c->sys->lineBuf); /* check the next character */ switch (ch) { case EOF: tkn = T_EOL; break; case '"': tkn = StringToken(c); break; case '\'': tkn = CharToken(c); break; case '<': if ((ch = GetChar(c)) == '=') tkn = T_LE; else if (ch == '>') tkn = T_NE; else if (ch == '<') tkn = T_SHL; else { UngetC(c); tkn = '<'; } break; case '>': if ((ch = GetChar(c)) == '=') tkn = T_GE; else if (ch == '>') tkn = T_SHR; else { UngetC(c); tkn = '>'; } break; case '0': switch (GetChar(c)) { case 'x': case 'X': tkn = HexNumberToken(c); break; case 'b': case 'B': tkn = BinaryNumberToken(c); break; default: UngetC(c); tkn = NumberToken(c, '0'); break; } break; default: if (isdigit(ch)) tkn = NumberToken(c, ch); else if (IdentifierCharP(ch)) { char *savePtr; switch (tkn = IdentifierToken(c,ch)) { case T_ELSE: savePtr = c->sys->linePtr; if ((ch = SkipSpaces(c)) != EOF && IdentifierCharP(ch)) { switch (IdentifierToken(c, ch)) { case T_IF: tkn = T_ELSE_IF; break; default: c->sys->linePtr = savePtr; break; } } else c->sys->linePtr = savePtr; break; case T_END: savePtr = c->sys->linePtr; if ((ch = SkipSpaces(c)) != EOF && IdentifierCharP(ch)) { switch (IdentifierToken(c, ch)) { case T_DEF: tkn = T_END_DEF; break; case T_IF: tkn = T_END_IF; break; default: c->sys->linePtr = savePtr; break; } } else c->sys->linePtr = savePtr; break; case T_DO: savePtr = c->sys->linePtr; if ((ch = SkipSpaces(c)) != EOF && IdentifierCharP(ch)) { switch (IdentifierToken(c, ch)) { case T_WHILE: tkn = T_DO_WHILE; break; case T_UNTIL: tkn = T_DO_UNTIL; break; default: c->sys->linePtr = savePtr; break; } } else c->sys->linePtr = savePtr; break; case T_LOOP: savePtr = c->sys->linePtr; if ((ch = SkipSpaces(c)) != EOF && IdentifierCharP(ch)) { switch (IdentifierToken(c, ch)) { case T_WHILE: tkn = T_LOOP_WHILE; break; case T_UNTIL: tkn = T_LOOP_UNTIL; break; default: c->sys->linePtr = savePtr; break; } } else c->sys->linePtr = savePtr; break; } } else tkn = ch; } /* return the token */ return tkn; }
/** * Don't use - not thread safe. */ pointer next_token(const_pointer delim) { return StringToken(nullptr, delim); }
/** * Don't use - not thread safe. */ pointer first_token(const_pointer delim) { return StringToken(data, delim); }
TInt TSuffixString::lower_bound(const char* str,const char* str_end)const{ if (SA.empty()) return 0; const TSuffixIndex* pos=std::lower_bound<const TSuffixIndex*,StringToken,const TSuffixString_compare&> (&SA[0],&SA[0]+SA.size(),StringToken(str,str_end),TSuffixString_compare(ssbegin,ssend)); return (TInt)(pos-&SA[0]); }
/** * Don't use - not thread safe. */ T *next_token(const T *delim) { return StringToken(nullptr, delim); }
/** * Don't use - not thread safe. */ T *first_token(const T *delim) { return StringToken(data, delim); }
/** * Don't use - not thread safe. */ T *next_token(const T *delim) { return StringToken(NULL, delim); }