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


C++ IsNumber函数代码示例

本文整理汇总了C++中IsNumber函数的典型用法代码示例。如果您正苦于以下问题:C++ IsNumber函数的具体用法?C++ IsNumber怎么用?C++ IsNumber使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: IsNumber

bool Value::
IsNumber (int &i) const
{
	long long i2;
	if ( IsNumber( i2 ) ) {
		i = (int)i2;		// truncation
		return true;
	} else {
		return false;
	}
}
开发者ID:emaste,项目名称:htcondor,代码行数:11,代码来源:value.cpp

示例2: GetValueAsNumber

double AnnotationValue::GetValueAsNumber() const
{
	if (!IsNumber())
	{
		std::stringstream ss;
		ss << "Attempted to access " << GetTypeString()
			<< " annotation as a number.";
		throw AnnotationValueTypeException(ss.str());
	}
	return boost::get<double>(value);
}
开发者ID:TimSimpson,项目名称:Macaroni,代码行数:11,代码来源:AnnotationValue.cpp

示例3: TITANIUM_FUNCTION

		TITANIUM_FUNCTION(TableView, deleteSection)
		{
			if (arguments.size() < 2) {
				return get_context().CreateUndefined();
			} else if (arguments.size() >= 2) {
				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsObject());
				const uint32_t section = static_cast<uint32_t>(_0);
				const auto animation = static_cast<JSObject>(_1);
				deleteSection(section, animation.GetPrivate<TableViewAnimationProperties>());
			} else if (arguments.size() >= 1) {
				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const uint32_t section = static_cast<uint32_t>(_0);
				const auto animation = get_context().CreateObject();
				deleteSection(section, animation.GetPrivate<TableViewAnimationProperties>());
			}
			return get_context().CreateUndefined();
		}
开发者ID:FokkeZB,项目名称:titanium_mobile_windows,代码行数:21,代码来源:TableView.cpp

示例4: TITANIUM_FUNCTION

		TITANIUM_FUNCTION(ResultSet, fieldByName)
		{
			ENSURE_STRING_AT_INDEX(name, 0);

			if (arguments.size() > 1) {
				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsNumber());
				const auto fieldType = Constants::to_FIELD_TYPE(static_cast<std::underlying_type<FIELD_TYPE>::type>(_1));
				return fieldByName(name, fieldType);
			}
			return fieldByName(name);
		}
开发者ID:appcelerator-forks,项目名称:appcelerator.titanium_mobile_windows,代码行数:12,代码来源:ResultSet.cpp

示例5: Jsonize

template<> void Jsonize(JsonIO& io, bool& var)
{
	if(io.IsLoading()) {
		const Value& v = io.Get();
		if(IsNumber(v) && !IsNull(v))
			var = (bool)v;
		else
			throw JsonizeError("boolean expected");
	}
	else
		io.Set(var);
}
开发者ID:kolyden,项目名称:mirror,代码行数:12,代码来源:JSON.cpp

示例6: ExtractNumber

//++
// Details: Extract the number from the string. The number can be either a
// hexadecimal or
//          natural number. It cannot contain other non-numeric characters.
// Type:    Method.
// Args:    vwrNumber   - (W) Number extracted from the string.
// Return:  bool - True = yes number, false not a number.
// Throws:  None.
//--
bool CMIUtilString::ExtractNumber(MIint64 &vwrNumber) const {
  vwrNumber = 0;

  if (!IsNumber()) {
    return ExtractNumberFromHexadecimal(vwrNumber);
  }

  std::stringstream ss(const_cast<CMIUtilString &>(*this));
  ss >> vwrNumber;

  return true;
}
开发者ID:llvm-project,项目名称:lldb,代码行数:21,代码来源:MIUtilString.cpp

示例7: SortSoftClippedReads

bool SoftClipRead::SortSoftClippedReads(SoftClipRead scRead1, SoftClipRead scRead2)
{
	std::string chromosome1 = scRead1.chromosome.substr(3,std::strlen(scRead1.chromosome.c_str()) - 2);
	std::string chromosome2 = scRead2.chromosome.substr(3,std::strlen(scRead2.chromosome.c_str()) - 2);


	if(IsNumber(chromosome1) && IsNumber(chromosome2))
	{
		if (atoi(chromosome1.c_str()) == atoi(chromosome2.c_str()))
			return scRead1.softclip_start > scRead2.softclip_start;
		return atoi(chromosome1.c_str()) > atoi(chromosome2.c_str());
		return false;
	}
	else
	{
		if(chromosome1 == chromosome2)
			return scRead1.softclip_start > scRead2.softclip_start;
		return chromosome1 > chromosome2;
		return false;
	}
}
开发者ID:ResearchDx,项目名称:HardSearch,代码行数:21,代码来源:SoftClipRead.cpp

