当前位置: 首页>>代码示例>>C++>>正文


C++ KeyValue::getComment方法代码示例

本文整理汇总了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 "";
}
开发者ID:dotminic,项目名称:actionaz,代码行数:15,代码来源:Section.cpp

示例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;
		}
//.........这里部分代码省略.........
开发者ID:CadeLaRen,项目名称:MUSIC-1,代码行数:101,代码来源:Writer.cpp


注:本文中的KeyValue::getComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。