using namespace libyang;
using namespace sysrepo;
-namespace {
-
-string encode64(const string& input) {
- vector<uint8_t> binary;
- binary.resize(input.size());
- memmove(&binary[0], input.c_str(), binary.size());
- return (encodeBase64(binary));
-}
-
-string decode64(const string& input) {
- vector<uint8_t> binary;
- decodeBase64(input, binary);
- string result;
- result.resize(binary.size());
- memmove(&result[0], &binary[0], result.size());
- return (result);
-}
-
-} // end of anonymous namespace
-
namespace isc {
namespace yang {
}
}
+string
+TranslatorBasic::decode64(string const& input) {
+ vector<uint8_t> binary;
+ decodeBase64(input, binary);
+ string result;
+ result.resize(binary.size());
+ memmove(&result[0], &binary[0], result.size());
+ return (result);
+}
+
void
TranslatorBasic::deleteItem(const std::string& xpath) {
/// @todo: Remove this if convenient. It is not strictly required and only done to detect
session_.applyChanges();
}
+
+string
+TranslatorBasic::encode64(string const& input) {
+ vector<uint8_t> binary;
+ binary.resize(input.size());
+ memmove(&binary[0], input.c_str(), binary.size());
+ return (encodeBase64(binary));
+}
+
DataNode
TranslatorBasic::findXPath(string const& xpath) {
optional<DataNode> const& data_node(getNode(xpath));
libyang::LeafBaseType const type);
protected:
+ /// @brief Decode a YANG element of binary type to a string that
+ /// can be stored in an Element::string JSON.
+ ///
+ /// @param input string to be decoded
+ ///
+ /// @return the decoded string
+ static std::string decode64(std::string const& input);
+
+ /// @brief Encode a string such that it can be stored in a YANG element of binary type.
+ ///
+ /// @param input string to be encoded
+ ///
+ /// @return the encoded string
+ static std::string encode64(std::string const& input);
+
/// @brief The sysrepo session.
sysrepo::Session session_;