当前位置: 首页>>代码示例>>C++>>正文


C++ boost::regex_match方法代码示例

本文整理汇总了C++中boost::regex_match方法的典型用法代码示例。如果您正苦于以下问题:C++ boost::regex_match方法的具体用法?C++ boost::regex_match怎么用?C++ boost::regex_match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boost的用法示例。


在下文中一共展示了boost::regex_match方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: utr_io_filter_filenames

//---------------------------------------------------------
// utr_io_filter_filename - to filter filenames with given regular expression
//---------------------------------------------------------
void utr_io_filter_filenames(std::vector<string>& Filenames, // vector of filenames
							   const char * Regex // regular expression to test against
							   // during filtering
							 )
{
  using boost::regex;
  using boost::smatch;
  using boost::regex_match;

  typedef std::vector<string>::iterator iter;
  
  assert( Regex != NULL );
  assert( Filenames.size() > 0 );

  const char * r = Regex;
  if(Regex[0]=='.' && Regex[1]=='/') {
      mf_log_warn(" 'File name regex' begins with './' - stripping that from regular expression.");
      r += 2;
  }

  regex re(r);
  smatch what;

  // Find entries that DON'T MATCH and remove them.
  iter it(Filenames.begin());
  while( it != Filenames.end() ) {
	if( regex_match(*it,what,re) == false ) {
	  it = Filenames.erase(it);
	} else {
	  ++it;
	}
  }//!for 
}
开发者ID:nestaaaa,项目名称:mgrmgrabarc,代码行数:36,代码来源:uts_io_intf.cpp

示例2: isRadianceName

bool Ave::isRadianceName(const string &variableName) {
    using boost::regex;
    using boost::regex_match;

    static const regex regularExpression("(solar_irradiance|L)_[0-9][0-9]?(_er)?");
    return regex_match(variableName, regularExpression);
}
开发者ID:bcdev,项目名称:s3-synergy,代码行数:7,代码来源:Ave.cpp

示例3: TryParse

Language Language::TryParse(const std::wstring& s)
{
    if (IsValidCode(s))
        return Language(s);

    // Is it a standard language code?
    if (regex_match(s, RE_LANG_CODE_PERMISSIVE))
    {
        std::wstring s2(s);
        TryNormalize(s2);
        if (IsValidCode(s2))
            return Language(s2);
    }

    // If not, perhaps it's a human-readable name (perhaps coming from the language control)?
    auto names = GetDisplayNamesData();
    icu::UnicodeString s_icu = ToIcuStr(s);
    s_icu.foldCase();
    std::wstring folded = StdFromIcuStr(s_icu);
    auto i = names.names.find(folded);
    if (i != names.names.end())
        return Language(i->second);

    // Maybe it was in English?
    i = names.namesEng.find(folded);
    if (i != names.namesEng.end())
        return Language(i->second);

    return Language(); // invalid
}
开发者ID:vnwildman,项目名称:poedit,代码行数:30,代码来源:language.cpp

示例4: defined

void BigInteger::Private::assign( const std::string & s ) {
#if defined( __GNUC__ ) && !defined(__clang__)
	using boost::regex;
	using boost::smatch;
	using boost::regex_match;
#else
	using std::regex;
	using std::smatch;
	using std::regex_match;
#endif

	regex pattern( "^(0)|((-?)([1-9]\\d*))$" );
	smatch m;
	if( !regex_match( s, m, pattern ) ) {
		throw ValueError( "invalid number" );
	}
	if( m[1].matched ) {
		this->v.push_back( 0 );
	} else {
		if( m[3].length() != 0 ) {
			this->minus = true;
		}
		std::string buffer( m[4] );
		// add padding to 3 multiple
		if( s.size() % 3 != 0 ) {
			buffer.insert( 0, 3 - s.size() % 3, ' ' );
		}
		for( std::size_t i = 0; i < buffer.size(); i += 3 ) {
			std::istringstream sin( buffer.substr( i, 3 ) );
			int j = -1;
			sin >> j;
			this->v.insert( this->v.begin(), j );
		}
	}
}
开发者ID:Manuel4131,项目名称:junkcode,代码行数:35,代码来源:biginteger.cpp

示例5: findFunctionType

