Example #1
0
int VParser::parseFile(const char *fileName)
{
    int     RetVal = 0;
    FILE    *fp;
    long    bufsize = 65536;
    char    *buffer;

    buffer = new(char[bufsize]);
        
    fp = fopen(fileName, "r");
    if (fp != NULL) {
        // Well, we were able to read the file...Start parsing it.
        while(fgets(buffer, bufsize - 1, fp) != NULL) {
            // Check for comments in the file.  Skip them.
            if (buffer[0] != '#') {
                fcontents.append(buffer);
            }
        }
        fclose(fp);

        doParsing();

    } else {
        RetVal = -1;
    }

    delete(buffer);

    return(RetVal);
}
Example #2
0
/**
 * Parse from an input stream.
 * @param in	Input stream to use.
 */
void Parser::parse(io::InStream& in) throw(json::Exception) {
	try {
		io::BufferedInStream buf(in);
		doParsing(buf);
	}
	catch(io::IOException& e) {
		throw json::Exception(e.message());
	}
}
Example #3
0
/**
 * Parser from a string.
 * @param s		String to parser.
 */
void Parser::parse(string s) throw(json::Exception) {
	io::BlockInStream in(s);
	doParsing(in);
}