當前位置: 首頁>>代碼示例>>C++>>正文


C++ Blob函數代碼示例

本文整理匯總了C++中Blob函數的典型用法代碼示例。如果您正苦於以下問題:C++ Blob函數的具體用法?C++ Blob怎麽用?C++ Blob使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Blob函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: CHECK

void MatrixServerTable<T>::ProcessGet(const std::vector<Blob>& data,
  std::vector<Blob>* result) {
  CHECK(data.size() == 1);
  CHECK_NOTNULL(result);

  result->push_back(data[0]); // also push the key

  size_t keys_size = data[0].size<integer_t>();
  integer_t* keys = reinterpret_cast<integer_t*>(data[0].data());

  //get all rows
  if (keys_size == 1 && keys[0] == -1){
    Blob value(sizeof(T) * storage_.size());
    T* pvalues = reinterpret_cast<T*>(value.data());
    updater_->Access(storage_.size(), storage_.data(), pvalues);
    result->push_back(value);
    result->push_back(Blob(&server_id_, sizeof(int)));
    Log::Debug("[ProcessGet] Server = %d, getting rows offset = %d, #rows = %d\n",
      server_id_, row_offset_, storage_.size() / num_col_);
    return;
  }

  integer_t row_size = sizeof(T)* num_col_;
  result->push_back(Blob(keys_size * row_size));
  T* vals = reinterpret_cast<T*>((*result)[1].data());
  integer_t offset_v = 0;
  for (auto i = 0; i < keys_size; ++i) {
    integer_t offset_s = (keys[i] - row_offset_) * num_col_;
    updater_->Access(num_col_, storage_.data(), vals + offset_v, offset_s);
    offset_v += num_col_;
    Log::Debug("[ProcessAdd] Server = %d, getting #row = %d\n",
      server_id_, keys[i]);
  }
}
開發者ID:pbnj-io,項目名稱:multiverso,代碼行數:34,代碼來源:matrix_table.cpp

示例2: while

bool BdbReader::Read(Blob& key, Blob& value) {
LAB_AGAIN:
	while (true) {
		if (m_idx < 0)
			return false;
		if (m_idx < m_entries)
			break;
		if (!LoadNextPage(m_pgno+1))
			return false;
	}
	int keyIdx = *((UInt16*)(m_curPage.data()+26)+m_idx*2),
		valIdx = *((UInt16*)(m_curPage.data()+26)+m_idx*2+1);
	if (keyIdx+3 > m_curPage.Size || valIdx+3 > m_curPage.Size) {
		m_idx = m_entries;
		goto LAB_AGAIN;
	}
	++m_idx;
	int keyLen = *(UInt16*)(m_curPage.data()+keyIdx),
		valLen = *(UInt16*)(m_curPage.data()+valIdx);
	if (keyIdx+keyLen > m_curPage.Size || valIdx+valLen > m_curPage.Size) {
		m_idx = m_entries;
		goto LAB_AGAIN;
	}
	if (*(m_curPage.data()+keyIdx+2) != 1 || *(m_curPage.data()+valIdx+2) != 1)
		goto LAB_AGAIN;
	key = Blob(m_curPage.data()+keyIdx+3, keyLen);
	value = Blob(m_curPage.data()+valIdx+3, valLen);
	return true;
}
開發者ID:coinhelper,項目名稱:coin,代碼行數:29,代碼來源:bdb-reader.cpp

示例3: Blob

Blob Object::toBlob() const
{
	if(isBlob())
		return Blob(*this);
	else
		return Blob();
}
開發者ID:balooloo,項目名稱:libgit2pp,代碼行數:7,代碼來源:object.cpp

示例4: Blob

void 
Sha256WithRsaSignature::set(const struct ndn_Signature& signatureStruct)
{
  digestAlgorithm_ = Blob(signatureStruct.digestAlgorithm);
  witness_ = Blob(signatureStruct.witness);
  signature_ = Blob(signatureStruct.signature);
  publisherPublicKeyDigest_.set(signatureStruct.publisherPublicKeyDigest);
  keyLocator_.set(signatureStruct.keyLocator);
}
開發者ID:flily,項目名稱:ndn-cpp,代碼行數:9,代碼來源:sha256-with-rsa-signature.cpp

示例5: FamilySize

Blob IPAddress::GetAddressBytes() const {
	int size = FamilySize(AddressFamily);
	if (!size)
		Throw(ExtErr::UnknownHostAddressType);
	switch ((int)get_AddressFamily()) {
	case AF_INET:
		return Blob(&m_sin.sin_addr, 4);
	case AF_INET6:
		return Blob(&m_sin6.sin6_addr, 16);
	default:
		Throw(ExtErr::UnknownHostAddressType);
	}
}
開發者ID:Groestlcoin,項目名稱:el,代碼行數:13,代碼來源:ext-ip-address.cpp

示例6: Throw

Blob Sec256Signature::Serialize() const {
	uint8_t buf[100];
	size_t size = sizeof buf;
	if (!secp256k1_ecdsa_sig_serialize(buf, &size, &m_r, &m_s))
		Throw(errc::invalid_argument);
	return Blob(buf, size);
}
開發者ID:ufasoft,項目名稱:coin,代碼行數:7,代碼來源:secp256k1-envelop.cpp

