/** * Reads a name from the cache * * Description: * Name ::= NameStartChar (NameChar)* * NameStartChar ::= ":" | [A-Z] | "_" | [a-z] //add "?" * NameChar ::= NameStartChar | "-" | "." | [0-9] * @param var * @return RES_OK if the char was skipped, RES_EOF if no more tags, errors.. */ RES_CODE CCache::get_name(CSTRING& var) { char ch; RES_CODE res; res = get_pc(ch); if (res == RES_OK) { if (ch == ':' || ch == '_' || ch == '?' || IS_ALPHA(ch)) { var += ch; while (!var.empty()) { res = getc(ch); switch (res) { case RES_OK: if (ch == ':' || ch == '_' || ch == '-' || ch == '.' || IS_ALPHANUM(ch)) { var += ch; } else { ungetc(); return RES_OK; } break; case RES_EOF: return RES_OK; default: return (res); } } return RES_OUT_OF_MEMORY; } ungetc(); res = RES_INVALID_DATA; } return (res); }
/** * Puts a string in the cache line * @param var * @return */ RES_CODE CCache::buffer(CSTRING &var) { unsigned int len; if (!var.empty()) { if (pos) { len = buf.length() - (pos - buf.c_str()); if (len) { CSTRING s(pos, len); if (next.empty()) next = s; else next = s + next; } } buf = var; pos = (char*) buf.c_str(); } return RES_OK; }