本文整理汇总了C++中boost::is_any_of方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::is_any_of方法的具体用法?C++ boost::is_any_of怎么用?C++ boost::is_any_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost
的用法示例。
在下文中一共展示了boost::is_any_of方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readNodesFile
void readNodesFile()
{
fstream file;
string buf;
int i=0;
vector<string> strVec;
using boost::is_any_of;
int Value=2;
file.open("ibm01.nodes", ios :: in);
while (getline(file, buf))
{
i++;
if(i>7)
{
boost::algorithm::split(strVec,buf,is_any_of(" "),boost::token_compress_on);
node n;
if (strVec[4] == "terminal")
{
Value = 1;
}
else
{
Value = 0;
}
n.setParameterNodes(strVec[1],atoi(strVec[2].c_str()),atoi(strVec[3].c_str()),Value);
nodeId.insert(pair<string,node>(strVec[1],n));
}
}
file.close();
}
示例2: process_command
string Worker::process_command (string command)
{
DEBUG(cout << command << endl);
trim (command);
vector <string> parts;
split (parts, command, is_any_of (L" "), boost::token_compress_on);
const size_t command_p = 0;
if (parts.size() < 1)
{
return string ("error \"bad command format\"");
}
if (parts [0] == "get")
{
const size_t key_p = 1;
if (parts.size() != 2)
{
return string ("error \"bad get format\"");
}
return process_get (parts [key_p]);
}
if (parts [0] == "set")
{
const size_t ttl_p = 1;
const size_t key_p = 2;
const size_t value_p = 3;
if (parts.size () != 4)
{
return string ("error \"bad set format\"");
}
ttl_t ttl = 0;
try
{
ttl = boost::lexical_cast<ttl_t> (parts [ttl_p]);
}
catch(boost::bad_lexical_cast& e)
{
return string ("error \"bad set format (ttl format)\"");
}
return process_set (parts [key_p], ttl, parts [value_p]);
}
return string ("error \"bad command format\"");
}
示例3: parse_command
command_s Command::parse_command (string command)
{
command_s result;
trim (command);
parse_redirect (command, result);
trim (command);
split (result.params, command, is_any_of (L" "), boost::token_compress_on);
result.name = result.params [0];
//result.params.erase (result.params.begin ());
return result;
}
示例4: parse_dsspfile_bond
/// \brief Parse an hbond from the specified string from within a DSSP line
dsspfile_hbond_opt dssp_dupl_fixture::parse_dsspfile_bond(const string &arg_hbond_string ///< The string containing the DSSP h-bond data (eg "-2,-2.6")
) {
const str_vec parts = split_build<str_vec>( arg_hbond_string, is_any_of( "," ), token_compress_on );
if ( parts.size() != 2 ) {
BOOST_THROW_EXCEPTION(runtime_error_exception("Did not find two parts in DSSP file h-bond"));
}
const int offset = stoi( trim_copy( parts.front() ) );
const double energy = stod( trim_copy( parts.back () ) );
if ( offset == 0 ) {
if ( energy != 0.0 ) {
BOOST_THROW_EXCEPTION(runtime_error_exception("Whilst try to parse H-bond from DSSP file data, non-zero energy for zero offset"));
}
return none;
}
else {
return dsspfile_hbond{ offset, energy };
}
}
示例5: readPlFile
void readPlFile()
{
fstream file;
string buf;
int i=0;
vector<string> strVec;
using boost::is_any_of;
file.open("ibm01.pl", ios :: in);
while (getline(file, buf))
{
i++;
if(i>6)
{
boost::algorithm::split(strVec,buf,is_any_of(" "),boost::token_compress_on);
nodeId[strVec[0]].setParameterPl(atoi(strVec[1].c_str()),atoi(strVec[2].c_str()),strVec[4]);
}
}
file.close();
}
示例6: readWtsFile
void readWtsFile()
{
fstream file;
string buf;
int i=0;
vector<string> strVec;
using boost::is_any_of;
map<string, node>::iterator itr;
file.open("ibm01.wts", ios :: in);
while (getline(file, buf))
{
i++;
if(i>5)
{
boost::algorithm::split(strVec,buf,is_any_of(" "),boost::token_compress_on);
nodeId[strVec[1]].setParameterWts(atoi(strVec[2].c_str()));
}
}
file.close();
}
示例7: ContactCondition
//.........这里部分代码省略.........
std::function<void(CalcNode&)> setter;
if (useValues)
{
xml::Node valuesNode = valuesNodes.front();
vector<string> names = {"vx", "vy", "vz", "sxx", "sxy", "sxz", "syy", "syz", "szz"};
int i = 0;
for (auto value_name: names)
{
string v = valuesNode.getAttributes()[value_name];
values[i++] = v.empty() ? 0.0 : lexical_cast<real>(v);
}
LOG_DEBUG("Initial state values: "
<< values[0] << " " << values[1] << " " << values[2] << " "
<< values[3] << " " << values[4] << " " << values[5] << " "
<< values[6] << " " << values[7] << " " << values[8] );
}
else
{
xml::Node pWaveNode = pWaveNodes.front();
auto attrs = pWaveNode.getAttributes();
auto direction = attrs["direction"];
if (direction.empty())
THROW_INVALID_INPUT("P-wave direction is not specified");
vector<string> _direction;
split(_direction, direction, is_any_of(";"));
if (_direction.size() != 3)
THROW_INVALID_INPUT("Invalid P-wave direction specified");
auto dx = lexical_cast<real>(_direction[0]);
auto dy = lexical_cast<real>(_direction[1]);
auto dz = lexical_cast<real>(_direction[2]);
Vector3 dir({dx, dy, dz});
if (dx == 0.0 && dy == 0.0 && dz == 0.0)
THROW_INVALID_INPUT("Invalid P-wave direction specified");
auto scale = attrs["amplitudeScale"];
if (scale.empty())
THROW_INVALID_INPUT("P-wave amplitude scale is not specified");
auto amplitudeScale = lexical_cast<real>(scale);
if (amplitudeScale <= 0.0)
THROW_INVALID_INPUT("P-wave amplitude must be positive");
auto type = attrs["type"];
if (type.empty())
THROW_INVALID_INPUT("P-wave type is not specified");
if (type != "compression" && type != "rarefaction")
THROW_INVALID_INPUT("Invalid P-wave type specified");
auto compression = type == "compression";
setter = [=](CalcNode& node)
{
setIsotropicElasticPWave(node, dir, amplitudeScale, compression);
};
示例8: readFromAdjacencyList
void readFromAdjacencyList( const string& fname, GraphT& G ) {
typedef typename boost::graph_traits< GraphT >::vertex_descriptor Vertex;
typedef typename boost::graph_traits< GraphT >::edge_descriptor Edge;
typedef unordered_map<string,Vertex> svMap;
svMap namePosMap;
bool inserted;
Vertex u,v;
typename unordered_map<string,Vertex>::iterator pos;
string line;
typedef vector< string > splitVectorT;
ifstream gfile(fname);
size_t numInsertedVerts = 0;
if ( gfile.is_open() ) {
while( gfile.good() ) {
getline( gfile, line, '\n' );
if ( gfile.eof() ) { break; }
boost::algorithm::trim(line);
auto vline = line.substr( 0, line.find_first_of('#') );
splitVectorT splitVec;
split( splitVec, vline, is_any_of(" \t"), token_compress_on );
if ( splitVec.size() > 0 and vline.size() > 0 ) {
auto fromVert = splitVec[0];
boost::tie( pos, inserted ) = namePosMap.insert( std::make_pair(fromVert,Vertex()) );
if (inserted) {
++numInsertedVerts;
u = add_vertex(G);
G[u].name = fromVert;
// This will happen later
// G[u].idx = nameMap[fromVert];
pos->second = u;
} else {
u = pos->second;
}
for( auto tgtIt = splitVec.begin() + 1; tgtIt != splitVec.end(); ++tgtIt ) {
auto& tgt = *tgtIt;
boost::tie(pos, inserted) = namePosMap.insert(std::make_pair(tgt, Vertex()));
if (inserted) {
++numInsertedVerts;
v = add_vertex(G);
G[v].name = tgt;
// This will happen later
// G[v].idx = nameMap[tgt];
pos->second = v;
} else {
v = pos->second;
}
Edge e; bool i;
boost::tie(e,i) = add_edge(u,v,G);
G[e].weight = 1.0;
}
}
}
if ( namePosMap.size() != boost::num_vertices(G) ) {
std::cerr << "(namePosMap.size() = " << namePosMap.size() << ") != ("
<< "(order(G) = " << boost::num_vertices(G) << ") : Error building the graph, aborting\n";
std::abort();
}
}
gfile.close();
}
示例9: readFromMultilineAdjacencyList
void readFromMultilineAdjacencyList( const string& fname, GraphT& G ) {
typedef typename boost::graph_traits< GraphT >::vertex_descriptor Vertex;
typedef typename boost::graph_traits< GraphT >::edge_descriptor Edge;
typedef unordered_map<string,Vertex> svMap;
svMap namePosMap;
bool inserted;
Vertex u,v;
typename unordered_map<string,Vertex>::iterator pos;
bool headLine = false;
size_t remEdgeLine = 0;
string line;
typedef vector< string > splitVectorT;
ifstream gfile(fname);
if ( gfile.is_open() ) {
while( gfile.good() ) {
getline( gfile, line, '\n' );
if ( gfile.eof() ) { break; }
boost::algorithm::trim(line);
auto vline = line.substr( 0, line.find_first_of('#') );
if (vline.length() == 0) { continue; }
splitVectorT splitVec;
split( splitVec, vline, is_any_of(" \t"), token_compress_on );
if ( splitVec.size() > 0 and vline.size() > 0 ) {
auto fromVert = splitVec[0];
remEdgeLine = lexical_cast<size_t>(splitVec[1]);
boost::tie( pos, inserted ) = namePosMap.insert( std::make_pair(fromVert,Vertex()) );
if (inserted) {
u = add_vertex(G);
G[u].name = fromVert;
// This will happen later
// G[u].idx = nameMap[fromVert];
pos->second = u;
} else {
u = pos->second;
}
while ( remEdgeLine > 0 ) {
getline( gfile, line, '\n' );
boost::algorithm::trim(line);
vline = line.substr( 0, line.find_first_of('#') );
split( splitVec, vline, is_any_of(" \t"), token_compress_on );
auto toVert = splitVec[0];
double weight = lexical_cast<double>(splitVec[1]);
boost::tie(pos, inserted) = namePosMap.insert(std::make_pair(toVert, Vertex()));
if (inserted) {
v = add_vertex(G);
G[v].name = toVert;
// This will happen later
// G[v].idx = nameMap[toVert];
pos->second = v;
} else {
v = pos->second;
}
Edge e; bool i;
boost::tie(e,i) = add_edge(u,v,G);
G[e].weight = weight;
remEdgeLine--;
}
}
}
if ( namePosMap.size() != boost::num_vertices(G) ) {
std::cerr << "(namePosMap.size() = " << namePosMap.size() << ") != ("
<< "(order(G) = " << boost::num_vertices(G) << ") : Error building the graph, aborting\n";
std::abort();
}
}
gfile.close();
}