LINDA_TYPE findFunctionType(std::string s) {
  // change string to all lower case, change \t to space
  std::locale loc;
  for (unsigned int i = 0; i < s.length(); i++) {
    s[i] = std::tolower(s[i], loc);
    if (s[i] == '\t')
      s[i] = ' ';
  }

  regex rIn(" *in *\\(.*\\).*");
  regex rOut(" *out *\\(.*\\).*");
  regex rEval(" *eval *\\(.*\\).*");
  regex rRd(" *rd *\\(.*\\).*");
  regex rRdp(" *rdp *\\(.*\\).*");
  regex rInp(" *inp *\\(.*\\).*");
  regex rDump(" *dump *\\(.*\\).*");

  regex rIf(" *if.*");
  regex rFor(" *for.*");
  regex rDefine(" *define.*");
  cmatch m;
  if (regex_match(s.c_str(), m, rIn))
    return IN;
  else if (regex_match(s.c_str(), m, rOut))
    return OUT;
  else if (regex_match(s.c_str(), m, rEval))
    return EVAL;
  else if (regex_match(s.c_str(), m, rRd))
    return RD;
  else if (regex_match(s.c_str(), m, rRdp))
    return RDP;
  else if (regex_match(s.c_str(), m, rInp))
    return INP;
  else if (regex_match(s.c_str(), m, rDump))
    return DUMP;
  else if (regex_match(s.c_str(), m, rIf))
    return IF;
  else if (regex_match(s.c_str(), m, rFor))
    return FOR;
  else if (regex_match(s.c_str(), m, rDefine))
    return DEFINE;
  return OTHER;
}
开发者ID:Jiafield,项目名称:LindaModel,代码行数:43,代码来源:tokenizer.cpp

示例6: generateArgs

// Only support int, double, string as user defined function's parameters.
std::string generateArgs(std::vector<std::string> &args) {
  std::string argStr = "";
  regex intR("int .*");
  regex doubleR("double .*");
  regex stringR("string .*");
  cmatch m;
  for (size_t i = 0; i < args.size(); i++) {
    if (regex_match((args[i]).c_str(), m, intR)) {
      argStr = argStr + "\n\t" + args[i] + " = atoi(argv[" + std::to_string(static_cast<long long int>(i + 1)) + "])"+ ";";
    } else if (regex_match((args[i]).c_str(), m, doubleR)) {
      argStr = argStr + "\n\t" + args[i] + " = atof(argv[" + std::to_string(static_cast<long long int>(i + 1)) + "])"+ ";";      
    } else if (regex_match((args[i]).c_str(), m, stringR)) {
      argStr = argStr + "\n\t" + args[i] + "(argv[" + std::to_string(static_cast<long long int>(i + 1)) + "])"+ ";";
    } else {
      std::cout << "Couldn't recognize user defined function parameter." << std::endl;
      exit(EXIT_FAILURE);
    }
  }
  return argStr;
}
开发者ID:Jiafield,项目名称:LindaModel,代码行数:21,代码来源:tokenizer.cpp

示例7: loadFromPropertiesStream

void ConfigFile::loadFromPropertiesStream(std::istream& propStream)
{
	using boost::algorithm::trim;
	using boost::regex;
	using boost::regex_match;
	using boost::smatch;
	using Util::unescapeString;

	// Expresiones regulares para distintos tipos de líneas
	regex reBlankOrCom("^(#.*)|(?:)$");
	regex reAssignment("^([A-Za-z.-]+)\\s*=\\s*(\\S.*)?");
	
	smatch matchRes;

	// Limpio los datos
	configMap_.clear();

	// Lo leo línea a línea
	std::string line;
	while (std::getline(propStream, line))
	{
		// Saco espacios al principio y al final
		trim(line);
		
		// Si está en blanco o es un coemntario, la ignoro
		if (regex_match(line, reBlankOrCom))
			continue;

		// Uso una expresión regular para partirlo en un par clave-valor
		if (!regex_match(line, matchRes, reAssignment))
			// No es ni comentario, ni línea en blanco ni asignación
			throw 0; // FIXME: Lanzar algo más significativo

		// Guardo ese par en el mapa (no me preocupo de pisar pares anteriores)
		configMap_[matchRes.str(1)] = unescapeString(matchRes.str(2));
	}
}
开发者ID:hytham,项目名称:afdgp,代码行数:37,代码来源:config_file.cpp

示例8: spritesheet_from_ssp_file