示例8: IsNumber2

bool IsNumber2(const Value &val) {
	if (IsNull(val))
		return false;
	if (IsNumber(val))
		return true;
	if (IsString(val)) {
		double d = ScanDouble(val.ToString());
		if (!IsNull(d))
			return true;
	}
	return false;
}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:12,代码来源:Regression.cpp

示例9: FormatXmlRpcValue

String FormatXmlRpcValue(const Value& _v)
{
	String r;
	Value v = _v;
	if(v.GetType() == INT64_V) {
		int64 x = v;
		if((int)x == x)
			v = (int)x;
	}
	if(IsNull(v) && !IsString(v) && !IsValueArray(v))
		r = XmlTag("nil")();
	else
	if(v.GetType() == INT_V)
		r = XmlTag("int")(Format("%d", (int)v));
	else
	if(v.GetType() == BOOL_V)
		r = XmlTag("boolean")(AsString((int)(bool)v));
	else
	if(IsNumber(v))
		r = XmlTag("double")(Format("%.16g", (double)v));
	else
	if(IsDateTime(v)) {
		Time t = v;
		r = XmlTag("dateTime.iso8601")
					(Format("%04.4d%02.2d%02.2d`T%02.2d`:%02.2d`:%02.2d",
					        t.year, t.month, t.day, t.hour, t.minute, t.second));
	}
	else
	if(v.GetType() == VALUEMAP_V) {
		r = "<struct>";
		ValueMap vm = v;
		const Index<Value>& k = vm.GetKeys();
		ValueArray va = vm.GetValues();
		for(int i = 0; i < k.GetCount(); i++)
			r << XmlTag("member")(XmlTag("name")(k[i]) + FormatXmlRpcValue(va[i]));
		r << "</struct>";
	}
	else
	if(v.GetType() == VALUEARRAY_V) {
		r = "<array><data>";
		ValueArray va = v;
		for(int i = 0; i < va.GetCount(); i++)
			r << FormatXmlRpcValue(va[i]);
		r << "</data></array>";
	}
	else
	if(v.Is<RawJsonText>())
		r = XmlTag("string").Text(v.To<RawJsonText>().json);
	else
		r = XmlTag("string").Text(v);
	return XmlTag("value")(r);
}
开发者ID:guowei8412,项目名称:upp-mirror,代码行数:52,代码来源:Xml.cpp

示例10: getLiteral

int ObjLexer::AddNewToken(Token::Type const& type, int i, std::string const& raw_object)
{
  Token new_token;
  new_token.SetType(type);

  std::string str = getLiteral(i, raw_object);
  if (IsNumber(str))
    new_token.SetFloat(StringToNumber<float>(str));

  tokens_.push(new_token);

  return str.size();
}
开发者ID:BrandonSchaefer,项目名称:ObjectLoader,代码行数:13,代码来源:ObjLexer.cpp

示例11: SetEmpty

void CppScanner::GetNext()
{
	SetEmpty();
	SkipWhitespace();
	if (f.Get() == '/') { SkipComment(); SkipWhitespace(); }

	char ch = f.Get();
	if (IsNumber(ch) || (ch == '+') || (ch == '-')) GetNumber();
	else if (IsAlpha(ch)) GetName();
	else if (ch == '(' || ch == ')' || ch == '<' || ch == '>' || ch == '=' || ch == ',' || ch == ';' || ch == '&')
	{ type = CToken::DELIMITER; delimiter = ch; f.GetNext(); }
	else throw CPError(CPError::UNKNOWN_CHARACTER);
}
开发者ID:psi46,项目名称:tools,代码行数:13,代码来源:cpp_scanner.cpp

示例12: while

