本文整理汇总了C++中GetBytes函数的典型用法代码示例。如果您正苦于以下问题:C++ GetBytes函数的具体用法?C++ GetBytes怎么用?C++ GetBytes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetBytes函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FOOTMARK
DWORD COMPSTREXTRA::Store(const LogCompStrExtra *log) {
FOOTMARK();
assert(this);
assert(log);
BYTE *pb = GetBytes();
dwSignature = 0xDEADFACE;
iClause = log->iClause;
pb += sizeof(COMPSTREXTRA);
DWORD size;
dwHiraganaClauseOffset = (DWORD)(pb - GetBytes());
dwHiraganaClauseCount = 0;
for (size_t i = 0; i < log->hiragana_clauses.size(); ++i) {
size = (log->hiragana_clauses[i].size() + 1) * sizeof(WCHAR);
memcpy(pb, &log->hiragana_clauses[i][0], size);
++dwHiraganaClauseCount;
pb += size;
}
dwTypingClauseOffset = (DWORD)(pb - GetBytes());
dwTypingClauseCount = 0;
for (size_t i = 0; i < log->typing_clauses.size(); ++i) {
size = (log->typing_clauses[i].size() + 1) * sizeof(WCHAR);
memcpy(pb, &log->typing_clauses[i][0], size);
++dwTypingClauseCount;
pb += size;
}
assert(log->GetTotalSize() == (DWORD)(pb - GetBytes()));
return (DWORD)(pb - GetBytes());
} // COMPSTREXTRA::Store
示例2: AsString
/// start : 0 ~ GetBytes()-1
std::string AsString(size_t start, size_t length)const
{
BOOST_ASSERT(start < GetBytes());
BOOST_ASSERT(start + length <= GetBytes());
return std::string(ptr_ + start, length);
}
示例3:
void
UUID::Dump (Stream *s) const
{
const uint8_t *u = (const uint8_t *)GetBytes();
s->Printf ("%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15]);
}
示例4: sizeof
std::string
UUID::GetAsString (const char *separator) const
{
std::string result;
char buf[256];
if (!separator)
separator = "-";
const uint8_t *u = (const uint8_t *)GetBytes();
if (sizeof (buf) > (size_t)snprintf (buf,
sizeof (buf),
"%2.2X%2.2X%2.2X%2.2X%s%2.2X%2.2X%s%2.2X%2.2X%s%2.2X%2.2X%s%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
u[0],u[1],u[2],u[3],separator,
u[4],u[5],separator,
u[6],u[7],separator,
u[8],u[9],separator,
u[10],u[11],u[12],u[13],u[14],u[15]))
{
result.append (buf);
if (m_num_uuid_bytes == 20)
{
if (sizeof (buf) > (size_t)snprintf (buf, sizeof (buf), "%s%2.2X%2.2X%2.2X%2.2X", separator,u[16],u[17],u[18],u[19]))
result.append (buf);
}
}
return result;
}
示例5: data
std::vector<byte> CSP::GetBytes(size_t Length)
{
std::vector<byte> data(Length);
GetBytes(data);
return data;
}
示例6: PutBytes
HRESULT CBPersistMgr::Transfer(const char* Name, AnsiStringArray& Val)
{
size_t size;
if (m_Saving)
{
size = Val.size();
PutBytes((BYTE*)&size, sizeof(size_t));
for (AnsiStringArray::iterator it = Val.begin(); it != Val.end(); ++it)
{
PutString((*it).c_str());
}
}
else
{
Val.clear();
GetBytes((BYTE*)&size, sizeof(size_t));
for (size_t i = 0; i < size; i++)
{
char* str = GetString();
if (str) Val.push_back(str);
}
}
return S_OK;
}
示例7: snprintf
char *
UUID::GetAsCString (char *dst, size_t dst_len) const
{
const uint8_t *u = (const uint8_t *)GetBytes();
snprintf(dst, dst_len, "%2.2X%2.2X%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X-%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15]);
return dst;
}
示例8: GetTunerSettings
// Settings for this kernel (general)
static TunerSettings GetTunerSettings(const Arguments<T> &args) {
auto settings = TunerSettings();
// Identification of the kernel
settings.kernel_family = (V==1) ? "xgemv" : ((V==2) ? "xgemv_fast" : "xgemv_fast_rot");
settings.kernel_name = (V==1) ? "Xgemv" : ((V==2) ? "XgemvFast" : "XgemvFastRot");
settings.sources =
#include "../src/kernels/common.opencl"
#include "../src/kernels/level2/xgemv.opencl"
#include "../src/kernels/level2/xgemv_fast.opencl"
;
// Buffer sizes
settings.size_x = args.n;
settings.size_y = args.m;
settings.size_a = args.m * args.n;
// Sets the base thread configuration
settings.global_size = {args.m};
settings.global_size_ref = settings.global_size;
settings.local_size = {1};
settings.local_size_ref = {64};
// Transforms the thread configuration based on the parameters
settings.mul_local = {{"WGS"+std::to_string(V)}};
settings.div_global = (V==1 || V==2) ?
TunerSettings::TransformVector{{"WPT"+std::to_string(V)}} :
TunerSettings::TransformVector{};
// Sets the tuning parameters and their possible values
if (V==1) {
settings.parameters = {
{"WGS"+std::to_string(V), {32, 64, 128, 256}},
{"WPT"+std::to_string(V), {1, 2, 4}},
};
}
if (V==2) {
settings.parameters = {
{"WGS"+std::to_string(V), {16, 32, 64, 128, 256}},
{"WPT"+std::to_string(V), {1, 2, 4}},
{"VW"+std::to_string(V), {1, 2, 4, 8}},
};
}
if (V==3) {
settings.parameters = {
{"WGS"+std::to_string(V), {16, 32, 64, 128}},
{"WPT"+std::to_string(V), {1, 2, 4, 8, 16, 32}},
{"VW"+std::to_string(V), {1, 2, 4, 8}},
};
}
// Describes how to compute the performance metrics
settings.metric_amount = (args.m*args.n + 2*args.m + args.n) * GetBytes(args.precision);
settings.performance_unit = "GB/s";
return settings;
}
示例9: VALIDATE_NOT_NULL
ECode UriCodec::Decode(
/* [in] */ const String& s,
/* [in] */ Boolean convertPlus,
/* [in] */ ICharset* charset,
/* [in] */ Boolean throwOnFailure,
/* [out] */ String* decodedString)
{
VALIDATE_NOT_NULL(decodedString);
if (s.IndexOf('%') == -1 && (!convertPlus || s.IndexOf('+') == -1)) {
*decodedString = s;
return NOERROR;
}
StringBuilder result(s.GetByteLength());
AutoPtr<IByteArrayOutputStream> out;
CByteArrayOutputStream::New((IByteArrayOutputStream**)&out);
IOutputStream* os = IOutputStream::Probe(out);
AutoPtr<ArrayOf<Char32> > char32Array = s.GetChars();
for (Int32 i = 0; i < s.GetLength();) {
Char32 c = (*char32Array)[i];
if (c == '%') {
do {
Int32 d1, d2;
if (i + 2 < s.GetLength()
&& (d1 = HexToInt((*char32Array)[i + 1])) != -1
&& (d2 = HexToInt((*char32Array)[i + 2])) != -1) {
os->Write((Byte) ((d1 << 4) + d2));
}
else if (throwOnFailure) {
return E_ILLEGAL_ARGUMENT_EXCEPTION;
}
else {
// TODO: unicode escape
const char* chars = "\ufffd";
AutoPtr<ArrayOf<Byte> > replacement = GetBytes(chars, charset);
os->Write(replacement, 0, replacement->GetLength());
}
i += 3;
} while (i < s.GetLength() && (*char32Array)[i] == '%');
AutoPtr<ArrayOf<Byte> > bytes;
out->ToByteArray((ArrayOf<Byte>**)&bytes);
//result.append(new String(out.toByteArray(), charset);
result.Append(String((char*)bytes->GetPayload()));
out->Reset();
}
else {
if (convertPlus && c == '+') {
c = ' ';
}
result.AppendChar(c);
i++;
}
}
*decodedString = result.ToString();
return NOERROR;
}
示例10: CryptoRandomException
void CSP::GetBytes(std::vector<byte> &Output, size_t Offset, size_t Length)
{
if (Offset + Length > Output.size())
throw CryptoRandomException("CSP:GetBytes", "The array is too small to fulfill this request!");
std::vector<byte> rnd(Length);
GetBytes(rnd);
memcpy(&Output[Offset], &rnd[0], rnd.size());
}
示例11: Find
bool CGXStandardObisCodeCollection::Find(basic_string<char> ln, OBJECT_TYPE objectType, CGXStandardObisCode& item)
{
unsigned char bytes[6];
if (GetBytes(ln, bytes) != ERROR_CODES_OK)
{
return NULL;
}
return Find(bytes, objectType, item);
}
示例12: copy
int c4_Handler::Compare(int index_, const c4_Bytes &buf_)
{
// create a copy for small data, since ints use a common _item buffer
c4_Bytes copy(buf_.Contents(), buf_.Size(), buf_.Size() <= 8);
c4_Bytes data;
GetBytes(index_, data);
return f4_CompareFormat(Property().Type(), data, copy);
}
示例13: EqualsMask
bool CGXStandardObisCodeCollection::EqualsMask(basic_string<char> obisMask, basic_string<char> ln)
{
unsigned char bytes[6];
if (GetBytes(ln, bytes) != ERROR_CODES_OK)
{
return NULL;
}
vector< basic_string<char> > tmp = GXHelpers::Split(obisMask, '.');
return EqualsObisCode(tmp, bytes);
}
示例14: SetLocalMemorySize
static void SetLocalMemorySize(cltune::Tuner &tuner, const size_t id, const Arguments<T> &args) {
if (V==1 || V==2) {
auto LocalMemorySize = [args] (std::vector<size_t> v) { return v[0]*GetBytes(args.precision); };
tuner.SetLocalMemoryUsage(id, LocalMemorySize, {"WGS"+std::to_string(V)});
}
else {
auto LocalMemorySize = [args] (std::vector<size_t> v) { return (v[0]*v[1] + v[1])*GetBytes(args.precision); };
tuner.SetLocalMemoryUsage(id, LocalMemorySize, {"WGS"+std::to_string(V), "WPT"+std::to_string(V)});
}
}
示例15: sizeof
uint CSP::Next()
{
uint rndNum = 0;
size_t len = sizeof(rndNum);
std::vector<byte> rnd(len);
GetBytes(rnd);
memcpy(&rndNum, &rnd[0], len);
return rndNum;
}