spritesheet
spritesheet_from_ssp_file(
	const boost::filesystem::path& sheet_path
) {
	using boost::cmatch;
	using boost::regex;
	using boost::regex_match;
	
	string_vector lines(read_file(sheet_path));
	
	spritesheet sprites;
	regex expression(
		"\\s?([-_0-9a-z]+)"
		"\\s?="
		"\\s?(\\d+)"
		"\\s+(\\d+)"          
		"\\s+(\\d+)"
		"\\s+(\\d+)",
		regex::extended | regex::icase
	);
	
	int n = 1;
	
	for (auto line : lines) {
		cmatch what;
		if (regex_match(line.c_str(), what, expression)) {
			sprites.insert(std::make_pair(
				what[1],
				rect(
					std::stoi(what[2]),
					std::stoi(what[3]),
					std::stoi(what[4]),
					std::stoi(what[5])
				)
			));
		} else if (!line.empty()) {
			RUNTIME_ERROR("failed to process sprite sheet line"
				" #%1%: \"%2%\"", n, line);
		}
		n++;
	}
	
	return sprites;
}
开发者ID:edlund,项目名称:libmeck,代码行数:44,代码来源:sprite.cpp

示例9: loadKeys

/**
 * @return the loaded keys count.
 */
size_t KeyManager::loadKeys() {
	BOOST_LOG_NAMED_SCOPE("KeyManager::loadKeys");
	itsKeyList.resize(0);
	itsKeyMapByPublicId.clear();
	list<path> myDamagedFiles;
	for (auto it = recursive_directory_iterator(getConfigDir());
			it != recursive_directory_iterator(); it++) {
		boost::smatch matchProd;
		const path myFNameWithPath(it->path().native());
		const path myFName(it->path().filename().native());
		if (!is_directory(it->path())
				&& regex_match(myFName.string(), matchProd, K_KEY_FILTER)) {
			BOOST_LOG_TRIVIAL(debug)<< "Found key file " << myFName << ".";
			try {
				YubikoOtpKeyConfig* myCfg = new YubikoOtpKeyConfig(*this, myFNameWithPath);
				myCfg->load();
				YubikoOtpKeyConfigPtr myKey {myCfg};
				itsKeyList.emplace_back(myKey);
				string myId(myKey->getPublicId());
				if (myId.empty()) {
					(myId += "generated:") += myKey->getFilename().string();
				}
				itsKeyMapByPublicId.emplace(KeyMap_t::value_type {myId, myKey.get()});
			} catch( std::exception& myExc ) {
				BOOST_LOG_TRIVIAL(error)<<"Exception caugh while loading key file \"" << myFName << "\" - "<< myExc.what();
				myDamagedFiles.push_back(myFNameWithPath);
			} catch(...) {
				BOOST_LOG_TRIVIAL(error)<<"Unknown exception caugh while loading key file \"" << myFName << "\".";
				myDamagedFiles.push_back(myFNameWithPath);
			}
		} else {
			BOOST_LOG_TRIVIAL(debug)<< "Skipping file  " << myFName << ".";
		}
	}
	for( path myFName : myDamagedFiles) {
		prefixKeyFile(myFName,"damaged");
	}
	return itsKeyList.size();
}
开发者ID:gogoba,项目名称:trihlav,代码行数:42,代码来源:trihlavKeyManager.cpp

示例10: operator

  parser_type operator()(const message_type& msg) const
  {
    // Important: copy path to local
    const string path(msg.request().path());
      
    smatch what;
    if(!regex_match(path, what, pattern_, match_single_line))
      return fail(msg, set_error);

    part v1;
    if(what.size() > 0)
      v1 = what[0];

    if(func_1_)
      return func_1_(msg, v1);

    part v2;
    if(what.size() > 1)
      v2 = what[1];

    if(func_2_)
      return func_2_(msg, v1, v2);

    part v3;
    if(what.size() > 2)
      v3 = what[2];

    if(func_3_)
      return func_3_(msg, v1, v2, v3);

    part v4;
    if(what.size() > 3)
      v4 = what[3];

    if(func_4_)
      return func_4_(msg, v1, v2, v3, v4);

    return parse(msg);
  }
开发者ID:josendf,项目名称:material-cpp-1209,代码行数:39,代码来源:path.hpp

示例11: main


//.........这里部分代码省略.........
		fs::path cfgFile("graphene.conf");
#else
		fs::path cfgFile(std::string(getenv("HOME"))+"/.graphene.conf");