示例7: ASSERT

Blob Sec256Dsa::PrivKeyToDER(RCSpan privKey, bool bCompressed) {
	ASSERT(privKey.size() == 32);
	uint8_t ar[279];
	size_t privkeylen = sizeof ar;
	Sec256Check(::ec_privkey_export_der(g_sec256Ctx, ar, &privkeylen, privKey.data(), bCompressed));
	return Blob(ar, privkeylen);
}
開發者ID:ufasoft,項目名稱:coin,代碼行數:7,代碼來源:secp256k1-envelop.cpp

示例8: gotStaleData

    /** We got some data for a ledger we are no longer acquiring
        Since we paid the price to receive it, we might as well stash it in case we need it.
        Nodes are received in wire format and must be stashed/hashed in prefix format
    */
    void gotStaleData (std::shared_ptr<protocol::TMLedgerData> packet_ptr)
    {
        const uint256 uZero;
        Serializer s;
        try
        {
            for (int i = 0; i < packet_ptr->nodes ().size (); ++i)
            {
                auto const& node = packet_ptr->nodes (i);

                if (!node.has_nodeid () || !node.has_nodedata ())
                    return;

                auto newNode = SHAMapAbstractNode::make(
                    Blob (node.nodedata().begin(), node.nodedata().end()),
                    0, snfWIRE, uZero, false);

                if (!newNode)
                    return;

                s.erase();
                newNode->addRaw(s, snfPREFIX);

                auto blob = std::make_shared<Blob> (s.begin(), s.end());

                getApp().getOPs().addFetchPack (newNode->getNodeHash(), blob);
            }
        }
        catch (...)
        {
        }
    }
開發者ID:xdv,項目名稱:divvyd,代碼行數:36,代碼來源:InboundLedgers.cpp

示例9: ConvertFromBase58

Blob ConvertFromBase58(RCString s, bool bCheckHash) {
	BigInteger bi = 0;
	for (const char *p=s; *p; ++p) {
		if (const char *q = strchr(s_pszBase58, *p)) {
			bi = bi*58 + BigInteger(q-s_pszBase58);
		} else
			Throw(errc::invalid_argument);
	}
	vector<byte> v((bi.Length+7)/8);
	bi.ToBytes(&v[0], v.size());
	if (v.size()>=2 && v.end()[-1]==0 && v.end()[-1]>=0x80)
		v.resize(v.size()-1);
	vector<byte> r;
	for (const char *p=s; *p==s_pszBase58[0]; ++p)
		r.push_back(0);
	r.resize(r.size()+v.size());
	std::reverse_copy(v.begin(), v.end(), r.end()-v.size());
	if (r.size() < 4)
		Throw(E_FAIL);
	if (bCheckHash) {
		HashValue hash = HasherEng::GetCurrent()->HashForAddress(ConstBuf(&r[0], r.size()-4));
		if (memcmp(hash.data(), &r.end()[-4], 4))
			Throw(HRESULT_FROM_WIN32(ERROR_CRC));
	}
	return Blob(&r[0], r.size()-4);
}
開發者ID:Groestlcoin,項目名稱:Groestlcoin-WPF,代碼行數:26,代碼來源:base58.cpp

示例10: ConvertFromBase58ShaSquare

Blob ConvertFromBase58ShaSquare(RCString s) {
	BigInteger bi = 0;
	for (const char *p=s; *p; ++p) {
		if (const char *q = strchr(s_pszBase58, *p)) {
			bi = bi*58 + BigInteger(q-s_pszBase58);
		} else
			Throw(E_INVALIDARG);
	}
	vector<byte> v((bi.Length+7)/8);
	bi.ToBytes(&v[0], v.size());
	if (v.size()>=2 && v.end()[-1]==0 && v.end()[-1]>=0x80)
		v.resize(v.size()-1);
	vector<byte> r;
	for (const char *p=s; *p==s_pszBase58[0]; ++p)
		r.push_back(0);
	r.resize(r.size()+v.size());
	std::reverse_copy(v.begin(), v.end(), r.end()-v.size());
	if (r.size() < 4)
		Throw(E_FAIL);
	SHA256 sha;
	HashValue hash = HashValue(sha.ComputeHash(sha.ComputeHash(ConstBuf(&r[0], r.size()-4))));
	if (memcmp(hash.data(), &r.end()[-4], 4))
		Throw(HRESULT_FROM_WIN32(ERROR_CRC));
	return Blob(&r[0], r.size()-4);
}
開發者ID:Groestlcoin,項目名稱:Groestlcoin-WPF,代碼行數:25,代碼來源:base58.cpp

示例11: Win32Check

SecurityDescriptor::SecurityDescriptor(RCString s) {
	PSECURITY_DESCRIPTOR pSD;
	ULONG size;
	Win32Check(::ConvertStringSecurityDescriptorToSecurityDescriptor(s, SDDL_REVISION_1, &pSD, &size));
	m_blob = Blob(pSD, size);
	Win32Check(!::LocalFree(pSD));
}
開發者ID:Groestlcoin,項目名稱:el,代碼行數:7,代碼來源:secdesc.cpp

