本文整理汇总了C++中block类的典型用法代码示例。如果您正苦于以下问题:C++ block类的具体用法?C++ block怎么用?C++ block使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了block类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertKey
bool AssocArrayElem::convertKey(block& blk, AssocArrayType& aaType, Variable* keyVar, bool needSwap)
{
bool result = false; //conversion generated?
if (keyVar && aaType.keyTYPE().isStringType())
{
block* keyBlock = needSwap ? blk.addNewBlock() : &blk;
//do not convert if the key is explicitly of the System.String type
if (aaType.keyType().isString())
{
#if 0
keyVar->store(*keyBlock);
loadArray(*keyBlock, *keyVar);
#else
Variable* v = savePartialResult(*keyBlock, keyVar->getDecl(), keyVar->getType(), false);
keyBlock->add(*new UTF8Encoding);
loadArray(*keyBlock, *v);
#endif
keyBlock->add(*new EncodingGetString);
result = true;
}
if (needSwap)
{
blk.swapTail();
}
}
return result;
}
示例2: ASSERTION
void block_file::write_block(int position, const block &b) {
ASSERTION(position < get_block_count());
ASSERTION(b.get_size() == block_size);
file.seekp(position * block_size);
file.write(b.raw_char_pointer(), block_size);
}
示例3: BlockDef
// as copy
block::block(const block& original)
:
BlockDef(original.blockDef()),
Vertices(original.points()),
Cells(original.cells()),
BoundaryPatches(original.boundaryPatches())
{}
示例4: ok
void abstract_block_model::ok(block& blk) {
if (currentblockiteator != end()) currentblockiteator->set_ok();
currentblockiteator++;
parcel_iterator endit = blk.end();
endit++;
for (parcel_iterator it = blk.begin(); it != endit; ++it) {
if (it->first->isvalue()) {
if (!it->first->error()) {
switch (SUPER_TYPE(it->first->type())) {
case TYPE_EVENT:
{
executr->write_val_event(it->second, it->first->value_event());
break;
}
case TYPE_REPORT:
{
executr->write_val_report(it->second, it->first->value_report());
break;
}
default:
{
executr->write_val(it->second, it->first->value());
}
}
}
}
if (it->first->error()) {
executr->error(it->second, it->first->error());
}
}
}
示例5: switch
// Return the neighbour face point from the mapped indices
inline label facePointN
(
const int facei,
const block& block,
const label i,
const label j
)
{
switch (facei)
{
case 0:
return facePointN(block, 0, i, j);
case 1:
return facePointN(block, block.meshDensity().x(), i, j);
case 2:
return facePointN(block, i, 0, j);
case 3:
return facePointN(block, i, block.meshDensity().y(), j);
case 4:
return facePointN(block, i, j, 0);
case 5:
return facePointN(block, i, j, block.meshDensity().z());
default:
return -1;
}
}
示例6: allocData
block::block(const block&right){
//delete []this->data;
allocData();
this->b_type=right.getType();
this->b_pos=right.getPos();
this->setType(this->b_type);
this->setState(right.getState());
}
示例7: hash
std::size_t block_hasher::hash(const block& v) {
std::size_t seed(0);
combine(seed, v.type());
combine(seed, v.content());
return seed;
}
示例8: addInside
void block::addInside(block & check, block grab, int i)
{
int pos=0;
if(check.cond&&(pos=check.blockIsInside(grab))){
check.addInside(check.blocksIn[pos-1],grab,pos-1);
}
else {
addIn(grab, i);
}
}
示例9: resetUsed
void bGroup::resetUsed(block & t)
{
//-------- resets the log of what blocks have been used in the last print stage
used[""]=false;
used[t.title]=false;
for (unsigned int i=0; i<t.numInside(); i++) {
resetUsed(t.blocksIn[i]);
}
for (unsigned int i=0; i<t.size(); i++) {
resetUsed(t.blocksOn[i]);
}
}
示例10: resetList
void resetList(block & t, map<string,bool> & used)
{
//-------- resets the log of what blocks have been used in the last print stage
used[""]=false;
used[t.title]=false;
for (unsigned int i=0; i<t.numInside(); i++) {
resetList(t.blocksIn[i],used);
}
for (unsigned int i=0; i<t.size(); i++) {
resetList(t.blocksOn[i],used);
}
}
示例11: get_previous_hash
code data_base::verify_push(const block& block, size_t height)
{
if (block.transactions().empty())
return error::empty_block;
if (get_next_height(blocks()) != height)
return error::store_block_invalid_height;
if (block.header().previous_block_hash() !=
get_previous_hash(blocks(), height))
return error::store_block_missing_parent;
return error::success;
}
示例12: unsignIndex
// Return the neighbour face point from the signed indices
inline label facePointN
(
const block& block,
const label i,
const label j,
const label k
)
{
return block.vtxLabel
(
unsignIndex(i, block.meshDensity().x()),
unsignIndex(j, block.meshDensity().y()),
unsignIndex(k, block.meshDensity().z())
);
}
示例13: generate_genesis_block
//---------------------------------------------------------------
bool generate_genesis_block(
block& bl
, std::string const & genesis_tx
, uint32_t nonce
)
{
//genesis block
bl = boost::value_initialized<block>();
account_public_address ac = boost::value_initialized<account_public_address>();
std::vector<size_t> sz;
construct_miner_tx(0, 0, 0, 0, 0, ac, bl.miner_tx); // zero fee in genesis
blobdata txb = tx_to_blob(bl.miner_tx);
std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb);
std::string genesis_coinbase_tx_hex = config::GENESIS_TX;
blobdata tx_bl;
string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl);
bool r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx);
CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob");
bl.major_version = CURRENT_BLOCK_MAJOR_VERSION;
bl.minor_version = CURRENT_BLOCK_MINOR_VERSION;
bl.timestamp = 0;
bl.nonce = nonce;
miner::find_nonce_for_given_block(bl, 1, 0);
bl.invalidate_hashes();
return true;
}
示例14: addFromClick
void bGroup::addFromClick(block & t, int _x, int _y)
{
for (unsigned int j=0; j<t.blocksIn.size(); j++) {
if (!inHand&&!ddopen&&!t.ddSelected){
int blk=0;
if(blk=t.blocksIn[j].onBlockIn(_x, _y)){
addFromClick(t.blocksIn[j].blocksIn[blk-1], _x, _y);
}
else if(t.blocksIn[j].clickDown(_x,_y)) {
int cur=add(t.passBlocks(OF_BLOCK_IN,j));
inHand=true;
dispx = blocks[cur].x-_x;
dispy = blocks[cur].y-_y;
}
}
}
for (unsigned int j=0; j<t.blocksOn.size(); j++) {
if (!inHand&&!ddopen&&!t.ddSelected){
int blk=0;
if(blk=t.blocksOn[j].onBlockIn(_x, _y)){
addFromClick(t.blocksOn[j].blocksIn[blk-1], _x, _y);
}
}
}
}
示例15: can_place
bool Game::can_place(block b, Point p)
{
bool onAbsCorner = false;
bool onRelCorner = false;
int N = dimension - 1;
Point corners[4] = { Point(0,0), Point(N, 0), Point(0, N), Point(N, N) };
Point corner = corners[my_number];
for(int i = 0; i < b.size(); i++){
Point q = b[i].add(p);
int x = q.x;
int y = q.y;
if (x > N || x < 0 || y < 0 || y > N || grid[x][y] >= 0
|| grid[x][y] == -2
|| (x > 0 && grid[x-1][y] == my_number)
|| (y > 0 && grid[x][y-1] == my_number)
|| (x < N && grid[x+1][y] == my_number)
|| (y < N && grid[x][y+1] == my_number)) {
return false;
}
onAbsCorner = onAbsCorner || q.eq(corner);
onRelCorner = onRelCorner
|| (x > 0 && y > 0 && grid[x-1][y-1] == my_number)
|| (x < N && y > 0 && grid[x+1][y-1] == my_number)
|| (x > 0 && y < N && grid[x-1][y+1] == my_number)
|| (x < N && y < N && grid[x+1][y+1] == my_number);
}
return grid[corner.x][corner.y] < 0 ? onAbsCorner : onRelCorner;
}