Token* Scanner::GetNumber(char currentChar) {
	string s = "";
	int pos = currentPos, line = currentLine, dot = 0, E = 0;
	s += currentChar;

	while( (currentChar = GetChar()) != '\0' && !IsSpace(currentChar)) {
		if(dot && IsDot(currentChar)) 
			throw ScannerException(currentLine, currentPos, "Too many dots in real number: \"" + GetInvalidToken(pos) + "\"");

		if(E) {
			if(IsE(currentChar)) 
				throw ScannerException(currentLine, currentPos, "Too many symbol \"E\" in real number: \"" + GetInvalidToken(pos) + "\"");

			if(IsNumber(currentChar) || currentChar == '-' || currentChar == '+') {
				s += currentChar;
				continue;
			}
			else
				throw ScannerException(currentLine, currentPos, "Invalid real number: \"" + GetInvalidToken(pos) + "\"");
		}

		if( IsNumber(currentChar) || IsE(currentChar) || IsDot(currentChar) ) {
			E += IsE(currentChar);
			dot += IsDot(currentChar);
			s += currentChar;
		}
		else {
			if(IsLetter(currentChar)) 
				throw ScannerException(currentLine, currentPos, "Invalid identificator: \"" + GetInvalidToken(pos) + "\"");

			BackToPreviousChar();
			break;
		}
	}
	if(IsE(s[s.length() - 1]) || IsDot(s[s.length() - 1])) 
		throw ScannerException(currentLine, currentPos, "Invalid real number: \"" + s + "\"");

	return new Token(line, pos, dot || E ? CONST_REAL : CONST_INTEGER, DEFAULT, s);
}
开发者ID:forsaken1,项目名称:compiler,代码行数:39,代码来源:scanner.cpp

示例13: ASSERT

int CALLBACK CSortListCtrl::CompareFunction( LPARAM lParam1, LPARAM lParam2, LPARAM lParamData )
{
	CSortListCtrl* pListCtrl = reinterpret_cast<CSortListCtrl*>( lParamData );
	ASSERT( pListCtrl->IsKindOf( RUNTIME_CLASS( CListCtrl ) ) );

	ItemData* pid1 = reinterpret_cast<ItemData*>( lParam1 );
	ItemData* pid2 = reinterpret_cast<ItemData*>( lParam2 );

	ASSERT( pid1 );
	ASSERT( pid2 );

	LPCTSTR pszText1 = pid1->arrpsz[ pListCtrl->m_iSortColumn ];
	LPCTSTR pszText2 = pid2->arrpsz[ pListCtrl->m_iSortColumn ];

	ASSERT_VALID_STRING( pszText1 );
	ASSERT_VALID_STRING( pszText2 );

	if( IsNumber( pszText1 ) && IsNumber( pszText2 ))
		return pListCtrl->m_bSortAscending ? NumberCompare( pszText1, pszText2 ) : NumberCompare( pszText2, pszText1 );
	else
		// text.
		return pListCtrl->m_bSortAscending ? lstrcmp( pszText1, pszText2 ) : lstrcmp( pszText2, pszText1 );
}
开发者ID:dyao-vu,项目名称:meta-core,代码行数:23,代码来源:SortListCtrl.cpp

示例14: TITANIUM_FUNCTION

		TITANIUM_FUNCTION(ListSection, deleteItemsAt)
		{
			const auto js_context = this_object.get_context();
			if (arguments.size() >= 2) {
				const auto _0 = arguments.at(0);
				TITANIUM_ASSERT(_0.IsNumber());
				const auto _1 = arguments.at(1);
				TITANIUM_ASSERT(_1.IsNumber());

				JSObject animation = js_context.CreateObject();
				const auto itemIndex = static_cast<std::uint32_t>(_0);
				const auto count = static_cast<std::uint32_t>(_1);

				if (arguments.size() >= 3) {
					const auto _2 = arguments.at(2);
					if (_2.IsObject()) {
						animation = listviewAnimationProperties_ctor__.CallAsConstructor({ _2 });
					}
				}
				deleteItemsAt(itemIndex, count, animation.GetPrivate<ListViewAnimationProperties>());
			}
			return get_context().CreateUndefined();
		}
开发者ID:jonasbjurhult,项目名称:titanium_mobile_windows,代码行数:23,代码来源:ListSection.cpp

示例15: UpdateData

void CEditKDATADlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData( );

	if( !IsNumber( m_strOpen, FALSE ) || !IsNumber( m_strHigh, FALSE )
		|| !IsNumber( m_strLow, FALSE ) || !IsNumber( m_strClose, FALSE ) )
	{
		AfxMessageBox( IDS_EDITKDATA_NOTNUMBER, MB_OK|MB_ICONINFORMATION );
		return;
	}

	CSPTime	sptime( m_tmDate.GetTime() );
	m_kd.m_date		=	sptime.ToStockTime( CKData::IsDayOrMin(m_nKType) );
	m_kd.m_fOpen	=	(float)atof(m_strOpen);
	m_kd.m_fHigh	=	(float)atof(m_strHigh);
	m_kd.m_fLow		=	(float)atof(m_strLow);
	m_kd.m_fClose	=	(float)atof(m_strClose);
	m_kd.m_fVolume	=	(float)m_dwVolume*100;
	m_kd.m_fAmount	=	(float)m_dwAmount*1000;

	CXFDialog::OnOK();
}
开发者ID:darwinbeing,项目名称:trade,代码行数:23,代码来源:EditKDATADlg.cpp


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