72{
73 std::string s;
74 while (is && getline(is, s)) {
75 if (s.size() == 0 || s.at(0) == '#') continue;
76 std::vector<std::string> str_v = StringUtil::split(s, ':');
77 if (str_v.size() >= 2) {
78 std::string label = StringUtil::replace(StringUtil::replace(str_v[0],
79 " ", ""), "\t", "");
80 if (label.find("[]") != std::string::npos) {
81 if (m_count.find(label) == m_count.end()) {
82 m_count.insert(std::pair<std::string, int>(label, 0));
83 }
84 std::string l = label;
85 label = StringUtil::replace(label, "[]", StringUtil::form("[%d]", m_count[l]));
86 m_count[l] = m_count[l] + 1;
87 }
88 if (str_v.size() > 2) {
89 for (size_t i = 2; i < str_v.size(); i++) {
90 str_v[1].append(":");
91 str_v[1].append(str_v[i]);
92 }
93 }
94 size_t i = 0;
95 std::stringstream ss;
96 for (; i < str_v[1].size(); i++) {
97 if (str_v[1].at(i) == '#' || str_v[1].at(i) == '\n') break;
98 if (str_v[1].at(i) == ' ' || str_v[1].at(i) == '\t') continue;
99 if (str_v[1].at(i) == '"') {
100 for (i++ ; i < str_v[1].size(); i++) {
101 if (str_v[1].at(i) == '"') break;
102 ss << str_v[1].at(i);
103 }
104 break;
105 }
106 if (str_v[1].at(i) == '$') {
107 i++;
108 if (str_v[1].at(i) == '{') {
109 for (i++ ; i < str_v[1].size(); i++) {
110 if (str_v[1].at(i) == '}') break;
111 ss << str_v[1].at(i);
112 }
113 }
114 std::string tmp = ss.str();
115 const char* env = getenv(tmp.c_str());
116 ss.str("");
117 if (env != NULL) {
118 ss << env;
119 } else if (m_value_m.find(tmp) != m_value_m.end()) {
120 ss << m_value_m[tmp];
121 }
122 continue;
123 }
124 ss << str_v[1].at(i);
125 }
126 add(label, ss.str(), overload);
127 }
128 }
129}