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


C++ Signal::SetError方法代码示例

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


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

示例1: DoSeek

bool Stream_File::DoSeek(Signal &sig, long offset, size_t offsetPrev, SeekMode seekMode)
{
	if (_hFile == INVALID_HANDLE_VALUE) return true;
	if (_map.hFileMappingObject == nullptr) {
		DWORD dwMoveMethod =
			(seekMode == SeekSet)? FILE_BEGIN :
			(seekMode == SeekCur)? FILE_CURRENT : FILE_BEGIN;
		DWORD dwPtr = ::SetFilePointer(_hFile, offset, nullptr, dwMoveMethod);
		if (dwPtr == INVALID_SET_FILE_POINTER) {
			sig.SetError(ERR_IOError, "seek error");
			return false;
		}
	} else {
		if (seekMode == SeekSet) {
			_map.offset = static_cast<size_t>(offset);
		} else if (seekMode == SeekCur) {
			if (offset < 0 && _map.offset < static_cast<size_t>(-offset)) {
				sig.SetError(ERR_IOError, "seek error");
				return false;
			}
			_map.offset = static_cast<size_t>(_map.offset + offset);
		}
		if (_map.offset > _map.bytes) {
			sig.SetError(ERR_IOError, "seek error");
			return false;
		}
	}
	return true;
}
开发者ID:gura-lang,项目名称:gura,代码行数:29,代码来源:module-fs.cpp

示例2: CheckArray

