本文整理汇总了C++中Blob::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Blob::get方法的具体用法?C++ Blob::get怎么用?C++ Blob::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toXmlString
string toXmlString(const Blob& val, bool* pError)
{
if (pError != NULL)
{
*pError = false;
}
// A copy from vector<unsigned char> to XMLByte* is not required because XMLByte is typedef'd to unsigned char.
// If this ever changes, this will fail to build; in this case, a copy will need to be made.
const vector<XMLByte>& values = val.get();
if (values.empty())
{
return string();
}
XMLSize_t outlen;
XMLByte* pBase64 =
XERCES_CPP_NAMESPACE_QUALIFIER Base64::encode(&values[0], values.size() * sizeof(values[0]), &outlen);
if (outlen == 0 || pBase64 == NULL)
{
if (pError != NULL)
{
*pError = true;
}
return string();
}
string xmlString(reinterpret_cast<char*>(pBase64), outlen);
// Use ::operator delete() per Xerces documentation.
::operator delete(pBase64);
return xmlString;
}
示例2: main
int main(int argc, char *argv[])
{
Blob *blob = new Blob;
char foo[] = { 'f', 'o', 'o' };
char bar[] = { 'b', 'a', 'r' };
char egg[] = { 'e', 'g', 'g' };
char spam[] = { 's', 'p', 'a', 'm' };
blob->debugPrint();
debugText(foo, sizeof(foo));
blob->append(foo, sizeof(foo));
blob->debugPrint();
debugText(bar, sizeof(bar));
blob->append(bar, sizeof(bar));
blob->debugPrint();
debugText(egg, sizeof(egg));
blob->append(egg, sizeof(egg));
blob->append('x');
blob->debugPrint();
debugText(spam, sizeof(spam));
blob->append(spam, sizeof(spam));
blob->debugPrint();
std::cout << "text: " << blob->get() << std::endl;
delete blob;
return 0;
}
示例3: fileOut
void FileUtil::Buffer2File(const Blob<char>& blob,const std::string& filePath)
{
CFileOutputStream fileOut(filePath.c_str());
fileOut.write((unsigned char*)blob.get(),blob.size());
fileOut.close();
}
示例4: fileIn
Blob<char> FileUtil::File2Buffer(const std::string& filePath)
{
CFileInputStream fileIn(filePath.c_str());
long fileLength = fileIn.available();
Blob<char> blob;
blob.setData(auto_array_ptr<char>(new char[fileLength]),fileLength);
fileIn.read((unsigned char*)blob.get(),fileLength);
fileIn.close();
return blob;
}
示例5:
void B64OutputStream::push(Blob<unsigned char>& blob)
{
int length = blob.length();
int index = 0;
int toWrite = 0;
while(length > 0)
{
toWrite = m_charsPerLine > length?length:m_charsPerLine;
toWrite -= m_lastCharOfLine;
if(toWrite <=0)
{
if(m_charsPerLine != -1)
{
toWrite = m_charsPerLine > length?length:m_charsPerLine;
}
else
{
toWrite = length;
}
}
m_output->write(blob.get() + index,toWrite);
m_lastCharOfLine += toWrite;
if((m_lastCharOfLine == m_charsPerLine)&&(m_charsPerLine != -1))
m_output->write((unsigned char*)m_newLineChar.c_str(),m_newLineChar.length());
index += toWrite;
length -= toWrite;
if(m_lastCharOfLine >= m_charsPerLine)
{
m_lastCharOfLine -= m_charsPerLine;
}
}
}