Ejemplo n.º 1
0
void DelimitedDataReader::readData(void)
{
    
    std::vector<std::string> tmpChars;
    
    // open file
    std::ifstream readStream;
    RbFileManager* f = new RbFileManager(filename);
    if (!f->openFile(readStream))
        std::cout << "ERROR: Could not open file " << filename << "\n";
    
    chars.clear();
    
    // read file
    // bool firstLine = true;
    std::string readLine = "";
    while (std::getline(readStream,readLine))
    {
        std::string field = "";
        std::stringstream ss(readLine);

        int pos = 0;
        while (std::getline(ss,field,delimiter))
        {
            tmpChars.push_back(field);
            pos++;
        };
        chars.push_back(tmpChars);
        tmpChars.clear();
    };
    
}
Ejemplo n.º 2
0
RbHelpType* RbHelpParser::parseHelpType(const std::string &fn)
{
    
    // first we need to load the file
    std::ifstream readStream;
    RbFileManager fm = RbFileManager(fn);
    fm.openFile( readStream );
    
    // try to load the xml file
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file(fn.c_str(), pugi::parse_default);
    if (result.status != pugi::status_ok)
    {
        std::cerr << "Problem while parsing file " << fn << std::endl;
        throw RbException( result.description() );
    }
    
    RbHelpType* helpEntry = new RbHelpType();
    
    pugi::xpath_node node = doc.select_single_node( "//type-help-entry" );
    parseInternalHelpType( node, helpEntry );
    
    // now return the help entry
    return helpEntry;
}
Ejemplo n.º 3
0
RbHelpFunction RbHelpParser::parseHelpFunction(const std::string &fn)
{
    
    // first we need to load the file
    std::ifstream readStream;
    RbFileManager fm = RbFileManager(fn);
    fm.openFile( readStream );
    
    // try to load the xml file
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file(fn.c_str(), pugi::parse_default);
    if (result.status != pugi::status_ok)
    {
    std::cerr << "Problem while parsing file " << fn << std::endl;
        throw RbException( result.description() );
    }
    
    std::vector<RbHelpFunction> functions;
//    pugi::xpath_node node = doc.select_single_node( "//function-help-entry" );
    pugi::xpath_node_set nodeSet = doc.select_nodes( "//function-help-entry" );
    for (pugi::xpath_node_set::const_iterator it = nodeSet.begin(); it != nodeSet.end(); ++it)
    {
        pugi::xpath_node node = *it;
        RbHelpFunction helpEntryFunction = parseInternalHelpFunction( node );
        functions.push_back( helpEntryFunction );
    }

    RbHelpFunction helpEntry = functions[0];
    
    return helpEntry;
}
Ejemplo n.º 4
0
RbHelpParser::HelpEntryType RbHelpParser::testHelpEntry(const std::string &fn)
{
    // first we need to load the file
    std::ifstream readStream;
    RbFileManager fm = RbFileManager(fn);
    fm.openFile( readStream );
    
    // try to load the xml file
    pugi::xml_document doc;
    pugi::xml_parse_result result = doc.load_file(fn.c_str(), pugi::parse_default);
    if (result.status != pugi::status_ok)
    {
        std::cerr << "Problem while parsing file " << fn << std::endl;
        throw RbException( result.description() );
    }
    
    pugi::xpath_node_set nodeSet = doc.select_nodes("//function-help-entry");
    if ( nodeSet.size() > 0 )
    {
        return FUNCTION;
    }
    
    nodeSet = doc.select_nodes("//type-help-entry");
    if ( nodeSet.size() > 0 )
    {
        return TYPE;
    }
    
    nodeSet = doc.select_nodes("//distribution-help-entry");
    if ( nodeSet.size() > 0 )
    {
        return DISTRIBUTION;
    }
    
    nodeSet = doc.select_nodes("//move-help-entry");
    if ( nodeSet.size() > 0 )
    {
        return MOVE;
    }
    
    nodeSet = doc.select_nodes("//monitor-help-entry");
    if ( nodeSet.size() > 0 )
    {
        return MONITOR;
    }
    
    
    throw RbException("Unknown help entry type in file '" + fn + "'.");

}