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