Skip to content

Improve checking of Folder element in SyncFolderHierarchy #161

Description

@idolum

Something like this:

    //! Utility function for finding the first node of
    //! a list of names.
    //! \param elem XML node the node should retrieved from
    //! \param node_names Names of requested nodes
    //! \returns Pointer to found XML node
    inline rapidxml::xml_node<>* find_first_node_of_ns(
        const rapidxml::xml_node<>& elem,
        const Ch* namespace,
        const std::vector<std::string>& node_names)
    {
        using namespace rapidxml;

        xml_node<>* result;

        for (auto name : node_names)
        {
            result = elem.first_node_ns(namespace, name);
            if (result)
            {
                return result;
            }
        }

        return result;
    }

Then it is possible to retrieve several node types:

std::vector<std::string> elem_list = { "Folder",
    "ContactsFolder", "SearchFolder", "TaskFolder" };
const auto folder_elem = item_elem.find_first_node_of_ns(
                    internal::uri<>::microsoft::types(), elem_list);
check(folder_elem,
   "Expected <Folder>, <ContactsFolder>, <SearchFolder> or <TaskFolder> element");

Originally posted by @idolum in #156 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions