Пример #1
0
UINT
TSHPath::GetCharType(tchar ch)
{
  static TModuleProc1<UINT,tchar>
         getCharType(GetModule(), GetCharTypeStr);
  return getCharType(ch);
}
Пример #2
0
	bool isNumeric(std::string const & in)
	{
		for(unsigned i=0;i<in.size();++i)
			if(!(getCharType(in[i]) == CharType::NUMBER || in[i] == '.'))
			{
				return false;
			}
		return true;
	}	
Пример #3
0
void hsTokenStream::getLine() {
    while (!fLineTokens.empty())
        fLineTokens.pop();
    if (fStream->eof())
        return;

    plString line = fStream->readLine() + "\n";
    size_t beg=0, end=0;
    int tokType;
    while (end < line.len()) {
        beg = end;
        if (fInComment == -1) {
            while (beg < line.len() && getCharType(line[beg]) == kCharNone)
                beg++;
        }
        for (auto mark = fStringMarkers.begin(); mark != fStringMarkers.end(); ++mark) {
            if (line.mid(beg).startsWith(mark->fStart)) {
                long strEnd = line.mid(beg + mark->fStart.len()).find(mark->fEnd);
                if (strEnd == -1)
                    throw hsBadParamException(__FILE__, __LINE__);
                unsigned long markerLen = mark->fStart.len() + mark->fEnd.len();
                fLineTokens.push(line.mid(beg, strEnd + markerLen));
                beg += strEnd + markerLen;
            }
        }
        for (size_t i=0; i<fCommentMarkers.size(); i++) {
            if (fInComment == -1 && line.mid(beg).startsWith(fCommentMarkers[i].fStart)) {
                fInComment = i;
                beg += fCommentMarkers[i].fStart.len();
            }
        }
        if (fInComment == -1) {
            while (beg < line.len() && getCharType(line[beg]) == kCharNone)
                beg++;
        }
        end = beg;
        if (fInComment != -1) {
            tokType = kCharComment;
            while (end < line.len() && fInComment != -1) {
                if (line.mid(end).startsWith(fCommentMarkers[fInComment].fEnd)) {
                    end += fCommentMarkers[fInComment].fEnd.len();
                    fInComment = -1;
                } else {
                    end++;
                }
            }
        } else {
            tokType = getCharType(line[beg]);
            while (end < line.len() && getCharType(line[end]) == tokType) {
                end++;
                if (tokType == kCharDelim) break; // Only return one Delimiter
            }
            if (end != beg)
                fLineTokens.push(line.mid(beg, end-beg));
        }
    }

    // Check for a blank line and skip it
    if (fLineTokens.empty())
        getLine();
}