本文整理汇总了C++中reader类的典型用法代码示例。如果您正苦于以下问题:C++ reader类的具体用法?C++ reader怎么用?C++ reader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了reader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: from_data
bool block_transactions::from_data(uint32_t version, reader& source)
{
reset();
block_hash_ = source.read_hash();
const auto count = source.read_size_little_endian();
// Guard against potential for arbitrary memory allocation.
if (count > max_block_size)
source.invalidate();
else
transactions_.resize(count);
// Order is required.
for (auto& tx: transactions_)
if (!tx.from_data(source, true))
break;
if (version < block_transactions::version_minimum)
source.invalidate();
if (!source)
reset();
return source;
}
开发者ID:libbitcoin,项目名称:libbitcoin,代码行数:26,代码来源:block_transactions.cpp
示例2: from_data
bool point::from_data(reader& source, bool wire)
{
reset();
valid_ = true;
hash_ = source.read_hash();
if (wire)
{
index_ = source.read_4_bytes_little_endian();
}
else
{
index_ = source.read_2_bytes_little_endian();
// Convert 16 bit sentinel to 32 bit sentinel.
if (index_ == max_uint16)
index_ = null_index;
}
if (!source)
reset();
return source;
}
开发者ID:RojavaCrypto,项目名称:libbitcoin,代码行数:25,代码来源:point.cpp
示例3: from_data
bool alert::from_data(reader& source)
{
reset();
auto size = source.read_variable_uint_little_endian();
BITCOIN_ASSERT(size <= bc::max_size_t);
const auto payload_size = static_cast<size_t>(size);
size_t signature_size = 0;
auto result = static_cast<bool>(source);
if (result)
{
payload = source.read_data(payload_size);
result = source && (payload.size() == payload_size);
}
if (result)
{
size = source.read_variable_uint_little_endian();
BITCOIN_ASSERT(size <= bc::max_size_t);
signature_size = static_cast<size_t>(size);
result = source;
}
if (result)
{
signature = source.read_data(signature_size);
result = source && (signature.size() == signature_size);
}
if (!result)
reset();
return result;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:35,代码来源:alert.cpp
示例4: handle_sent_chat_message
void handle_sent_chat_message(vector<char> packet, reader r){
Bot* my_bot = Bot::instance();
string message;
r.read(U);
r.read(message);
// create stream with message
stringstream stream;
stream.str(message);
// process
string command;
stream >> command;
if (command == "/start"){
my_bot->state = E_STATE_NOENEMY;
// store star coords to save starting coords
my_bot->start_X = my_bot->X;
my_bot->start_Y = my_bot->Y;
//GET FIRST PARAMETER
//int whatever;
//stream >> whatever;
//cout << "Started with parameter " << whatever << endl;
}
else if (command == "/stop"){
my_bot->state = E_STATE_STOPPED;
}
else if (command == "/monsters"){
cout << "MONSTERS:" << endl;
for each(auto mob in my_bot->monsters){
cout << "Mob ID:" << mob.second.ID << ", coords: [" << mob.second.X << ", " << mob.second.Y << "]" << endl;
}
}
开发者ID:tommarek,项目名称:KOHack,代码行数:35,代码来源:handle_sent_packets.cpp
示例5: handle_rgb
static void handle_rgb(reader& io)
{
bool src_rgb =
io.get_color_type() & (color_mask_rgb | color_mask_palette);
bool dst_rgb = traits::get_color_type() & color_mask_rgb;
if (src_rgb && !dst_rgb)
{
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
io.set_rgb_to_gray(/*rgb_to_gray_error*/);
#else
throw error("grayscale data expected;"
" recompile with"
" PNG_READ_RGB_TO_GRAY_SUPPORTED");
#endif
}
if (!src_rgb && dst_rgb)
{
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
io.set_gray_to_rgb();
#else
throw error("expected RGB data;"
" recompile with"
" PNG_READ_GRAY_TO_RGB_SUPPORTED");
#endif
}
}
开发者ID:Linux-enCaja,项目名称:ecbot,代码行数:26,代码来源:convert_color_space.hpp
示例6: from_data
bool merkle_block::from_data(reader& source)
{
reset();
bool result = header.from_data(source, true);
uint64_t hash_count = 0;
if (result)
{
hash_count = source.read_variable_uint_little_endian();
result = source;
}
for (uint64_t i = 0; (i < hash_count) && result; ++i)
{
hashes.push_back(source.read_hash());
result = source;
}
if (result)
{
auto size = source.read_variable_uint_little_endian();
BITCOIN_ASSERT(size <= bc::max_size_t);
const auto flag_count = static_cast<size_t>(size);
flags = source.read_data(flag_count);
result = source && (flags.size() == flag_count);
}
if (!result)
reset();
return result;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:33,代码来源:merkle_block.cpp
示例7: match
int match(vector<DMatch> &match, frame &f1, frame &f2)
{
vector<DMatch> matches;
FlannBasedMatcher matcher;
matcher.match(f1.desp, f2.desp, matches);
static reader pd("../config/config.ini");
double min_distance = 9999;
double match_threshold = atof(pd.get("match_threshold").c_str());
for (int i = 0; i < matches.size(); ++i)
{
if (matches[i].distance < min_distance)
{
min_distance = matches[i].distance;
}
}
for (int i = 0; i < matches.size(); ++i)
{
if (matches[i].distance < (min_distance * match_threshold))
{
match.push_back(matches[i]);
}
}
return match.size();
}
开发者ID:westlife-lisp,项目名称:slam-work,代码行数:29,代码来源:slam_base.cpp
示例8: from_data
bool operation::from_data(reader& source)
{
reset();
const auto byte = source.read_byte();
auto result = static_cast<bool>(source);
auto op_code = static_cast<opcode>(byte);
if (byte == 0 && op_code != opcode::zero)
return false;
code = ((0 < byte && byte <= 75) ? opcode::special : op_code);
if (operation::must_read_data(code))
{
uint32_t size;
read_opcode_data_size(size, code, byte, source);
data = source.read_data(size);
result = (source && (data.size() == size));
}
if (!result)
reset();
return result;
}
开发者ID:zauguin,项目名称:libbitcoin,代码行数:26,代码来源:operation.cpp
示例9: handle_rest_packet
void handle_rest_packet(vector<char> packet, reader r){
byte param;
r.read(U);
r.read(param);
cout << "Rest packet sent with param: " << dec << (int)param << endl;
}
开发者ID:tommarek,项目名称:KOHack,代码行数:8,代码来源:handle_sent_packets.cpp
示例10: handle_load_player
void handle_load_player(vector<char> packet, reader r){
DWORD player_ID, p1, p2;
r.read(U);
r.read(player_ID);
r.read(p1);
r.read(p2);
//cout << "Selected player ID = " << player_ID << endl;
}
开发者ID:tommarek,项目名称:KOHack,代码行数:8,代码来源:handle_sent_packets.cpp
示例11: handle_use_item_packet
void handle_use_item_packet(vector<char> packet, reader r){
DWORD param;
r.read(U);
r.read(param);
cout << "used item ID: " << hex << (int)param << endl;
}
开发者ID:tommarek,项目名称:KOHack,代码行数:8,代码来源:handle_sent_packets.cpp
示例12: handle_skill_attack
void handle_skill_attack(vector<char> packet, reader r){
DWORD monster_ID;
byte skill_ID, p1;
r.read(U);
r.read(skill_ID);
r.read(p1);
r.read(monster_ID);
cout << dec << "sent: Attack with Skill: skill_id=" << (int)skill_ID << ", p1 = " << (int)p1 << ", monster_id = " << (int)monster_ID << "time: " << GetTickCount() << endl;
}
开发者ID:tommarek,项目名称:KOHack,代码行数:9,代码来源:handle_sent_packets.cpp
示例13: handle_attack
void handle_attack(vector<char> packet, reader r){
DWORD monster_ID, p2;
byte p1;
r.read(U);
r.read(p1);
r.read(monster_ID);
r.read(p2);
cout << dec << "sent: Attack, p1=" << (int)p1 << ", monster_id=" << (int)monster_ID << ", p3=" << (int)p2 << "time: " << GetTickCount() << endl;
}
开发者ID:tommarek,项目名称:KOHack,代码行数:9,代码来源:handle_sent_packets.cpp
示例14: handle_preskill
void handle_preskill(vector<char> packet, reader r){
DWORD monster_id;
byte skill_id;
r.read(U);
r.read(skill_id);
r.read(monster_id);
cout << dec << "sent: Preskill with skill_id = " << (int)skill_id << ", monster_id = " << (int)monster_id << "time: " << GetTickCount() << endl;
}
开发者ID:tommarek,项目名称:KOHack,代码行数:9,代码来源:handle_sent_packets.cpp
示例15: operator
void operator()(reader& io) const
{
handle_16(io);
handle_alpha(io, alpha_traits::get_alpha_filler());
handle_palette(io);
handle_rgb(io);
handle_gray(io);
io.set_color_type(traits::get_color_type());
io.set_bit_depth(traits::get_bit_depth());
}
开发者ID:Linux-enCaja,项目名称:ecbot,代码行数:11,代码来源:convert_color_space.hpp
示例16: from_data
bool heading::from_data(reader& source)
{
reset();
magic = source.read_4_bytes_little_endian();
command = source.read_fixed_string(command_size);
payload_size = source.read_4_bytes_little_endian();
checksum = source.read_4_bytes_little_endian();
if (!source)
reset();
return source;
}
开发者ID:bankonca,项目名称:libbitcoin,代码行数:12,代码来源:heading.cpp
示例17: from_data
bool point::from_data(reader& source)
{
auto result = true;
reset();
hash = source.read_hash();
index = source.read_4_bytes_little_endian();
result = source;
if (!result)
reset();
return result;
}
开发者ID:respu,项目名称:libbitcoin,代码行数:12,代码来源:point.cpp
示例18: handle_move_end_packet
void handle_move_end_packet(vector<char> packet, reader r){
Bot* my_bot = Bot::instance();
signed char dX, dY, dZ;
r.read(U);
r.read(dX);
r.read(dY);
r.read(dZ);
my_bot->X += dX;
my_bot->Y += dY;
my_bot->Z += dZ;
cout << "sent move end packet" << endl;
}
开发者ID:tommarek,项目名称:KOHack,代码行数:12,代码来源:handle_sent_packets.cpp
示例19: from_data
bool alert::from_data(uint32_t , reader& source)
{
reset();
payload_ = source.read_bytes(source.read_size_little_endian());
signature_ = source.read_bytes(source.read_size_little_endian());
if (!source)
reset();
return source;
}
开发者ID:RojavaCrypto,项目名称:libbitcoin,代码行数:12,代码来源:alert.cpp
示例20: from_data
bool stealth_record::from_data(reader& source, bool wire)
{
if (!wire)
return from_data(source, 0, {});
reset();
unsigned_ephemeral_ = source.read_hash();
public_key_hash_ = source.read_short_hash();
transaction_hash_ = source.read_hash();
if (!source)
reset();
return source;
}
开发者ID:libbitcoin,项目名称:libbitcoin,代码行数:15,代码来源:stealth_record.cpp
注:本文中的reader类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论