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