コード例 #1
0
Version Popt::getVersion(const Package &p, VersionFlag vf, bool versionMustExist) {
	if(_args.empty()) {
		switch(vf) {
			case NO_DEFAULT:
				// No default, skip to the popArg call below which
				// will trigger the appropriate error.
				break;
			case INSTALLED:
				if(p.isInstalled()) {
					return p.getInstalledVersion(); // exists per definition
				}
				break; // Fall through to popArg
			case INSTALLED_OR_CURRENT:
				if(p.isInstalled()) {
					return p.getInstalledVersion(); // exists per definition
				}
				// fall through to next case
			case CURRENT:
				if(p.hasVersions()) {
					return p.getRecentVersion(); // Exists per definition
				}
				break; // Fall through to popArg
			case NONE_NEEDED:
				// Ignores versionMustExist, caller has to handle this,
				// but at least we do not return an invalid version just an empty
				// one, the caller can easily distinct them.
				return Version::EMPTY_VERSION;
		}
	}
	const Version v(popArg("missing version"));
	if(v.isEmptyVersion() || versionMustExist) {
		p.checkVersionExists(v);
	}
	return v;
}
コード例 #2
0
void TPKGS::loadConfig(const Package &package, const Version &version) {
	assert(!version.isEmptyVersion());
	loadConfig(package.getConfigFile(version));
}