[DEV] add stream write of data for FSNode (test)

This commit is contained in:
Edouard DUPIN 2015-02-18 15:22:48 +01:00
parent e6a829fd2a
commit 69c052df6a
2 changed files with 44 additions and 0 deletions

View File

@ -1708,6 +1708,39 @@ int64_t etk::FSNode::fileWrite(const void * _data, int64_t _blockSize, int64_t _
#endif
return fwrite(_data, _blockSize, _nbBlock, m_PointerFile);
}
/*
etk::FSNode& etk::FSNode::operator<< (const std::ostream& _data) {
fileWrite(_data.str().c_str(), 1, _data.str().size());
return *this;
}
*/
etk::FSNode& etk::FSNode::operator<< (const std::stringstream& _data) {
std::string sss = _data.str();
fileWrite(sss.c_str(), 1, sss.size());
return *this;
}
etk::FSNode& etk::FSNode::operator<< (const std::string& _data) {
fileWrite(_data.c_str(), 1, _data.size());
return *this;
}
etk::FSNode& etk::FSNode::operator<< (const char* _data) {
fileWrite(_data, 1, strlen(_data));
return *this;
}
etk::FSNode& etk::FSNode::operator<< (const int32_t _data) {
std::stringstream tmp;
tmp << _data;
std::string sss = tmp.str();
fileWrite(sss.c_str(), 1, sss.size());
return *this;
}
etk::FSNode& etk::FSNode::operator<< (const uint32_t _data) {
std::stringstream tmp;
tmp << _data;
std::string sss = tmp.str();
fileWrite(sss.c_str(), 1, sss.size());
return *this;
}
bool etk::FSNode::fileSeek(long int _offset, enum etk::seekNode _origin)
{

View File

@ -452,6 +452,17 @@ namespace etk {
* @return Number of element written (in block number)
*/
int64_t fileWrite(const void* _data, int64_t _blockSize, int64_t _nbBlock);
/**
* @brief Stream write mode
* @param[in] _data Stream to write
* @note not stable API ...
*/
//etk::FSNode& operator<< (const std::ostream& _data);
etk::FSNode& operator<< (const std::stringstream& _data);
etk::FSNode& operator<< (const std::string& _data);
etk::FSNode& operator<< (const char* _data);
etk::FSNode& operator<< (const int32_t _data);
etk::FSNode& operator<< (const uint32_t _data);
/**
* @brief Get the position in the file.
* @return the requested position.