Implemented KRDataBlock::getString()
--HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40207
This commit is contained in:
@@ -199,3 +199,12 @@ bool KRDataBlock::save(const std::string& path) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get contents as a string
|
||||||
|
std::string KRDataBlock::getString()
|
||||||
|
{
|
||||||
|
KRDataBlock b;
|
||||||
|
b.append(*this);
|
||||||
|
b.append((void *)"\0", 1); // Ensure data is null terminated, to read as a string safely
|
||||||
|
return std::string((char *)b.getStart());
|
||||||
|
}
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ public:
|
|||||||
|
|
||||||
// Return the size of the data block. Use append() or expand() to make the data block larger
|
// Return the size of the data block. Use append() or expand() to make the data block larger
|
||||||
size_t getSize() const;
|
size_t getSize() const;
|
||||||
|
|
||||||
|
// Get the contents as a string
|
||||||
|
std::string getString();
|
||||||
private:
|
private:
|
||||||
void *m_data;
|
void *m_data;
|
||||||
size_t m_data_size;
|
size_t m_data_size;
|
||||||
|
|||||||
Reference in New Issue
Block a user