Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include <mbl/mbl_parse_string_list.h>
00007
00008 #include <mbl/mbl_exception.h>
00009 #include <mbl/mbl_parse_block.h>
00010 #include <vcl_sstream.h>
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 void mbl_parse_string_list(vcl_istream& is,
00021 vcl_vector<vcl_string>& items,
00022 const vcl_string& comment_str)
00023 {
00024 vcl_string s = mbl_parse_block(is);
00025 vcl_istringstream ss(s);
00026 char c;
00027 ss>>c;
00028 if (c!='{')
00029 {
00030 throw mbl_exception_parse_error("Expected '{' in mbl_parse_string_list");
00031 }
00032
00033 unsigned comment_len = comment_str.size();
00034
00035 items.resize(0);
00036 vcl_string label;
00037 while (!ss.eof())
00038 {
00039 ss >> label;
00040 if (comment_len>0 &&
00041 label.length()>=comment_len &&
00042 label.substr(0,comment_len)==comment_str)
00043 {
00044
00045
00046 vcl_string dummy;
00047 vcl_getline(ss,dummy);
00048 continue;
00049 }
00050 if (label == "}") continue;
00051 items.push_back(label);
00052 }
00053
00054 if (label!="}")
00055 {
00056 throw mbl_exception_parse_error("Expected closing '}' in mbl_parse_string_list");
00057 }
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 void mbl_parse_string_list(const vcl_string& data,
00069 vcl_vector<vcl_string>& items,
00070 const vcl_string& comment_str)
00071 {
00072 vcl_istringstream data_stream(data);
00073 mbl_parse_string_list(data_stream,items,comment_str);
00074 }
00075
00076