本文整理汇总了C++中ParametersMap::getMap方法的典型用法代码示例。如果您正苦于以下问题:C++ ParametersMap::getMap方法的具体用法?C++ ParametersMap::getMap怎么用?C++ ParametersMap::getMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParametersMap
的用法示例。
在下文中一共展示了ParametersMap::getMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _setFromParametersMap
void WebPageLinkFunction::_setFromParametersMap(const ParametersMap& map)
{
// Target
string targetStr(map.get<string>(PARAMETER_TARGET));
ParametersMap::Trim(targetStr);
if(!targetStr.empty() && targetStr[0] >= '0' && targetStr[0] <= '9')
{ // Page by ID
try
{
RegistryKeyType pageId(lexical_cast<RegistryKeyType>(targetStr));
_target = Env::GetOfficialEnv().get<Webpage>(pageId).get();
}
catch(bad_lexical_cast&)
{
throw RequestException("Bad cast in page id");
}
catch(ObjectNotFoundException<Webpage>&)
{
throw RequestException("No such web page");
}
}
else
{ // Page by smart URL
_target = getSite()->getPageBySmartURL(targetStr);
if(!_target)
{
throw RequestException("No such web page");
}
}
optional<string> ot(map.getOptional<string>(PARAMETER_TEXT, false));
_text = ot ? *ot : _target->getName();
_useSmartURL = map.getDefault<bool>(PARAMETER_USE_SMART_URL, true);
_confirm = map.getDefault<string>(PARAMETER_CONFIRM, string(), false);
_title = map.getDefault<string>(PARAMETER_TITLE);
// Class
_class = map.getDefault<string>(PARAMETER_CLASS);
// Additional parameters
BOOST_FOREACH(const ParametersMap::Map::value_type& item, map.getMap())
{
if(item.first == PARAMETER_TEXT ||
item.first == PARAMETER_TARGET ||
item.first == PARAMETER_USE_SMART_URL ||
item.first == PARAMETER_CONFIRM ||
item.first == PARAMETER_TITLE ||
item.first == PARAMETER_CLASS
){
continue;
}
// Using the getValue virtual method instead of item.second in order to handle DelayedEvaluationParametersMap
_parameters.insert(item.first, map.getValue(item.first));
}
}
示例2: _export
void SVNWorkingCopy::_export(
const Registrable& object,
const boost::filesystem::path& dirPath,
const bool noCommit
) const {
RegistryKeyType key(object.getKey());
//////////////////////////////////////////////////////////////////////////
// Attributes
// File creation or update ?
path dumpFilePath(dirPath / path(lexical_cast<string>(key) + ".dump"));
bool creation(!filesystem::exists(dumpFilePath));
// Field names
ParametersMap attributesMap;
object.toParametersMap(attributesMap, false, false);
ofstream dumpStream(
dumpFilePath.string().c_str(),
std::ios_base::out | std::ios_base::binary
);
dumpStream << object.getTableName() << "(";
bool first(true);
BOOST_FOREACH(const ParametersMap::Map::value_type& item, attributesMap.getMap())
{
if(first)
{
first = false;
}
else
{
dumpStream << ",";
}
dumpStream << item.first;
}
dumpStream << ")" << endl;
// Values
first = true;
BOOST_FOREACH(const ParametersMap::Map::value_type& item, attributesMap.getMap())
{
string escapedValue;
escapedValue = item.second;
replace_all(escapedValue, "\\", "\\\\");
replace_all(escapedValue, "\"", "\\\"");
if(first)
{
first = false;
}
else
{
dumpStream << "," << endl;
}
dumpStream << "\"" << escapedValue << "\"";
}
dumpStream << endl;
dumpStream.close();
// If creation, svn add
if(creation && !noCommit)
{
_svnAdd(dumpFilePath);
}
//////////////////////////////////////////////////////////////////////////
// Files
FilesMap filesMap;
object.toFilesMap(filesMap);
BOOST_FOREACH(const FilesMap::Map::value_type& item, filesMap.getMap())
{
// Creation or update or move
bool creation(true);
string fileNameMainPart(lexical_cast<string>(key) + "_" + item.first);
string fileNameWithExtension(fileNameMainPart + "." + item.second.mimeType.getDefaultExtension());
path filePath(dirPath / path(fileNameWithExtension));
for(directory_iterator it(dirPath); it != directory_iterator(); ++it)
{
if( !is_directory(it->path()) &&
it->path().filename().string().size() >= fileNameMainPart.size() &&
it->path().filename().string().substr(0, fileNameMainPart.size()) == fileNameMainPart
){
creation = false;
if(it->path().filename().string() != fileNameWithExtension && !noCommit)
{
_svnMove(it->path(), filePath);
}
break;
}
}
// Dump value into file
ofstream fileStream(filePath.string().c_str(), std::ios_base::out | std::ios_base::binary);
fileStream << item.second.content;
fileStream.close();
// If creation, svn add
if(creation && !noCommit)
{
//.........这里部分代码省略.........