本文整理汇总了C++中poco::regularexpression::MatchVec类的典型用法代码示例。如果您正苦于以下问题:C++ MatchVec类的具体用法?C++ MatchVec怎么用?C++ MatchVec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MatchVec类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkShaderInfoLog
//--------------------------------------------------------------
void ofShader::checkShaderInfoLog(GLuint shader, GLenum type, ofLogLevel logLevel) {
GLsizei infoLength;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLength);
if (infoLength > 1) {
GLchar* infoBuffer = new GLchar[infoLength];
glGetShaderInfoLog(shader, infoLength, &infoLength, infoBuffer);
ofLog(logLevel, "ofShader: %s shader reports:\n%s", nameForType(type).c_str(), infoBuffer);
if (shaderSource.find(type) != shaderSource.end()) {
// The following regexp should match shader compiler error messages by Nvidia and ATI.
// Unfortunately, each vendor's driver formats error messages slightly different.
Poco::RegularExpression re("^.*[(:]{1}(\\d+)[:)]{1}.*");
Poco::RegularExpression::MatchVec matches;
string infoString = (infoBuffer != NULL) ? string(infoBuffer): "";
re.match(infoString, 0, matches);
ofBuffer buf = shaderSource[type];
ofBuffer::Line line = buf.getLines().begin();
if (!matches.empty()){
int offendingLineNumber = ofToInt(infoString.substr(matches[1].offset, matches[1].length));
ostringstream msg;
msg << "ofShader: " + nameForType(type) + ", offending line " << offendingLineNumber << " :"<< endl;
for(int i=0; line != buf.getLines().end(); line++, i++ ){
string s = *line;
if ( i >= offendingLineNumber -3 && i < offendingLineNumber + 2 ){
msg << "\t" << setw(5) << (i+1) << "\t" << s << endl;
}
}
ofLog(logLevel) << msg.str();
}
}
delete [] infoBuffer;
}
}
示例2: checkProgramInfoLog
//--------------------------------------------------------------
void ofShader::checkProgramInfoLog(GLuint program) {
GLsizei infoLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLength);
if (infoLength > 1) {
GLchar* infoBuffer = new GLchar[infoLength];
glGetProgramInfoLog(program, infoLength, &infoLength, infoBuffer);
string msg = "ofShader: program reports:\n";
#ifdef TARGET_RASPBERRYPI
if (shaderSource.find(GL_FRAGMENT_SHADER) != shaderSource.end()) {
Poco::RegularExpression re(",.line.([^\\)]*)");
Poco::RegularExpression::MatchVec matches;
string infoString = (infoBuffer != NULL) ? string(infoBuffer): "";
re.match(infoString, 0, matches);
ofBuffer buf = shaderSource[GL_FRAGMENT_SHADER];
ofBuffer::Line line = buf.getLines().begin();
if (!matches.empty()){
int offendingLineNumber = ofToInt(infoString.substr(matches[1].offset, matches[1].length));
ostringstream msg;
msg << "ofShader: " + nameForType(GL_FRAGMENT_SHADER) + ", offending line " << offendingLineNumber << " :"<< endl;
for(int i=0; line != buf.getLines().end(); line++, i++ ){
string s = *line;
if ( i >= offendingLineNumber -3 && i < offendingLineNumber + 2 ){
msg << "\t" << setw(5) << (i+1) << "\t" << s << endl;
}
}
ofLogError("ofShader") << msg.str();
}
}
#endif
ofLogError("ofShader", msg + infoBuffer);
delete [] infoBuffer;
}
}
示例3: readRectangularMasks
/// Read rectangular masks from a config file string
/// @param line :: line (string) from the config file
void EQSANSLoad::readRectangularMasks(const std::string& line)
{
// Looking for rectangular mask
// Rectangular mask = 7, 0; 7, 255
Poco::RegularExpression re_key("rectangular mask", Poco::RegularExpression::RE_CASELESS);
Poco::RegularExpression re_key_alt("elliptical mask", Poco::RegularExpression::RE_CASELESS);
Poco::RegularExpression::Match match;
if (re_key.match(line, 0, match) || re_key_alt.match(line, 0, match))
{
Poco::RegularExpression re_sig("=[ ]*([0-9]+)[ ]*[ ,][ ]*([0-9]+)[ ]*[ ;,][ ]*([0-9]+)[ ]*[ ,][ ]*([0-9]+)");
if (re_sig.match(line, 0, match))
{
Poco::RegularExpression::MatchVec posVec;
re_sig.match(line, 0, posVec);
if (posVec.size()==5)
{
for (int i=0; i<4; i++)
{
std::string num_str = line.substr(posVec[i+1].offset, posVec[i+1].length);
m_mask_as_string = m_mask_as_string + " " + num_str;
}
m_mask_as_string += ",";
}
}
}
}
示例4: setType
void WindowFunction::setType(const std::string &type)
{
//parse the input
Poco::RegularExpression::MatchVec matches;
Poco::RegularExpression("^\\s*(\\w+)\\s*(\\((.*)\\))?\\s*$").match(type, 0, matches);
if (matches.empty()) throw Pothos::InvalidArgumentException("WindowFunction("+type+")", "cant parse window type");
//parse the args
Poco::JSON::Array::Ptr args(new Poco::JSON::Array());
if (matches.size() > 3)
{
auto argsStr = type.substr(matches[3].offset, matches[3].length);
Poco::JSON::Parser p; p.parse("["+argsStr+"]");
args = p.getHandler()->asVar().extract<Poco::JSON::Array::Ptr>();
}
//check input
auto name = Poco::toLower(type.substr(matches[1].offset, matches[1].length));
if (name == "kaiser")
{
if (args->size() != 1) throw Pothos::InvalidArgumentException("WindowFunction("+type+")", "expects format: kaiser(beta)");
}
else if (args->size() != 0) throw Pothos::InvalidArgumentException("WindowFunction("+type+")", name + " takes no arguments");
//bind window function
if (name == "rectangular") _calc = &rectangular;
else if (name == "hann") _calc = &hann;
else if (name == "hamming") _calc = &hamming;
else if (name == "blackman") _calc = &blackman;
else if (name == "bartlett") _calc = &bartlett;
else if (name == "flattop") _calc = &flattop;
else if (name == "kaiser") _calc = std::bind(&kaiser, std::placeholders::_1, std::placeholders::_2, args->getElement<double>(0));
else throw Pothos::InvalidArgumentException("WindowFunction::setType("+type+")", "unknown window name");
this->reload();
}
示例5: singleInfo
bool singleInfo(const std::string & subject, std::string & info)
{
Poco::RegularExpression rg1("^([0-9]{5}) ([0-9]{14}) .+^RE .{28} ([0-9/,]{2}) ([0-9/,]{5}) .+^SP ([0-9/,]{4})",
Poco::RegularExpression::RE_MULTILINE| Poco::RegularExpression::RE_DOTALL| Poco::RegularExpression::RE_NEWLINE_ANYCRLF);
Poco::RegularExpression::MatchVec matchs;
int m = rg1.match(subject,0,matchs);
if(6 != m) return false;
//std::cout<<m<<matchs.size()<<"\n"<<subject<<std::endl;
//std::cin>>info;
std::vector< std::string > record;
std::vector< bool > lossrecord(5, false);
for(size_t i=1; i!=matchs.size(); i++)
{
record.push_back( subject.substr(matchs[i].offset, matchs[i].length) );
lossrecord[i-1] = std::string::npos != record[i-1].find('/');
}
if(lossrecord[3] && lossrecord[4] )//ͬʱȱ²â
{
return false;
}
for(size_t i=2; i<5; i++)
{
if(lossrecord[i])
{
record[i] = "99999";
}
else if( std::string::npos != record[i].find(',') )
{
record[i] = "1";
}
else if(i>2)
{
record[i] += '0';
}
}
for(size_t i=0; i<record.size(); i++)
{
info += record[i] + ' ';
}
info[info.size()-1] = '\n';
return true;
}
示例6: readModeratorPosition
/// Read the moderator position from a config file string
/// @param line :: line (string) from the config file
void EQSANSLoad::readModeratorPosition(const std::string& line)
{
Poco::RegularExpression re_key("sample location", Poco::RegularExpression::RE_CASELESS);
Poco::RegularExpression::Match match;
if (re_key.match(line, 0, match))
{
Poco::RegularExpression re_sig("=[ ]*([0-9]+)");
if (re_sig.match(line, 0, match))
{
Poco::RegularExpression::MatchVec posVec;
re_sig.match(line, 0, posVec);
if (posVec.size()==2)
{
std::string num_str = line.substr(posVec[1].offset, posVec[1].length);
Poco::NumberParser::tryParseFloat(num_str, m_moderator_position);
m_moderator_position = -m_moderator_position/1000.0;
}
}
}
}
示例7: readBeamCenter
/// Read the beam center from a config file string
/// @param line :: line (string) from the config file
void EQSANSLoad::readBeamCenter(const std::string& line)
{
Poco::RegularExpression re_key("spectrum center", Poco::RegularExpression::RE_CASELESS);
Poco::RegularExpression::Match match;
if (re_key.match(line, 0, match))
{
Poco::RegularExpression re_sig("=[ ]*([0-9]+.[0-9]*)[ ]*[ ,][ ]*([0-9]+.[0-9]+)");
if (re_sig.match(line, 0, match))
{
Poco::RegularExpression::MatchVec posVec;
re_sig.match(line, 0, posVec);
if (posVec.size()==3)
{
std::string num_str = line.substr(posVec[1].offset, posVec[1].length);
Poco::NumberParser::tryParseFloat(num_str, m_center_x);
num_str = line.substr(posVec[2].offset, posVec[2].length);
Poco::NumberParser::tryParseFloat(num_str, m_center_y);
}
}
}
}
示例8: readTOFcuts
/// Read the TOF cuts from a config file string
/// @param line :: line (string) from the config file
void EQSANSLoad::readTOFcuts(const std::string& line)
{
Poco::RegularExpression re_key("tof edge discard", Poco::RegularExpression::RE_CASELESS);
Poco::RegularExpression::Match match;
if (re_key.match(line, 0, match))
{
Poco::RegularExpression re_sig("=[ ]*([0-9]+)[ ]*[ ,][ ]*([0-9]+)");
if (re_sig.match(line, 0, match))
{
Poco::RegularExpression::MatchVec posVec;
re_sig.match(line, 0, posVec);
if (posVec.size()==3)
{
std::string num_str = line.substr(posVec[1].offset, posVec[1].length);
Poco::NumberParser::tryParseFloat(num_str, m_low_TOF_cut);
num_str = line.substr(posVec[2].offset, posVec[2].length);
Poco::NumberParser::tryParseFloat(num_str, m_high_TOF_cut);
}
}
}
}
示例9: readSourceSlitSize
/// Read the source slit sizes from a config file string
/// @param line :: line (string) from the config file
void EQSANSLoad::readSourceSlitSize(const std::string& line)
{
Poco::RegularExpression re_key("wheel", Poco::RegularExpression::RE_CASELESS);
Poco::RegularExpression::Match match;
if (re_key.match(line, 0, match))
{
Poco::RegularExpression re_sig("([1-8]) wheel[ ]*([1-3])[ \\t]*=[ \\t]*(\\w+)");
if (re_sig.match(line, 0, match))
{
Poco::RegularExpression::MatchVec posVec;
re_sig.match(line, 0, posVec);
if (posVec.size()==2)
{
std::string num_str = line.substr(posVec[1].offset, posVec[1].length);
int slit_number = 0;
Poco::NumberParser::tryParse(num_str, slit_number);
slit_number--;
num_str = line.substr(posVec[2].offset, posVec[2].length);
int wheel_number = 0;
Poco::NumberParser::tryParse(num_str, wheel_number);
wheel_number--;
num_str = line.substr(posVec[3].offset, posVec[3].length);
Poco::RegularExpression re_size("\\w*?([0-9]+)mm");
int slit_size = 0;
re_size.match(num_str, 0, posVec);
if (posVec.size()==2)
{
num_str = line.substr(posVec[1].offset, posVec[1].length);
Poco::NumberParser::tryParse(num_str, slit_size);
}
m_slit_positions[wheel_number][slit_number] = slit_size;
}
}
}
}
示例10: determineAnimated
void ofxTPSpriteData::determineAnimated() {
Poco::RegularExpression reg("((?:(?![\\d]*[.].*$)[\\w\\s])+)([\\d]*)([.].*)$");
// int match(const std::string& subject, Match& mtch, int options = 0) const;
Poco::RegularExpression::MatchVec matches;
int numberOfMatches = reg.match(name, 0, matches);
if(!matches.empty()){
if(matches[0].length != 0) {
if (matches[2].length > 0) {
if (matches[1].length > 0) {
animationName = name.substr(matches[1].offset, matches[1].length);
if(animationName.substr(animationName.size()-1, animationName.size()) == "_") {
animationName = animationName.substr(0, animationName.size()-1);
}
}
bAnimated = true;
frame = ofToInt(name.substr(matches[2].offset, matches[2].length));
} else {
bAnimated = false;
}
}
else {
ofLog(OF_LOG_ERROR, "ERROR: Filename format not recognised for " + name);
}
} else {
// Make sure not to Trim names in Texture Packer! if you debug your way here!
bAnimated = false;
}
//---------- CP-11 version
/**
if (reg.match(name, matches)) {
if (subStrings.length(2) > 0) {
if (subStrings.length(1) > 0) {
animationName = subStrings[1];
}
isAnimated = true;
frame = ofToInt(subStrings[2]);
} else {
isAnimated = false;
}
} else {
ofLog(OF_LOG_ERROR, "ERROR: Filename format not recognised for " + name);
}
smatch subStrings;
regex expression ("((?:(?![\\d]*[.].*$)[\\w\\s])+)([\\d]*)([.].*)$");
if (regex_match(name, subStrings, expression)) {
if (subStrings.length(2) > 0) {
if (subStrings.length(1) > 0) {
animationName = subStrings[1];
}
isAnimated = true;
frame = ofToInt(subStrings[2]);
} else {
isAnimated = false;
}
} else {
ofLog(OF_LOG_ERROR, "ERROR: Filename format not recognised for " + name);
}
*/
}