Exemplo n.º 1
0
UString FileList::findFirstGlob(const UString &glob, bool caseInsensitive) const {
	std::regex::flag_type type = std::regex_constants::ECMAScript;
	if (caseInsensitive)
		type |= std::regex::icase;
	std::regex expression(glob.c_str(), type);

	// Iterate through the whole list, adding the matches to the sub list
	for (Files::const_iterator it = _files.begin(); it != _files.end(); ++it)
		if (std::regex_match(it->c_str(), expression))
			return *it;

	return "";
}
Exemplo n.º 2
0
bool FileList::getSubListGlob(const UString &glob, bool caseInsensitive, FileList &subList) const {
	std::regex::flag_type type = std::regex_constants::ECMAScript;
	if (caseInsensitive)
		type |= std::regex::icase;
	std::regex expression(glob.c_str(), type);

	bool foundMatch = false;

	// Iterate through the whole list, adding the matches to the sub list
	for (Files::const_iterator it = _files.begin(); it != _files.end(); ++it)
		if (std::regex_match(it->c_str(), expression)) {
			subList._files.push_back(*it);
			foundMatch = true;
		}

	return foundMatch;
}
Exemplo n.º 3
0
int main(int argc, char** argv)
{
	if(argc < 3){
		cout << "Prague metadata tool" << endl;
		cout << "Usage: " << argv[0] <<" [-s] [-c] [-o  <output file>] <metadata filename1>...<metadata filenameN>" << endl;
		cout << "\t-s\t\t" << "change byteorder of metadata from little-endian to big-endian" << endl;
		cout << "\t-c\t\t" << "save in metacache format" << endl;
		cout << "\t-m\t\t" << "save in multimeta format" << endl;
		cout << "\t-o <filename>\t" << "name of output file [default is out.meta]" << endl;
		return -1;
	}
	bool swap = false;
	bool cache = false;
	bool multi = false;
	Files files;
	int i = 1;
	string outfile("out.meta");
	while(i < argc){
		if(argv[i][0] == '-'){
			switch(argv[i++][1]){
			case 's': swap = true; break;
			case 'c': cache = true; break;
			case 'm': multi = true; break;	
			case 'o': 
				if(i < argc) 
					outfile = argv[i++]; 
				else 
					cerr << "an output file is not specified" << endl;
				break;					
			default: cerr << "unknown option '" << argv[i][1] << "'" << endl;
			}
		}
		else
			files.push_back(argv[i++]);
	}
	PragueMetadata metadata;
	MetaLoader<GetLEValue> loader;
	for(Files::const_iterator i = files.begin(); i != files.end(); ++i)
		if(!loader.load(i->c_str(), metadata)){
			cerr << "Can't load metadata from " << *i << endl;
			continue;
		}
	bool result = false;
	if(swap){
		MetaSaver<SaveBEValue> saver;
		if(!saver.open(outfile.c_str())){
			cerr << "can't open " << outfile << endl;
			return -1;
		}
		if(cache)
			result = saver.saveCache(metadata);
		else if(multi || (metadata.count() > 1))
			result = saver.saveMulti(metadata);
		else 
			result = saver.saveOne(metadata);
	}
	else{
		MetaSaver<SaveValue> saver;
		if(!saver.open(outfile.c_str())){
			cerr << "can't open " << outfile << endl;
			return -1;
		}
		if(cache)
			result = saver.saveCache(metadata);
		else if(multi || (metadata.count() > 1))
			result = saver.saveMulti(metadata);
		else 
			result = saver.saveOne(metadata);
	}
	if(!result){
		cerr << "Can't save metadata to " << outfile << endl;
		return -1;
	}

	return 0;
}