示例12: msg

void Zoo::RegisterNode() {
  MessagePtr msg(new Message());
  msg->set_src(rank());
  msg->set_dst(kController);
  msg->set_type(MsgType::Control_Register);
  msg->Push(Blob(&nodes_[rank()], sizeof(Node)));
  SendTo(actor::kCommunicator, msg);

  // waif for reply
  mailbox_->Pop(msg);
  CHECK(msg->type() == MsgType::Control_Reply_Register);
  CHECK(msg->data().size() == 2);
  Blob info_blob = msg->data()[0];
  Blob count_blob = msg->data()[1];
  num_workers_ = count_blob.As<int>(0);
  num_servers_ = count_blob.As<int>(1);
  worker_id_to_rank_.resize(num_workers_);
  server_id_to_rank_.resize(num_servers_);
  CHECK(info_blob.size() == size() * sizeof(Node));
  memcpy(nodes_.data(), info_blob.data(), info_blob.size());
  for (auto node : nodes_) {
    if (node.worker_id != -1) {
      worker_id_to_rank_[node.worker_id] = node.rank;
    }
    if (node.server_id != -1) {
      server_id_to_rank_[node.server_id] = node.rank;
    }
  }
  Log::Debug("rank %d end register\n", Zoo::Get()->rank());
}
開發者ID:Microsoft,項目名稱:multiverso,代碼行數:30,代碼來源:zoo.cpp

示例13: wireDecode

 /**
  * Decode the input using a particular wire format and update this Data. If wireFormat is the default wire format, also
  * set the defaultWireEncoding field to a copy of the input. (To not copy the input, see wireDecode(Blob).)
  * @param input The input byte array to be decoded.
  * @param inputLength The length of input.
  * @param wireFormat A WireFormat object used to decode the input. If omitted, use WireFormat getDefaultWireFormat().
  */
 void
 wireDecode
   (const uint8_t* input, size_t inputLength,
    WireFormat& wireFormat = *WireFormat::getDefaultWireFormat())
 {
   wireDecode(Blob(input, inputLength), wireFormat);
 }
開發者ID:named-data,項目名稱:ndn-cpp,代碼行數:14,代碼來源:data.hpp

示例14: Blob

void BlobDetector::detect()
{

    double sigmaFirst = data->getSigmaFirst();
    double sigmaStep = data->getSigmaStep();
    for (int oID = 0; oID < data->octavs.size(); oID++)
    {
        //data->octavs[oID]->genDOG();
        double sigma = sigmaFirst*(1<<oID);
        double littlesigma = 1;

        for (int layerID = 1; layerID < data->octavs[oID]->dogs.size()-1; layerID++)
        {
            unique_ptr<HarrisDetector> harrisDetector = make_unique<HarrisDetector>(data->octavs[oID]->layers[layerID].get());
            harrisDetector->configure(0.01,0.06,1);
            ImageMap* img =  data->octavs[oID]->dogs[layerID].get();
            for (int x=0;x<img->getWidth();x++)
            {
                for (int y=0;y<img->getHeight();y++)
                {
                    bool isMax = true;
                    bool isMin = true;
                    double val = img->getData(x,y);//* sigma;
                    if(val<0.031 && val>-0.031) continue;
                    //double ds =  sigma/sigmaStep;
                    //int dl = layerID;
                    for (int dl = layerID-1; dl <= layerID+1; dl++)
                    {
                        ImageMap* img1 =  data->octavs[oID]->dogs[dl].get();
                        for(int dx = x-1; dx <= x+1; dx++)
                        {
                            for(int dy = y-1; dy <= y+1; dy++)
                            {
                                double val1 = img1->getData(dx,dy);//*ds;
                                if (dx != x || dy != y || dl != layerID)
                                {
                                    isMax &= (val1 < val);
                                    isMin &= (val1 > val);
                                }

                            }
                        }
                      //  ds*=sigmaStep;
                    }
                    if (isMax || isMin)
                    {
                        Blob b = Blob(x,y,sigma,val);
                        b.scale = (oID);
                        data->blobs.push_back(b);
                        data->blobs[data->blobs.size()-1].isClone = false;
                        data->descriptors.push_back(harrisDetector->calcDescriptor(littlesigma,&(data->blobs[data->blobs.size()-1])));
                    }
               }
          }
            littlesigma*=sigmaStep;
            sigma*=sigmaStep;
       }
    }
}
開發者ID:smart-frogg,項目名稱:image_worker,代碼行數:59,代碼來源:blobdetector.cpp

示例15: buf

UTF8 JSON::generate(Error& error) const
{
	Buffer buf(0);
	HOutputStream out = NewObject(MemoryOutputStream, buf);
	generate(error, out);
	out->twrite(error,'\0');
	return UTF8(Blob(buf));
}
開發者ID:tomazos,項目名稱:Folderscope,代碼行數:8,代碼來源:JSON.cpp


注:本文中的Blob函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。