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


C++ StringT::StringLength方法代码示例

本文整理汇总了C++中StringT::StringLength方法的典型用法代码示例。如果您正苦于以下问题:C++ StringT::StringLength方法的具体用法?C++ StringT::StringLength怎么用?C++ StringT::StringLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringT的用法示例。


在下文中一共展示了StringT::StringLength方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: atoi

/* construct extracting dimensions from the name */
MatrixParameterT::MatrixParameterT(const StringT& name_NxM, char variable):
	ParameterInterfaceT(name_NxM),
	fVariable(variable),
	fCopySymmetric(false)
{
	const char caller[] = "MatrixParameterT::MatrixParameterT";
	const char msg[] = "could not extract %s dimensions from \"%s\" in \"%s\"";

	/* resolve suffix */
	StringT suffix;
	suffix.Suffix(name_NxM, '_');
	if (suffix.StringLength() < 4)
		ExceptionT::GeneralFail(caller, msg, "matrix", suffix.Pointer(), name_NxM.Pointer());
	
	/* resolve column dimensions */
	StringT num;
	num.Suffix(suffix, 'x');
	if (num.StringLength() < 2 || !isdigit(num[1]))
		ExceptionT::GeneralFail(caller, msg, "col", num.Pointer(), name_NxM.Pointer());
	int col = -1;
	col = atoi(num.Pointer(1));
	if (col < 0)
		ExceptionT::GeneralFail(caller, msg, "col", num.Pointer(), name_NxM.Pointer());
	
	/* resolve row dimensions */
	suffix.Root('x');
	if (suffix.StringLength() < 2 || !isdigit(suffix[1]))
		ExceptionT::GeneralFail(caller, msg, "row", suffix.Pointer(), name_NxM.Pointer());
	int row = -1;
	row = atoi(suffix.Pointer(1));
	if (row < 0)
		ExceptionT::GeneralFail(caller, msg, "row", suffix.Pointer(), name_NxM.Pointer());
	
	/* initialize */
	fMatrix.Dimension(row, col);
	fMatrix = 0.0;
}
开发者ID:samanseifi,项目名称:Tahoe,代码行数:38,代码来源:ParameterUtils.cpp

示例2: OpenFile

void ExtractIOManager::OpenFile (ofstreamT& o, const StringT& name, bool append) const
{
  StringT filename (fOutputName);
  filename.Append ("_");
  for (int i=name.StringLength(); i < fNumDigits; i++)
    filename.Append ("0");
  filename.Append (name);
  filename.Append (".", fOutfileExtension);
  if (!append)
    {
      remove (filename); // remove any pre-existing file
      o.open (filename);
    }
  else
    o.open_append (filename);
  if (!o.is_open())
    ExceptionT::GeneralFail ("ExtractIOManager::OpenFile","Unable to open %s", filename.Pointer());
}
开发者ID:samanseifi,项目名称:Tahoe,代码行数:18,代码来源:ExtractIOManager.cpp

示例3: ReadValue

/* read value from stream */
bool ArgSpecT::ReadValue(istream& in)
{
	switch (fType)
	{
		case int_:
		{
			int a = -991991;
			in >> a;
			if (a != -991991) {
				SetValue(a);
				return true;
			}
		}
		case double_:
		{
			double a = -991.991;
			in >> a;
			if (a != -991.991) {
				SetValue(a);
				return true;
			}
		}
		case string_:
		{
			StringT a;
			a.GetLineFromStream(in);
			if (a.StringLength() > 0) {
				SetValue(a);
				return true;
			}
		}
		case bool_:
		{
			/* get next non-white space character */
			char a;	
			in.get(a);
			while (in.good() && isspace(a)) 
				in.get(a);	

			/* resolve */
			switch (a)
			{
				case '1':
				case 't':
				case 'T':
					SetValue(true);
					return true;
				case '0':
				case 'f':
				case 'F':
					SetValue(false);
					return true;
				default:
					return false;
			}
		}
		case float_:
		{
			float a = -91.91;
			in >> a;
			if (a != -91.91) {
				SetValue(a);
				return true;
			}
		}
		default:
			cout << "\n ArgSpecT::operator=: unknown value type" << endl;
			throw ExceptionT::kGeneralFail;
	}

	/* dummy */
	return false;
}
开发者ID:samanseifi,项目名称:Tahoe,代码行数:74,代码来源:ArgSpecT.cpp


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