Skip to main content

Browse

s.Browse(node_id, filter = NodeClass::Unspecified) — Lists the direct child nodes (first level) of the specified node.

Prerequisite Reading / Supplementary Materials

Signature​

Both are Session 'sMember Methods, Not a free function.

namespace darra::opcua {

class Session {
public:
std::vector<Reference> Browse(
std::string const& node_id,
NodeClass filter = NodeClass::Unspecified);

std::vector<std::vector<Reference>> BrowseMany(
std::vector<std::string> const& node_ids,
NodeClass filter = NodeClass::Unspecified);
};

}

Reference Structure​

struct Reference {
std::string node_id;
std::string browse_name;
std::string display_name;
NodeClass node_class;
};
FieldTypeNote
node_idstd::stringChild node NodeId String
browse_namestd::stringBrowse Name — Only the QualifiedName "Name" section, without the prefix NamespaceIndex (e.g. Temperature, not 2:Temperature)
display_namestd::stringDisplay Name
node_classNodeClassChild Node Categories
browse_name does not include the prefix ns.

The SDK takes the value itself, browse_name.name, from the server's ReferenceDescription; namespace_index is not concatenated into the string. Therefore:

  • Please provide the child node's bare name Temperature; if you provide a name with a prefix, it will not match 2:Temperature.
  • When it is necessary to distinguish between namespaces, use node_id node_id parse(ns=2;s=...) or rely on auxiliary display_name criteria.

Examples​

#include <darra/opcua/client.hpp>
#include <iostream>

using namespace darra::opcua;

Session s("opc.tcp://localhost:4840");
s.Connect();

// List all child nodes Boiler1 under this node
auto children = s.Browse("ns=2;s=Boiler1");
for (auto const& c : children) {
std::cout << " " << static_cast<int>(c.node_class)
<< " " << c.browse_name << " -> " << c.node_id << "\n";
}

// Show only Variable types
auto vars = s.Browse("ns=2;s=Boiler1", NodeClass::Variable);

// View Only Method
auto methods = s.Browse("ns=2;s=Calculator", NodeClass::Method);

Batch View (BrowseMany)​

If you want to view multiple nodes at the same time (for example, when expanding the tree for the first GUI time), do it in one BrowseMany go RPC:

std::vector<std::string> roots = { "i=85" /* Objects */, "i=86" /* Types */ };
auto results = s.BrowseMany(roots);
for (size_t i = 0; i < roots.size(); ++i) {
std::cout << roots[i] << ":\n";
for (auto const& c : results[i]) {
std::cout << " " << c.browse_name << "\n";
}
}

A single node failure does not affect the entire batch: Slots that fail to NodeId parse or return a server error status code return an empty value std::vector<Reference>, Do not throw exceptions (An exception is thrown only if the entire operation fails RPC .)

NodeClass filter​

enum class NodeClass : int32_t {
Unspecified = 0,
Object = 1,
Variable = 2,
Method = 4,
ObjectType = 8,
VariableType = 16,
ReferenceType = 32,
DataType = 64,
View = 128
};
ValueIncludes
UnspecifiedAll (No category filter)
ObjectObject Only
VariableVariable Only
MethodMethod Only
ObjectType / VariableType / ReferenceType / DataType / ViewCategory Only

filter nodeClassMask Send it to the server as-is as a BrowseRequest; the client no longer performs any secondary filtering. To retrieve multiple categories at once, simply static_cast<NodeClass> combine multiple bits and pass them as a single value.

Exception​

Failure exception ( darra::opcua::Exception inherited std::runtime_error), such as / Status::BadNodeIdUnknown Status::BadCommunicationError. The entire tree throws a failure RPC exception; a single child node failure does not trigger an exception.

To read the status code, use ex.status_code() Na uint32_t:

try {
auto refs = s.Browse("ns=2;s=NotExist");
} catch (Exception const& ex) {
std::printf("0x%08X %s\n", ex.status_code(),
Stack::StatusName(ex.status_code()).c_str());
}
Why use status_code() instead of status()

Exception::status() simply hard-casts uint32_t to enum class Status, while the Status enum only includes a dozen or so common codes; other codes returned by the server convert to values outside the enumeration. This conversion is unreliable when checking equality against Status::Xxx; to avoid errors, compare against constants with status_code(), or use Stack::StatusName() for a readable name (its name table is broader than the Status enum).

Pagination for Large Nodes (ContinuationPoint)​

When the client sends a BrowseRequest, requestedMaxReferencesPerNode is fixed at 1000. If the number of child nodes exceeds this limit, the server returns only the first page along with continuation_point, while Browse returns std::vector<Reference> and the CP is discarded — more than 1000 child nodes means data is silently lost.

To view the entire content, use BrowseWithPaging + BrowseNext:

auto page = s.BrowseWithPaging("ns=2;s=BigFolder");
std::vector<Reference> all_refs = page.references;
while (!page.continuation_point.empty()) {
page = s.BrowseNext(page.continuation_point);
all_refs.insert(all_refs.end(), page.references.begin(), page.references.end());
}

Number of round trips​

  • Browse: 1 time RPC
  • BrowseMany: 1 time RPC — A single BrowseRequest contains N BrowseDescription entries, and the server returns N BrowseResult entries at once; compared to processing them one by one, this Browse saves N-1 network round trips (this is batching, not parallel processing).
  • Maximum of 1000 references per page; anything beyond goes through BrowseWithPaging + BrowseNext

The SDK gives no performance guarantees; real numbers depend on your network and your server.

Lack of Ability (Don't copy from other languages)​

In the C++ export interfaceOnlyBrowse / BrowseMany / BrowseWithPaging / BrowseNext Four access points (client.hpp Session class). The following capabilities in C++ No match found API, Please do not name them after C#, Java, or Rust:

It exists in other languagesThe Current State of C++Alternative Approach
BrowseFiltered (Direction / Reference Type / result_mask Filter)NoneBrowse The direction is fixed as "Forward," the reference type is fixed as " References (i=31) + includeSubtypes," and "result_mask" is fixed 0x3F; these parameters are not SDK exposed. Filter by category filter; to perform a reverse lookup, please perform a reverse search node_id yourself.
BrowseAll (Automatic continuation)NoneWrite a few lines of code for a loop; see BrowseWithPaging The complete template
OpcUaReference / BrowseDirection TypeNoneThe result type is called Reference (client.hpp); the direction cannot be specified.
Full-Tree CrawlingNot API in this group BrowseUse BrowseCrawler

Next Step​