本文整理汇总了C++中separator函数的典型用法代码示例。如果您正苦于以下问题:C++ separator函数的具体用法?C++ separator怎么用?C++ separator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了separator函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: input
wxString* PROJECT_TEMPLATE::GetTitle(void)
{
wxFileInputStream input( GetHtmlFile().GetFullPath() );
wxString separator( wxT( "\x9" ) );
wxTextInputStream text( input, separator, wxConvUTF8 );
/* Open HTML file and get the text between the title tags */
if( title == wxEmptyString )
{
int start = 0;
int finish = 0;
bool done = false;
while( input.IsOk() && !input.Eof() && !done )
{
wxString line = text.ReadLine();
start = line.Find( wxT( "<title>" ) );
if( start == wxNOT_FOUND )
start = line.Find( wxT( "<TITLE>" ) );
finish = line.Find( wxT( "</title>" ) );
if( finish == wxNOT_FOUND )
finish = line.Find( wxT( "</TITLE>" ) );
// find the opening tag
if( start != wxNOT_FOUND )
{
if( finish != wxNOT_FOUND )
{
title = line.SubString( start + 7, finish );
}
else
{
title = line.SubString( start + 7, line.Len() - 1 );
done = true;
}
}
else
{
if( finish != wxNOT_FOUND )
{
title += line.SubString( 0, finish );
done = true;
}
else
{
title += line;
}
}
// Remove line endings
title.Replace( wxT( "\r" ), wxT( "" ) );
title.Replace( wxT( "\n" ), wxT( "" ) );
}
}
return &title;
}
示例2: clear
void PathListEditor::setPathList(const QString &pathString)
{
if (pathString.isEmpty()) {
clear();
} else {
setPathList(pathString.split(separator(), QString::SkipEmptyParts));
}
}
示例3: Split
/*! \fn
* Split a line (series of characters) with the given delimiter
* @param line Input string in order to be split by the given delimiter
* @param delim Series of delimiters (each delimiter character is followed by the next one in a single string variable) in order to split the given string
* @return Vector of elements of the given string that have been split by the given delimiter(s)
*/
inline std::vector<std::string> Split(std::string line, std::string delim)
{
boost::char_separator<char> separator(delim.c_str());
boost::tokenizer< boost::char_separator<char> > tokens(line, separator);
std::vector<std::string> vectorTokens = std::vector<std::string>();
vectorTokens.assign(tokens.begin(), tokens.end());
return vectorTokens;
}
示例4: _collision_sphere_convex_polygon
static void _collision_sphere_convex_polygon(const ShapeSW *p_a, const Transform &p_transform_a, const ShapeSW *p_b, const Transform &p_transform_b, _CollectorCallback *p_collector, real_t p_margin_a, real_t p_margin_b) {
const SphereShapeSW *sphere_A = static_cast<const SphereShapeSW *>(p_a);
const ConvexPolygonShapeSW *convex_polygon_B = static_cast<const ConvexPolygonShapeSW *>(p_b);
SeparatorAxisTest<SphereShapeSW, ConvexPolygonShapeSW, withMargin> separator(sphere_A, p_transform_a, convex_polygon_B, p_transform_b, p_collector, p_margin_a, p_margin_b);
if (!separator.test_previous_axis())
return;
const Geometry::MeshData &mesh = convex_polygon_B->get_mesh();
const Geometry::MeshData::Face *faces = mesh.faces.ptr();
int face_count = mesh.faces.size();
const Geometry::MeshData::Edge *edges = mesh.edges.ptr();
int edge_count = mesh.edges.size();
const Vector3 *vertices = mesh.vertices.ptr();
int vertex_count = mesh.vertices.size();
// faces of B
for (int i = 0; i < face_count; i++) {
Vector3 axis = p_transform_b.xform(faces[i].plane).normal;
if (!separator.test_axis(axis))
return;
}
// edges of B
for (int i = 0; i < edge_count; i++) {
Vector3 v1 = p_transform_b.xform(vertices[edges[i].a]);
Vector3 v2 = p_transform_b.xform(vertices[edges[i].b]);
Vector3 v3 = p_transform_a.origin;
Vector3 n1 = v2 - v1;
Vector3 n2 = v2 - v3;
Vector3 axis = n1.cross(n2).cross(n1).normalized();
if (!separator.test_axis(axis))
return;
}
// vertices of B
for (int i = 0; i < vertex_count; i++) {
Vector3 v1 = p_transform_b.xform(vertices[i]);
Vector3 v2 = p_transform_a.origin;
Vector3 axis = (v2 - v1).normalized();
if (!separator.test_axis(axis))
return;
}
separator.generate_contacts();
}
示例5: foo
int foo(void) {
// Both MSVC and GCC do the ++ after the assignment !
*buffp = buffer[(*buffa) ++];
separator(1);
// Both MSVC and GCC do the ++ before the call to bar !
// buffb is incremented first in both compilers
*buffp = bar(buffer[(*buffa) ++] + buffer[(*buffb) ++]);
separator(2);
// The +7 must be done before the assignment
*buffp = buffer[(*buffa) += 7];
separator(3);
bar((*buffa) ++) + bar((*buffb) ++);
separator(4);
buffer[*buffp + 4] = buffer[(*buffa) ++] + f2(f1((*buffb)++), (*buffc) ++);
return *buffp;
}
示例6: UserString
void OptionsDB::GetUsage(std::ostream& os, const std::string& command_line/* = ""*/) const {
os << UserString("COMMAND_LINE_USAGE") << command_line << "\n";
int longest_param_name = 0;
for (const std::map<std::string, Option>::value_type& option : m_options) {
if (longest_param_name < static_cast<int>(option.first.size()))
longest_param_name = option.first.size();
}
int description_column = 5;
int description_width = 80 - description_column;
if (description_width <= 0)
throw std::runtime_error("The longest parameter name leaves no room for a description.");
for (const std::map<std::string, Option>::value_type& option : m_options) {
// Ignore unrecognized options that have not been formally registered
// with Add().
if (!option.second.recognized)
continue;
if (option.second.short_name)
os << "-" << option.second.short_name << ", --" << option.second.name << "\n";
else
os << "--" << option.second.name << "\n";
os << std::string(description_column - 1, ' ');
typedef boost::tokenizer<boost::char_separator<char>> Tokenizer;
boost::char_separator<char> separator(" \t");
Tokenizer tokens(UserString(option.second.description), separator);
int curr_column = description_column;
for (const Tokenizer::value_type& token : tokens) {
if (80 < curr_column + token.size()) {
os << "\n" << std::string(description_column, ' ') << token;
curr_column = description_column + token.size();
} else {
os << " " << token;
curr_column += token.size() + 1;
}
}
if (option.second.validator) {
std::stringstream stream;
stream << UserString("COMMAND_LINE_DEFAULT") << option.second.DefaultValueToString();
if (80 < curr_column + stream.str().size() + 3) {
os << "\n" << std::string(description_column, ' ') << stream.str() << "\n";
} else {
os << " | " << stream.str() << "\n";
}
} else {
os << "\n";
}
os << "\n";
}
}
示例7: StringToList
std::vector<std::string> StringToList(const std::string& input_string) {
std::vector<std::string> retval;
typedef boost::tokenizer<boost::char_separator<char>> Tokenizer;
boost::char_separator<char> separator(",");
Tokenizer tokens(input_string, separator);
for (const Tokenizer::value_type& token : tokens) {
retval.push_back(token);
}
return retval;
}
示例8: getNextFilePath
std::string UDir::getNextFilePath()
{
std::string filePath;
if(iFileName_ != fileNames_.end())
{
filePath = path_+separator()+*iFileName_;
++iFileName_;
}
return filePath;
}
示例9: separator
/**
* Adds a border & timestamp to the message
* @param msg
* @return A new string with the required formatting
*/
QString ScriptOutputDisplay::addTimestamp(const QString &msg) {
QString separator(75, '-');
QString timestamped = "%1\n"
"%2: %3\n"
"%4\n";
timestamped =
timestamped.arg(separator, QDateTime::currentDateTime().toString(),
msg.trimmed(), separator);
return timestamped;
}
示例10: separator
void ArSocket::separateHost(const char *rawHost, int rawPort, char *useHost,
size_t useHostSize, int *port)
{
if (useHost == NULL)
{
ArLog::log(ArLog::Normal, "ArSocket: useHost was NULL");
return;
}
if (port == NULL)
{
ArLog::log(ArLog::Normal, "ArSocket: port was NULL");
return;
}
useHost[0] = '\0';
if (rawHost == NULL || rawHost[0] == '\0')
{
ArLog::log(ArLog::Normal, "ArSocket: rawHost was NULL or empty");
return;
}
ArArgumentBuilder separator(512, ':');
separator.add(rawHost);
if (separator.getArgc() <= 0)
{
ArLog::log(ArLog::Normal, "ArSocket: rawHost was empty");
return;
}
if (separator.getArgc() == 1)
{
snprintf(useHost, useHostSize, separator.getArg(0));
*port = rawPort;
return;
}
if (separator.getArgc() == 2)
{
if (separator.isArgInt(1))
{
snprintf(useHost, useHostSize, separator.getArg(0));
*port = separator.getArgInt(1);
return;
}
else
{
ArLog::log(ArLog::Normal, "ArSocket: port given in hostname was not an integer it was %s", separator.getArg(1));
return;
}
}
// if we get down here there's too many args
ArLog::log(ArLog::Normal, "ArSocket: too many arguments in hostname %s", separator.getFullString());
return;
}
示例11: tree_output
static void
tree_output()
{
Symbol **symbols, *main_sym;
int i, num;
/* Collect and sort symbols */
num = collect_symbols(&symbols, is_var);
qsort(symbols, num, sizeof(*symbols), compare);
/* Scan and mark the recursive ones */
for (i = 0; i < num; i++) {
if (symbols[i]->callee)
scan_tree(0, symbols[i]);
}
/* Produce output */
begin();
if (reverse_tree) {
for (i = 0; i < num; i++) {
inverted_tree(0, 0, symbols[i]);
separator();
}
} else {
main_sym = lookup(start_name);
if (main_sym) {
direct_tree(0, 0, main_sym);
separator();
} else {
for (i = 0; i < num; i++) {
if (symbols[i]->callee == NULL)
continue;
direct_tree(0, 0, symbols[i]);
separator();
}
}
}
end();
free(symbols);
}
示例12: _collision_circle_rectangle
static void _collision_circle_rectangle(const Shape2DSW* p_a,const Matrix32& p_transform_a,const Shape2DSW* p_b,const Matrix32& p_transform_b,_CollectorCallback2D *p_collector,const Vector2& p_motion_a,const Vector2& p_motion_b,float p_margin_A,float p_margin_B) {
const CircleShape2DSW *circle_A = static_cast<const CircleShape2DSW*>(p_a);
const RectangleShape2DSW *rectangle_B = static_cast<const RectangleShape2DSW*>(p_b);
SeparatorAxisTest2D<CircleShape2DSW,RectangleShape2DSW,castA,castB,withMargin> separator(circle_A,p_transform_a,rectangle_B,p_transform_b,p_collector,p_motion_a,p_motion_b,p_margin_A,p_margin_B);
if (!separator.test_previous_axis())
return;
if (!separator.test_cast())
return;
const Vector2 &sphere=p_transform_a.elements[2];
const Vector2 *axis=&p_transform_b.elements[0];
// const Vector2& half_extents = rectangle_B->get_half_extents();
if (!separator.test_axis(axis[0].normalized()))
return;
if (!separator.test_axis(axis[1].normalized()))
return;
Matrix32 binv = p_transform_b.affine_inverse();
{
if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv,sphere ) ) )
return;
}
if (castA) {
Vector2 sphereofs = sphere + p_motion_a;
if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv, sphereofs) ) )
return;
}
if (castB) {
Vector2 sphereofs = sphere - p_motion_b;
if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv, sphereofs) ) )
return;
}
if (castA && castB) {
Vector2 sphereofs = sphere - p_motion_b + p_motion_a;
if (!separator.test_axis( rectangle_B->get_circle_axis(p_transform_b,binv, sphereofs) ) )
return;
}
separator.generate_contacts();
}
示例13: eolDelimiter
static QString eolDelimiter(const QString& str)
{
// find the split character
QString separator('\n');
if (str.indexOf("\r\n") != -1) {
separator = "\r\n";
} else if (str.indexOf('\r') != -1 ) {
separator = '\r';
}
return separator;
}
示例14: separator
std::string MixAll::filterIP(const std::string& addr) {
std::string separator(",");
if (addr.find(separator) == std::string::npos) {
return addr;
} else {
std::vector<std::string> ips;
std::string::size_type previous = 0;
std::string::size_type current = std::string::npos;
while ((current = addr.find(separator, previous)) != std::string::npos) {
std::string ip = addr.substr(previous, current - previous);
ips.push_back(ip);
previous = current + 1;
if (current == addr.find_last_of(separator)) {
ips.push_back(addr.substr(previous));
break;
}
}
struct ifaddrs* if_addr = nullptr;
if (getifaddrs(&if_addr) == -1) {
// TODO log error.
std::cout << "Failed to execute getifaddrs()" << std::endl;
}
// Choose IP that share the same subnet with current host.
for (std::vector<std::string>::iterator it = ips.begin(); it != ips.end(); it++) {
struct sockaddr_in sock;
inet_pton(AF_INET, it->c_str(), &sock.sin_addr.s_addr);
struct ifaddrs* p = if_addr;
while (p != nullptr) {
if(p->ifa_addr->sa_family == AF_INET) {
struct sockaddr_in* ip_addr = (struct sockaddr_in*)p->ifa_addr;
struct sockaddr_in* netmask_addr = (struct sockaddr_in*)p->ifa_netmask;
if ((ip_addr->sin_addr.s_addr & netmask_addr->sin_addr.s_addr) == (sock.sin_addr.s_addr & netmask_addr->sin_addr.s_addr)) {
return *it;
}
}
p = p->ifa_next;
}
}
// If not found in the previous step, choose a public IP address.
for (std::string ip : ips) {
if (is_public_ip(ip)) {
return ip;
}
}
// Just return the first one and warn.
std::cout << "Unable to figure out an ideal IP, returning the first candiate." << std::endl;
return ips[0];
}
}
示例15: eolDelimiter
static QString eolDelimiter(const QString &str)
{
// find the split character
QString separator(QLatin1Char('\n'));
if (str.indexOf(QStringLiteral("\r\n")) != -1) {
separator = QStringLiteral("\r\n");
} else if (str.indexOf(QLatin1Char('\r')) != -1) {
separator = QLatin1Char('\r');
}
return separator;
}