Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions source/module_io/input_conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,45 @@ template <typename T> void Input_Conv::parse_expression(const std::string &fn, s
int count = 0;
std::string pattern("([0-9]+\\*[0-9.]+|[0-9,.]+)");
std::vector<std::string> str;
std::string::size_type pos1, pos2;
std::string c = " ";
pos2 = fn.find(c);
pos1 = 0;
while (std::string::npos != pos2)
{
str.push_back(fn.substr(pos1, pos2 - pos1));
pos1 = pos2 + c.size();
pos2 = fn.find(c, pos1);
}
if (pos1 != fn.length())
{
str.push_back(fn.substr(pos1));
std::stringstream ss(fn);
std::string section;
while (ss >> section) {
int index = 0;
if (str.empty()) {
while (index < section.size() && std::isspace(section[index])) {
index++;
}
}
section.erase(0, index);
str.push_back(section);
}
// std::string::size_type pos1, pos2;
// std::string c = " ";
// pos2 = fn.find(c);
// pos1 = 0;
// while (std::string::npos != pos2)
// {
// str.push_back(fn.substr(pos1, pos2 - pos1));
// pos1 = pos2 + c.size();
// pos2 = fn.find(c, pos1);
// }
// if (pos1 != fn.length())
// {
// str.push_back(fn.substr(pos1));
// }
regex_t reg;
regcomp(&reg, pattern.c_str(), REG_EXTENDED);
regmatch_t pmatch[1];
const size_t nmatch = 1;
for (int i = 0; i < str.size(); ++i)
for (size_t i = 0; i < str.size(); ++i)
{
if (str[i] == "")
{
continue;
}
int status = regexec(&reg, str[i].c_str(), nmatch, pmatch, 0);
std::string sub_str = "";
for (int j = pmatch[0].rm_so; j != pmatch[0].rm_eo; ++j)
for (size_t j = pmatch[0].rm_so; j != pmatch[0].rm_eo; ++j)
{
sub_str += str[i][j];
}
Expand All @@ -78,8 +90,8 @@ template <typename T> void Input_Conv::parse_expression(const std::string &fn, s
// std::vector<double> ocp_temp(num, occ);
// const std::vector<double>::iterator dest = vec.begin() + count;
// copy(ocp_temp.begin(), ocp_temp.end(), dest);
//count += num;
for (size_t i = 0; i != num; i++)
// count += num;
for (size_t k = 0; k != num; k++)
vec.emplace_back(occ);
}
else
Expand Down