/usr/include/elektra/keysetio.hpp is in libelektra-dev 0.8.14-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | #ifndef ELEKTRA_KEYSET_IO_HPP
#define ELEKTRA_KEYSET_IO_HPP
#include <iostream>
#include <keyio.hpp>
#include <keyset.hpp>
namespace kdb
{
/**
* @brief Outputs line per line the keynames
*
* To output values you should use the plugin framework.
*
* @param os the stream to write to
* @param cks the keyset which should be streamed
*
* Use unsetf(std::ios_base::skipws) or use noskipws iomanip on the stream
* if you want a null terminated sequence of key names.
*
* Use setf(std::ios_base::unitbuf) on the stream if you want to
* flush the buffer after each key.
*
* @return the stream
*/
inline std::ostream & operator << (std::ostream & os, kdb::KeySet const & cks)
{
kdb::KeySet & ks = const_cast<kdb::KeySet &>(cks);
cursor_t c = ks.getCursor();
ks.rewind();
kdb::Key k;
while ((k=ks.next()))
{
os << k;
if (os.flags() & std::ios_base::skipws)
{
os << '\n';
}
else
{
os << '\0';
}
if (os.flags() & std::ios_base::unitbuf)
{
os << std::flush;
}
}
ks.setCursor(c);
return os;
}
/**
* @brief Reads line per line key names and appends those keys to ks.
*
* To input values you need to use the plugin framework.
*
* @param is the stream to read from
* @param ks the keyset to append to
*
* @return the stream
*/
inline std::istream & operator >> (std::istream & is, kdb::KeySet & ks)
{
cursor_t c = ks.getCursor();
while (!is.eof())
{
kdb::Key k;
is >> k;
ks.append(k);
}
ks.setCursor(c); // jump back to previous cursor
return is;
}
}
#endif
|