bool CheckArray(Signal &sig, GLenum pname, const Array *pArray)
{
	ParamInfoDict::iterator iter = _pParamInfoDict->find(pname);
	if (iter == _pParamInfoDict->end()) return true;
	if (pArray->HasShape(iter->second)) return true;
	sig.SetError(ERR_ValueError, "the array must contain %d elements", iter->second);
	return false;
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例3: ChooseMin

size_t Pointer::StreamEx::DoRead(Signal &sig, void *buff, size_t len)
{
	size_t offset = _pPointer->GetOffset();
	size_t bytesEntire = _pPointer->GetEntireSize();
	if (offset > bytesEntire) {
		sig.SetError(ERR_OutOfRangeError, "offset is out of range");
		return 0;
	}
	size_t bytesToCopy = ChooseMin(bytesEntire - offset, len);
	::memcpy(buff, _pPointer->GetPointerC(), bytesToCopy);
	_pPointer->SetOffset(offset + bytesToCopy);
	return bytesToCopy;
}
开发者ID:gura-lang,项目名称:gura,代码行数:13,代码来源:Pointer.cpp

示例4: Seek

bool Stream::Seek(Signal &sig, long offset, SeekMode seekMode)
{
	size_t offsetPrev = _offsetCur;
	if (seekMode == SeekSet) {
		_offsetCur = static_cast<size_t>(offset);
	} else if (seekMode == SeekCur) {
		_offsetCur = _offsetCur + offset;
	} else if (seekMode == SeekEnd) {
		_offsetCur = DoGetSize();
		if (offset < 0 && _offsetCur < static_cast<size_t>(-offset)) {
			sig.SetError(ERR_IOError, "seek error");
			return false;
		}
	} else {
		// this must not happen because illegal value has to be rejected before.
		return false;
	}
	if (_peek.buff == nullptr) return DoSeek(sig, offset, offsetPrev, seekMode);
	if (_offsetCur < offsetPrev) {
		size_t bytesPeeked = _peek.bytes;
		if (_peek.offsetRead >= offsetPrev - _offsetCur) {
			_peek.offsetRead -= (offsetPrev - _offsetCur);
			return true;
		}
		delete[] _peek.buff;
		_peek.buff = nullptr;
		_peek.bytes = 0;
		_peek.offsetRead = 0;
		if (seekMode == SeekSet) return DoSeek(sig, offset, offsetPrev, SeekSet);
		offset -= static_cast<long>(bytesPeeked);
		return DoSeek(sig, offset, offsetPrev, SeekCur);
	} else {
		if (_peek.offsetRead + _offsetCur - offsetPrev <= _peek.bytes) {
			_peek.offsetRead += _offsetCur - offsetPrev;
			return true;
		}
		size_t bytesTrail = _peek.bytes - _peek.offsetRead;
		delete[] _peek.buff;
		_peek.buff = nullptr;
		_peek.bytes = 0;
		_peek.offsetRead = 0;
		if (seekMode == SeekSet) return DoSeek(sig, offset, offsetPrev, SeekSet);
		offset -= static_cast<long>(bytesTrail);
		return DoSeek(sig, offset, offsetPrev, SeekCur);
	}
}
开发者ID:,项目名称:,代码行数:46,代码来源:

示例5: Open

bool Stream_File::Open(Signal &sig, const char *fileName, UInt32 attr)
{
	Close();
	_attr |= attr;
	_fileName = OAL::MakeAbsPathName(OAL::FileSeparator, fileName);
	DWORD dwDesiredAccess =
			IsAppend()? GENERIC_WRITE :
			IsReadable()? GENERIC_READ :
			IsWritable()? GENERIC_WRITE :
			GENERIC_READ;
	DWORD dwShareMode = FILE_SHARE_READ;
	DWORD dwCreationDisposition =
			IsAppend()? OPEN_ALWAYS :
			IsReadable()? OPEN_EXISTING :
			IsWritable()? CREATE_ALWAYS :
			OPEN_EXISTING;
	_hFile = ::CreateFile(OAL::ToNativeString(_fileName.c_str()).c_str(),
					dwDesiredAccess, dwShareMode,
					nullptr, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr);
	if (_hFile == INVALID_HANDLE_VALUE) {
		sig.SetError(ERR_IOError, "can't open file '%s'", fileName);
		return false;
	}
	if (IsAppend()) {
		::SetFilePointer(_hFile, 0, nullptr, FILE_END);
	}
	_map.hFileMappingObject = nullptr;
	_map.buff = nullptr;
	_map.bytes = 0;
	_map.offset = 0;
	_needCloseFlag = true;
	if (dwDesiredAccess == GENERIC_READ) {
		_map.hFileMappingObject =
				::CreateFileMapping(_hFile, nullptr, PAGE_READONLY, 0, 0, nullptr);
		if (_map.hFileMappingObject == nullptr) {
			// it seems to open an empty file
			return true;
		}
		_map.buff = reinterpret_cast<UChar *>(
				::MapViewOfFile(_map.hFileMappingObject, FILE_MAP_READ, 0, 0, 0));
		_map.bytes = ::GetFileSize(_hFile, nullptr);
		_map.offset = 0;
	}
	return true;
}
开发者ID:gura-lang,项目名称:gura,代码行数:45,代码来源:module-fs.cpp

示例6: GetChar

int Stream::GetChar(Signal &sig)
{
	char chConv = '\0';
	Codec::Decoder *pDecoder = GetCodec()->GetDecoder();
	if (pDecoder->FollowChar(chConv)) return static_cast<UChar>(chConv);
	for (;;) {
		int ch = DoGetChar(sig);
		if (ch < 0) return ch;
		Codec::Result rtn = pDecoder->FeedChar(static_cast<char>(ch), chConv);
		if (rtn == Codec::RESULT_Complete) {
			break;
		} else if (rtn == Codec::RESULT_Error) {
			sig.SetError(ERR_CodecError, "not a valid character of %s", GetCodec()->GetEncoding());
			return -1;
		}
	}
	return static_cast<UChar>(chConv);
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例7: ReadChar

String Stream::ReadChar(Signal &sig)
{
	char chConv = '\0';
	String str;
	Codec::Decoder *pDecoder = GetCodec()->GetDecoder();
	for (;;) {
		int ch = DoGetChar(sig);
		if (ch < 0) break;
		Codec::Result rtn = pDecoder->FeedChar(static_cast<char>(ch), chConv);
		if (rtn == Codec::RESULT_Complete) {
			str += chConv;
			break;
		} else if (rtn == Codec::RESULT_Error) {
			sig.SetError(ERR_CodecError, "not a valid character of %s", GetCodec()->GetEncoding());
			return "";
		}
	}
	while (pDecoder->FollowChar(chConv)) str += chConv;
	return str;
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例8: SetError_DenominatorZero

void Rational::SetError_DenominatorZero(Signal &sig)
{
	sig.SetError(ERR_ZeroDivisionError, "denominator can't be zero");
}
开发者ID:gura-lang,项目名称:gura,代码行数:4,代码来源:Rational.cpp

示例9: CheckBwdSeekable

bool Stream::CheckBwdSeekable(Signal &sig) const
{
	if (IsBwdSeekable()) return true;
	sig.SetError(ERR_IOError, "stream is not capable of backward seeking");
	return false;
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例10: SetError_WrongFormat

void Formatter::SetError_WrongFormat(Signal &sig)
{
	sig.SetError(ERR_ValueError, "wrong format for formatter");
}
开发者ID:,项目名称:,代码行数:4,代码来源:

示例11: SetError_InfiniteNotAllowed

void Iterator::SetError_InfiniteNotAllowed(Signal &sig)
{
	sig.SetError(ERR_IteratorError, "cannot evaluate infinite iterator");
}
开发者ID:gura-lang,项目名称:gura,代码行数:4,代码来源:Iterator.cpp

示例12: SetError_InvalidDataTypeOfElement

void Iterator::SetError_InvalidDataTypeOfElement(Signal &sig)
{
	sig.SetError(ERR_ValueError, "invalid data type of element");
}
开发者ID:gura-lang,项目名称:gura,代码行数:4,代码来源:Iterator.cpp

示例13: SetError_Curl

//-----------------------------------------------------------------------------
// utility functions
//-----------------------------------------------------------------------------
void SetError_Curl(Signal &sig, CURLcode code)
{
	sig.SetError(ERR_RuntimeError, "%s", ::curl_easy_strerror(code));
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例14: SetError_NotEnoughArguments

void Formatter::SetError_NotEnoughArguments(Signal &sig)
{
	sig.SetError(ERR_TypeError, "not enough arguments for formatter");
}
开发者ID:,项目名称:,代码行数:4,代码来源:

示例15: CheckWritable

bool Stream::CheckWritable(Signal &sig) const
{
	if (IsWritable()) return true;
	sig.SetError(ERR_IOError, "stream is not writable");
	return false;
}
开发者ID:,项目名称:,代码行数:6,代码来源:


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