本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例8: SetError_DenominatorZero
void Rational::SetError_DenominatorZero(Signal &sig)
{
sig.SetError(ERR_ZeroDivisionError, "denominator can't be zero");
}
示例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;
}
示例10: SetError_WrongFormat
void Formatter::SetError_WrongFormat(Signal &sig)
{
sig.SetError(ERR_ValueError, "wrong format for formatter");
}
示例11: SetError_InfiniteNotAllowed
void Iterator::SetError_InfiniteNotAllowed(Signal &sig)
{
sig.SetError(ERR_IteratorError, "cannot evaluate infinite iterator");
}
示例12: SetError_InvalidDataTypeOfElement
void Iterator::SetError_InvalidDataTypeOfElement(Signal &sig)
{
sig.SetError(ERR_ValueError, "invalid data type of element");
}
示例13: SetError_Curl
//-----------------------------------------------------------------------------
// utility functions
//-----------------------------------------------------------------------------
void SetError_Curl(Signal &sig, CURLcode code)
{
sig.SetError(ERR_RuntimeError, "%s", ::curl_easy_strerror(code));
}
示例14: SetError_NotEnoughArguments
void Formatter::SetError_NotEnoughArguments(Signal &sig)
{
sig.SetError(ERR_TypeError, "not enough arguments for formatter");
}
示例15: CheckWritable
bool Stream::CheckWritable(Signal &sig) const
{
if (IsWritable()) return true;
sig.SetError(ERR_IOError, "stream is not writable");
return false;
}