bool
YangRepr::validate(S_Session session, std::ostream& errs) const {
try {
+ // Try to validate. If it succeeds, then we're done here.
session->validate();
return (true);
} catch (const std::exception& ex) {
errs << "validate fails with " << ex.what() << endl;
}
try {
+ // If we get here, it means the validate() threw exceptions.
S_Errors s_errors = session->get_last_errors();
if (!s_errors) {
+
+ // This is really weird. An exception was thrown, but
+ // get_last_errors() didn't return anything. Maybe we're out of
+ // memory or something?
errs << "no errors" << endl;
return (false);
}
namespace test {
/// @brief Yang/sysrepo datastore textual representation class.
+///
+/// This class allows to store a configuration tree in YANG format.
+/// It is used in tests to conduct operations on whole configurations.
class YangRepr {
public:
YangRepr(const std::string& model) : model_(model) {
}
- /// @brief The item class.
+ /// @brief A struct representing a single entry.
struct YangReprItem {
/// @brief Constructor with content.
///
: xpath_(xpath), value_(value), type_(type), settable_(settable) {
}
- /// @brief Factory from session.
+ /// @brief Retrieves configuration parameter from sysrepo
///
- /// @param xpath The xpath.
+ /// @param xpath The xpath of an element to be retrieved
/// @param session Sysrepo session.
+ /// @return YangReprItem instance representing configuration parameter
static YangReprItem get(const std::string& xpath, S_Session session);
/// @brief The xpath.
bool settable_;
/// @brief The equal operator ignoring settable.
+ ///
+ /// @param other the other object to compare with
+ /// @return true if equal
bool operator==(const YangReprItem& other) const {
return ((xpath_ == other.xpath_) &&
(value_ == other.value_) &&
}
/// @brief The unequal operator ignoring settable.
+ ///
+ /// @param other the other object to compare with
+ /// @return false if equal
bool operator!=(const YangReprItem& other) const {
return (!(*this == other));
}
/// @param session Sysrepo session.
Tree get(S_Session session) const;
- /// @brief Verify tree.
+ /// @brief Verifies a tree.
///
/// @param expected The expected value.
/// @param session Sysrepo session.
/// @param errs Error stream.
- /// @return True if verification succeeds, false with errors displayed
+ /// @return true if verification succeeds, false with errors displayed
/// on errs if it fails.
bool verify(const Tree& expected, S_Session session,
std::ostream& errs) const;
- /// @brief Set tree to session.
+ /// @brief Sets specified tree in a sysrepo.
+ ///
+ /// The actual access parameters are specified within session.
///
/// @param tree The tree to install.
/// @param session Sysrepo session.