/usr/include/elektra/kdbio.hpp is in libelektra-dev 0.8.7-4.
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 84 85 86 87 | #ifndef ELEKTRA_KDB_IO_HPP
#define ELEKTRA_KDB_IO_HPP
/*
* @brief See examples/cpp_example_userio.cpp for how to use
* USER_DEFINED_IO
*/
#ifndef USER_DEFINED_IO
#include <key.hpp>
#include <ostream>
#include <iomanip>
namespace kdb
{
inline std::ostream & printError(std::ostream & os, kdb::Key const & error)
{
try {
if (!error.getMeta<const kdb::Key>("error"))
{
// no error available
return os;
}
error.getMeta<std::string>("error");
os << "Error (#" << error.getMeta<std::string>("error/number") << ") occurred!" << std::endl;
os << "Description: " << error.getMeta<std::string>("error/description") << std::endl;
os << "Ingroup: " << error.getMeta<std::string>("error/ingroup") << std::endl;
os << "Module: " << error.getMeta<std::string>("error/module") << std::endl;
os << "At: " << error.getMeta<std::string>("error/file") << ":" << error.getMeta<std::string>("error/line") << std::endl;
os << "Reason: " << error.getMeta<std::string>("error/reason") << std::endl;
} catch (kdb::KeyTypeConversion const& e)
{
os << "Error meta data is not set correctly by a plugin: " << e.what() << std::endl;
}
return os;
}
inline std::ostream & printWarnings(std::ostream & os, kdb::Key const & error)
{
try {
if (!error.getMeta<const kdb::Key>("warnings"))
{
// no warnings were issued
return os;
}
int nr = error.getMeta<int>("warnings");
if (!nr)
{
os << "1 Warning was issued:" << std::endl;
}
else
{
os << nr+1 << " Warnings were issued:" << std::endl;
}
for (int i=0; i<=nr; i++)
{
std::ostringstream name;
name << "warnings/#" << std::setfill('0') << std::setw(2) << i;
// os << "\t" << name.str() << ": " << error.getMeta<std::string>(name.str()) << std::endl;
os << "\tWarning number: " << error.getMeta<std::string>(name.str() + "/number") << std::endl;
os << "\tDescription: " << error.getMeta<std::string>(name.str() + "/description") << std::endl;
os << "\tIngroup: " << error.getMeta<std::string>(name.str() + "/ingroup") << std::endl;
os << "\tModule: " << error.getMeta<std::string>(name.str() + "/module") << std::endl;
os << "\tAt: " << error.getMeta<std::string>(name.str() + "/file") << ":"
<< error.getMeta<std::string>(name.str() + "/line") << std::endl;
os << "\tReason: " << error.getMeta<std::string>(name.str() + "/reason") << std::endl;
}
} catch (kdb::KeyTypeConversion const& e)
{
os << "Warnings meta data not set correctly by a plugin: " << e.what() << std::endl;
}
return os;
}
}
#endif
#endif
|