本文整理汇总了C++中KeyValue::getComment方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValue::getComment方法的具体用法?C++ KeyValue::getComment怎么用?C++ KeyValue::getComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValue
的用法示例。
在下文中一共展示了KeyValue::getComment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// MAPPED
//
const char * Section::getComment(const char *name) const
{
if(name)
{
std::string myname=name;
KeyValue *mydata = d_kv_map[myname];
if(mydata)
{
return mydata->getComment();
}
}
return "";
}
示例2: visitKeyValue
void Writer::visitKeyValue(const KeyValue& dataline) const
{
if(dataline.isDeleted() && ( !d_commentchar || !d_preservedeleted))
{
// Don't preserve deleted data when comments are null
// or we don't want to preserve them
return;
}
else
{
string key = dataline.getName();
string value = dataline.getValue();
string comment = dataline.getComment();
string commentchar(1,d_commentchar);
if(dataline.isDeleted())
{
// print the comment character
//
*d_outputstream << d_commentchar << " ";
}
if(key != "")
{
int position = 0;
size_t location;
// escape all backslashes
//
while( (location = key.find("\\", position)) != string::npos )
{
// location points right at the '\'
key.insert(location, "\\");
position = (int) location + 2;
}
// escape comment characters
// unless the comment character is a backslash, which we've already escaped....
//
if(d_commentchar && d_commentchar != '\\')
{
position = 0;
while( (location = key.find(commentchar, position)) != string::npos )
{
// location points right at the '"'
key.insert(location, "\\");
position = (int) location + 2;
}
}
// escape all delimiters, unless the delimiter is a backslash or the same as the comment, god forbid.
//
//
if(d_delimiter != '\\' && d_delimiter != d_commentchar)
{
if(d_delimiter)
{
string delimiter(1, d_delimiter);
position = 0;
while( (location = key.find(delimiter, position)) != string::npos )
{
// location points right at the '"'
key.insert(location, "\\");
position = (int) location + 2;
}
}
else
{
position = 0;
while( (location = key.find("\t", position)) != string::npos )
{
// location points right at the '"'
key.insert(location, "\\");
position = (int) location + 2;
}
position = 0;
while( (location = key.find(" ", position)) != string::npos )
{
// location points right at the '"'
key.insert(location, "\\");
position = (int) location + 2;
}
}
}
// print the key
//
*d_outputstream << key;
}
//.........这里部分代码省略.........