コード例 #1
0
static int _lastNonTrailingIndexOfPathSeparator(const VString& s, int& lengthWithoutTrailingSeparator) {
    bool hasTrailingPathSeparator = s.endsWith(VFSNode::PATH_SEPARATOR_CHAR);
    if (!hasTrailingPathSeparator) {
        lengthWithoutTrailingSeparator = s.length();
        return s.lastIndexOf(VFSNode::PATH_SEPARATOR_CHAR);
    }

    VString stripped;
    s.getSubstring(stripped, s.begin(), s.end() - 1);
    lengthWithoutTrailingSeparator = stripped.length();
    return stripped.lastIndexOf(VFSNode::PATH_SEPARATOR_CHAR);
}
コード例 #2
0
// define a dependency of one parameter respect to the other parameters and their respective values
// the parameters and values are expressed as follows: parameter1(value1)|...|parameterN(valueN)
bool ParameterManager::defineDependency(const char *strParameter, const char *strParametersAndValues) {

	// (1) make sure the parameter exists
	MParameter::iterator it = m_mParameter.find(strParameter);
	if (it == m_mParameter.end()) {
		return false;
	}
	
	Dependency dependency;
	dependency.strParameter = strParameter;
	
	// (2) parse the parameter(value) items
	ParameterValue parameterValue;
	VString *vString = getItemList(strParametersAndValues);
	for(VString::iterator it = vString->begin() ; it != vString->end() ; ++it) {
		size_t iOpen = (*it).find("(");
		size_t iClose = (*it).rfind(")");	
		// just a parameter
		if (iOpen == string::npos) {
			if (iClose != string::npos) {
				return false;
			}
			parameterValue.strParameter = *it;
			parameterValue.strValue = "";
		} 
		// a parameter with its corresponding value
		else {
			if (((*it).rfind("(") != iOpen) || ((*it).find(")") != iClose) || (iClose-iOpen < 2) || (iClose+1 != (*it).length())) {
				return false;
			}
			parameterValue.strParameter = (*it).substr(0,iOpen);
			parameterValue.strValue = (*it).substr(iOpen+1,iClose-(iOpen+1));
			//printf("%s %s\n",parameterValue.strParameter.c_str(),parameterValue.strValue.c_str());
		}
		// check that the parameter actually exists
		MParameter::iterator jt = m_mParameter.find(parameterValue.strParameter);
		if (jt == m_mParameter.end()) {
			return false;
		}
		// check that the parameter is different from the dependent parameter
		if (parameterValue.strParameter.compare(strParameter) == 0) {
			return false;
		}
		dependency.vParameterValue.push_back(parameterValue);	
	}
	delete vString;

	m_vDependency.push_back(dependency);	

	return true;
}
コード例 #3
0
ファイル: mmo.hpp プロジェクト: qiuhw/tmwa
 MapName(VString<15> v) : _impl(v.oislice_h(std::find(v.begin(), v.end(), '.'))) {}
コード例 #4
0
ファイル: mmo.hpp プロジェクト: cnelsonsic/tmwa
 iterator end() const { return &*_impl.end(); }