Use std::string_view in a few places where it makes sense
parent
4c58451d83
commit
5c33051990
|
@ -25,6 +25,7 @@
|
|||
#include <numeric>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <string_view>
|
||||
|
||||
#include "DynamicModel.hh"
|
||||
#include "ParsingDriver.hh"
|
||||
|
@ -243,7 +244,7 @@ DynamicModel::writeDynamicPerBlockMFiles(const string &basename) const
|
|||
output << "function [residual, y, T, g1, varargout] = dynamic_" << blk+1 << "(y, x, params, steady_state, T, it_, stochastic_mode)" << endl;
|
||||
|
||||
output << " % ////////////////////////////////////////////////////////////////////////" << endl
|
||||
<< " % //" << " Block "s.substr(static_cast<int>(log10(blk + 1))) << blk+1
|
||||
<< " % //" << " Block "sv.substr(static_cast<int>(log10(blk + 1))) << blk+1
|
||||
<< " //" << endl
|
||||
<< " % // Simulation type "
|
||||
<< BlockSim(simulation_type) << " //" << endl
|
||||
|
@ -1528,9 +1529,12 @@ DynamicModel::parseIncludeExcludeEquations(const string &inc_exc_option_value, b
|
|||
for (auto it = sregex_iterator(tags.begin(), tags.end(), s);
|
||||
it != sregex_iterator(); ++it)
|
||||
{
|
||||
auto str = it->str();
|
||||
if (str[0] == '\'' && str[str.size()-1] == '\'')
|
||||
str = str.substr(1, str.size()-2);
|
||||
string_view str {it->str()};
|
||||
if (str.front() == '\'' && str.back() == '\'')
|
||||
{
|
||||
str.remove_prefix(1);
|
||||
str.remove_suffix(1);
|
||||
}
|
||||
eq_tag_set.emplace_back(tagname, str);
|
||||
}
|
||||
return eq_tag_set;
|
||||
|
|
|
@ -3245,13 +3245,11 @@ ParsingDriver::add_native(string s)
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_native_remove_charset(string str, const string &token)
|
||||
ParsingDriver::add_native_remove_charset(string_view str, string_view token)
|
||||
{
|
||||
size_t found = str.find(token);
|
||||
|
||||
assert(found != string::npos);
|
||||
str.resize(found);
|
||||
add_native(move(str));
|
||||
assert(found != string_view::npos);
|
||||
add_native(string{str.substr(0, found)});
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3261,13 +3259,11 @@ ParsingDriver::add_verbatim(string s)
|
|||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_verbatim_remove_charset(string str, const string &token)
|
||||
ParsingDriver::add_verbatim_remove_charset(string_view str, string_view token)
|
||||
{
|
||||
size_t found = str.find(token);
|
||||
|
||||
assert(found != string::npos);
|
||||
str.resize(found);
|
||||
add_verbatim(str);
|
||||
assert(found != string_view::npos);
|
||||
add_verbatim(string{str.substr(0, found)});
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <istream>
|
||||
#include <stack>
|
||||
#include <optional>
|
||||
#include <string_view>
|
||||
|
||||
#include "ModFile.hh"
|
||||
#include "SymbolList.hh"
|
||||
|
@ -849,11 +850,11 @@ public:
|
|||
//! Adds a native statement
|
||||
void add_native(string s);
|
||||
//! Adds a native statement, first removing the set of characters passed in token (and everything after)
|
||||
void add_native_remove_charset(string str, const string &token);
|
||||
void add_native_remove_charset(string_view str, string_view token);
|
||||
//! Adds a verbatim statement
|
||||
void add_verbatim(string s);
|
||||
//! Adds a verbatim statement, first removing the set of characters passed in token (and everything after)
|
||||
void add_verbatim_remove_charset(string str, const string &token);
|
||||
void add_verbatim_remove_charset(string_view str, string_view token);
|
||||
//! Resets data_tree and model_tree pointers to default (i.e. mod_file->expressions_tree)
|
||||
void reset_data_tree();
|
||||
//! Begin a steady_state_model block
|
||||
|
|
|
@ -124,7 +124,7 @@ StaticModel::writeStaticPerBlockMFiles(const string &basename) const
|
|||
output << "function [residual, y, T, g1] = static_" << blk+1 << "(y, x, params, T)" << endl;
|
||||
|
||||
output << " % ////////////////////////////////////////////////////////////////////////" << endl
|
||||
<< " % //" << " Block "s.substr(static_cast<int>(log10(blk + 1))) << blk+1
|
||||
<< " % //" << " Block "sv.substr(static_cast<int>(log10(blk + 1))) << blk+1
|
||||
<< " //" << endl
|
||||
<< " % // Simulation type "
|
||||
<< BlockSim(simulation_type) << " //" << endl
|
||||
|
|
Loading…
Reference in New Issue