本文整理汇总了C++中ParameterIncorrect函数的典型用法代码示例。如果您正苦于以下问题:C++ ParameterIncorrect函数的具体用法?C++ ParameterIncorrect怎么用?C++ ParameterIncorrect使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ParameterIncorrect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidateName
void Serializer::Deserialize (const string &name, const BufferPtr &data)
{
ValidateName (name);
uint64 size = Deserialize <uint64> ();
if (data.Size() != size)
throw ParameterIncorrect (SRC_POS);
DataStream->ReadCompleteBuffer (data);
}
示例2: ParameterIncorrect
void VolumeHeader::Serialize (const BufferPtr &header) const
{
if (header.Size() != EncryptedHeaderDataSize)
throw ParameterIncorrect (SRC_POS);
header.Zero();
header[0] = 'V';
header[1] = 'E';
header[2] = 'R';
header[3] = 'A';
size_t offset = 4;
header.GetRange (DataAreaKeyOffset, DataAreaKey.Size()).CopyFrom (DataAreaKey);
uint16 headerVersion = CurrentHeaderVersion;
SerializeEntry (headerVersion, header, offset);
SerializeEntry (RequiredMinProgramVersion, header, offset);
SerializeEntry (Crc32::ProcessBuffer (header.GetRange (DataAreaKeyOffset, DataKeyAreaMaxSize)), header, offset);
uint64 reserved64 = 0;
SerializeEntry (reserved64, header, offset);
SerializeEntry (reserved64, header, offset);
SerializeEntry (HiddenVolumeDataSize, header, offset);
SerializeEntry (VolumeDataSize, header, offset);
SerializeEntry (EncryptedAreaStart, header, offset);
SerializeEntry (EncryptedAreaLength, header, offset);
SerializeEntry (Flags, header, offset);
if (SectorSize < TC_MIN_VOLUME_SECTOR_SIZE
|| SectorSize > TC_MAX_VOLUME_SECTOR_SIZE
|| SectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0)
{
throw ParameterIncorrect (SRC_POS);
}
SerializeEntry (SectorSize, header, offset);
offset = TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC;
SerializeEntry (Crc32::ProcessBuffer (header.GetRange (0, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC)), header, offset);
}
示例3: ss
uint32 StringConverter::ToUInt32 (const string &str)
{
uint32 n;
stringstream ss (str);
ss >> n;
if (ss.fail() || n == 0xffffFFFFU)
throw ParameterIncorrect (SRC_POS);
return n;
}
示例4: ss
int64 StringConverter::ToInt64 (const string &str)
{
int64 n;
stringstream ss (str);
ss >> n;
if (ss.fail() || n == 0x7fffFFFFffffFFFFLL || n == -0x7fffFFFFffffFFFFLL)
throw ParameterIncorrect (SRC_POS);
return n;
}
示例5: ParameterIncorrect
void *Memory::Allocate (std::size_t size)
{
if (size < 1)
throw ParameterIncorrect (SRC_POS);
void *bufPtr = malloc (size);
if (!bufPtr)
throw bad_alloc();
return bufPtr;
}
示例6: ParameterIncorrect
string StringConverter::GetTrailingNumber (const string &str)
{
size_t start = str.find_last_not_of ("0123456789");
if (start == string::npos)
return str;
string s = str.substr (start + 1);
if (s.empty ())
throw ParameterIncorrect (SRC_POS);
return s;
}
示例7: ParameterIncorrect
void Cipher::SetKey (const ConstBufferPtr &key)
{
if (key.Size() != GetKeySize ())
throw ParameterIncorrect (SRC_POS);
if (!Initialized)
ScheduledKey.Allocate (GetScheduledKeySize ());
SetCipherKey (key);
Key.CopyFrom (key);
Initialized = true;
}
示例8: sizeof
T Serializer::Deserialize ()
{
uint64 size;
DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &size, sizeof (size)));
if (Endian::Big (size) != sizeof (T))
throw ParameterIncorrect (SRC_POS);
T data;
DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &data, sizeof (data)));
return Endian::Big (data);
}
示例9: GetVersion
bool SystemInfo::IsVersionAtLeast (int versionNumber1, int versionNumber2, int versionNumber3)
{
vector <int> osVersionNumbers = GetVersion();
if (osVersionNumbers.size() < 2)
throw ParameterIncorrect (SRC_POS);
if (osVersionNumbers.size() < 3)
osVersionNumbers[2] = 0;
return (osVersionNumbers[0] * 10000000 + osVersionNumbers[1] * 10000 + osVersionNumbers[2]) >=
(versionNumber1 * 10000000 + versionNumber2 * 10000 + versionNumber3);
}
示例10: deserializedObject
auto_ptr <T> CoreService::GetResponse ()
{
auto_ptr <Serializable> deserializedObject (Serializable::DeserializeNew (ServiceOutputStream));
Exception *deserializedException = dynamic_cast <Exception*> (deserializedObject.get());
if (deserializedException)
deserializedException->Throw();
if (dynamic_cast <T *> (deserializedObject.get()) == nullptr)
throw ParameterIncorrect (SRC_POS);
return auto_ptr <T> (dynamic_cast <T *> (deserializedObject.release()));
}
示例11: NotInitialized
void EncryptionAlgorithm::SetKey (const ConstBufferPtr &key)
{
if (Ciphers.size() < 1)
throw NotInitialized (SRC_POS);
if (GetKeySize() != key.Size())
throw ParameterIncorrect (SRC_POS);
size_t keyOffset = 0;
foreach_ref (Cipher &c, Ciphers)
{
c.SetKey (key.GetRange (keyOffset, c.GetKeySize()));
keyOffset += c.GetKeySize();
}
示例12: ParameterIncorrect
uint64 MemoryStream::Read (const BufferPtr &buffer)
{
if (Data.size() == 0)
throw ParameterIncorrect (SRC_POS);
ConstBufferPtr streamBuf (*this);
size_t len = buffer.Size();
if (streamBuf.Size() - ReadPosition < len)
len = streamBuf.Size() - ReadPosition;
BufferPtr(buffer).CopyFrom (streamBuf.GetRange (ReadPosition, len));
ReadPosition += len;
return len;
}
示例13: switch
uint64 EncryptionModeLRW::SectorToBlockIndex (uint64 sectorIndex) const
{
sectorIndex -= SectorOffset;
switch (Ciphers.front()->GetBlockSize())
{
case 8:
return (sectorIndex << 6) | 1;
case 16:
return (sectorIndex << 5) | 1;
default:
throw ParameterIncorrect (SRC_POS);
}
}
示例14: ParameterIncorrect
void EncryptionModeLRW::SetKey (const ConstBufferPtr &key)
{
if (key.Size() != 16)
throw ParameterIncorrect (SRC_POS);
if (!KeySet)
GfContext.Allocate (sizeof (GfCtx));
if (!Gf64TabInit ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr())))
throw bad_alloc();
if (!Gf128Tab64Init ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr())))
throw bad_alloc();
Key.CopyFrom (key);
KeySet = true;
}
示例15: switch
void VolumeFormatOptionsWizardPage::SetFilesystemType (VolumeCreationOptions::FilesystemType::Enum type)
{
switch (type)
{
case VolumeCreationOptions::FilesystemType::None: FilesystemTypeChoice->SetStringSelection (LangString["NONE"]); break;
case VolumeCreationOptions::FilesystemType::FAT: FilesystemTypeChoice->SetStringSelection (L"FAT"); break;
case VolumeCreationOptions::FilesystemType::NTFS: FilesystemTypeChoice->SetStringSelection (L"NTFS"); break;
case VolumeCreationOptions::FilesystemType::Ext2: FilesystemTypeChoice->SetStringSelection (L"Linux Ext2"); break;
case VolumeCreationOptions::FilesystemType::Ext3: FilesystemTypeChoice->SetStringSelection (L"Linux Ext3"); break;
case VolumeCreationOptions::FilesystemType::Ext4: FilesystemTypeChoice->SetStringSelection (L"Linux Ext4"); break;
case VolumeCreationOptions::FilesystemType::MacOsExt: FilesystemTypeChoice->SetStringSelection (L"Mac OS Extended"); break;
case VolumeCreationOptions::FilesystemType::UFS: FilesystemTypeChoice->SetStringSelection (L"UFS"); break;
default:
throw ParameterIncorrect (SRC_POS);
}
}