#endif
		std::ifstream in;
		if (fs::exists(cfgFile)) {
			in.open(cfgFile.string().c_str());
			po::store(po::parse_config_file(in, desc), vm);
			in.close();
		} else {
			std::cout << "config file does not exist" << "\n";
		}
		po::notify(vm);
	} catch (std::exception& e) {
		if (!vm.count("help")) {
			std::cout << e.what() << "\n";
		}
		optionsException = true;
	}
	if (optionsException || vm.count("help")) {
		std::cout << desc << "\n";
		return optionsException ? 1 : 0;
	}
	if (vm.count("version")) {
		std::cout << "graphene version: " << VERSION_MAJOR << "." << VERSION_MINOR << "\n";
		return 0;
	}
	wndParams.maximized = vm.count("maximized") > 0;
	noEffects = vm.count("no-effects") > 0;
	verbose = vm.count("verbose") > 0;
	singleMode = single != "";

	// sanitize paths
	substituteHome(visPath);
	substituteHome(backendPath);

	FW::Events::EventHandler::Ptr eventHandler(new FW::Events::EventHandler());

	GUI::Backend::Ptr backend = getBackend(backendPath);
	if (!backend) return 1;
	backend->init(argc, argv, eventHandler, wndParams, singleMode, verbose);
	backend->setWindowTitle(title);
	backend->setWindowSize(wndWidth, wndHeight);

	Graphene graphene(backend, eventHandler, singleMode, noEffects);

	if (singleMode) {
		fs::path p(visPath);
		p = p / ("vis"+single+visExt);
		if (fs::is_directory(p)) {
			backend->getLog()->error("Input factory is a directory: " + p.string());
			return graphene.run(fps);
		}
		if (!fs::exists(p)) {
			backend->getLog()->error("Input factory does not exist: " + p.string());
			return graphene.run(fps);
		}
		ext::shared_library lib(p.string());
		if (!lib.open()) {
			backend->getLog()->error("Library failed to open: " + p.string());
			return graphene.run(fps);
		}
		std::function<FW::Factory* ()> retrFactory(lib.get<FW::Factory*>("getFactory"));
		if (!retrFactory) {
			backend->getLog()->error("Function \"getFactory\" not found in \""+p.string()+"\". Try adding VIS_DLL_EXPORT(VIS) macro.");
			return graphene.run(fps);
		}
		backend->getLog()->info("Visualizer type \"" + single + "\" initialized");
		FW::Factory* factoryPtr = retrFactory();
		std::shared_ptr<FW::Factory> factory(factoryPtr);
		graphene.addFactory(single, factory);
	} else {
		fs::directory_iterator dirIt(visPath), endIt;
		for (; dirIt != endIt; ++dirIt) {
			fs::path p = dirIt->path();
			if (fs::is_directory(p)) continue;
			smatch what;
			regex pattern("vis(\\w+)"+visExt);
			std::string filename = p.filename().string();
			if (!regex_match(filename, what, pattern)) continue;
			std::string name = what[1];
			ext::shared_library lib(p.string());
			if (!lib.open()) {
				backend->getLog()->warn("Library failed to open: " + p.string());
				continue;
			}
			std::function<FW::Factory* ()> retrFactory(lib.get<FW::Factory*>("getFactory"));
			if (!retrFactory) {
				backend->getLog()->warn("Function \"getFactory\" not found in \""+p.string()+"\". Try adding VIS_DLL_EXPORT(VIS) macro.");
				continue;
			}
			backend->getLog()->info("Adding visualizer type: " + name);
			FW::Factory* factoryPtr = retrFactory();
			std::shared_ptr<FW::Factory> factory(factoryPtr);
			graphene.addFactory(name, factory);
		}
	}

	return graphene.run(fps);
}
开发者ID:paulhilbert,项目名称:graphene,代码行数:101,代码来源:graphene.cpp

示例12: IsValidCode

bool Language::IsValidCode(const std::wstring& s)
{
    return regex_match(s, RE_LANG_CODE);
}
开发者ID:vnwildman,项目名称:poedit,代码行数:4,代码来源:language.cpp

示例13: isExp

bool isExp(std::string &s) {
  regex rx(".*\\(.*\\)");
  cmatch m;
  return regex_match(s.c_str(), m, rx);
}
开发者ID:Jiafield,项目名称:LindaModel,代码行数:5,代码来源:tokenizer.cpp


注:本文中的boost::regex_match方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。