Skip to content

Commit

Permalink
Fix for old compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
an-tao committed Nov 28, 2021
1 parent aca3b1d commit eb587b0
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions drogon_ctl/create_swagger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,33 +104,38 @@ class StructNode
}
}
}
return {content.substr(pos1, pos2 - pos1), content.substr(pos2 + 1)};
return std::pair<std::string, std::string>(content.substr(pos1,
pos2 - pos1),
content.substr(pos2 + 1));
}
std::pair<StructNodePtr, std::string> findClass(const std::string &content)
{
LOG_DEBUG << "findClass: " << content;
if (content.empty())
return {nullptr, ""};
return std::pair<StructNodePtr, std::string>(nullptr, "");
std::regex rx(R"(class[ \r\n]+([^ \r\n\{]+)[ \r\n\{:]+)");
std::smatch results;
if (std::regex_search(content, results, rx))
{
assert(results.size() > 1);
auto nextPart =
findContentOfClassOrNameSpace(content, results.position());
return {std::make_shared<StructNode>(nextPart.first,
results[1].str(),
kClass),
nextPart.second};
return std::pair<StructNodePtr, std::string>(
std::make_shared<StructNode>(nextPart.first,
results[1].str(),
kClass),
nextPart.second);
}
return {nullptr, ""};
return std::pair<StructNodePtr, std::string>(nullptr, "");
}
std::tuple<std::string, StructNodePtr, std::string> findNameSpace(
const std::string &content)
{
LOG_DEBUG << "findNameSpace";
if (content.empty())
return {"", nullptr, ""};
return std::tuple<std::string, StructNodePtr, std::string>("",
nullptr,
"");
std::regex rx(R"(namespace[ \r\n]+([^ \r\n]+)[ \r\n]*\{)");
std::smatch results;
if (std::regex_search(content, results, rx))
Expand All @@ -143,11 +148,14 @@ class StructNode
results[1].str(),
kNameSpace);

return {first, npNodePtr, nextPart.second};
return std::tuple<std::string, StructNodePtr, std::string>(
first, npNodePtr, nextPart.second);
}
else
{
return {"", nullptr, ""};
return std::tuple<std::string, StructNodePtr, std::string>("",
nullptr,
"");
}
}
std::vector<StructNodePtr> parse(const std::string &content)
Expand Down Expand Up @@ -221,6 +229,10 @@ class StructNode
{
child->print(indent + 2);
}
if (type_ == kClass)
{
std::cout << content_ << "\n";
}
std::cout << ind << "}";
if (type_ == kClass)
std::cout << ";";
Expand Down

0 comments on commit eb587b0

Please sign in to comment.