Ejemplo n.º 1
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  process_flags
 *  Description:  processes input flags  
 * =====================================================================================
 */
int process_flags(int argc, char* argv[])
{
    if((argc % 2) == 0) 
    {
        cout << "invalid number of arguments specified.\n";
        cout << "usage: " << argv[0] << " <flag> <value> ";
        exit(-1);
    }
    
    int num_flags = (argc-1)/2;
    string* flags = new string[num_flags];
    const char** values = new const char*[num_flags];
    
    int j = 0;
    for(int i = 1; i+1 < argc; ++i)
    {
        flags[j] = string(argv[i]);
        values[j] = argv[i+1];
        ++i;
        ++j;
    }
    
    // validate flags 
    validate_flags(flags, values, num_flags);
    // if no flags provided, globals will use default values
    initialize_variables(flags, values, num_flags);
    
    delete [] flags;
    delete [] values;

	return 0;
}
Ejemplo n.º 2
0
 void read_xml(const std::string &filename,
               Ptree &pt,
               int flags = 0,
               const std::locale &loc = std::locale())
 {
     BOOST_ASSERT(validate_flags(flags));
     std::basic_ifstream<typename Ptree::key_type::value_type>
         stream(filename.c_str());
     if (!stream)
         BOOST_PROPERTY_TREE_THROW(xml_parser_error(
             "cannot open file", filename, 0));
     stream.imbue(loc);
     read_xml_internal(stream, pt, flags, filename);
 }