rwsf::Member rwsf::HandleBase
#include <rwsf/xmlbinding/Member.h>
Class rwsf::Member is a container for holding class instances that represent members of XML Binding classes. rwsf::Member instances provide a generic way of returning values using the get() interface and of passing values using the set() interface of each XML Binding class.
rwsf::Member implements the handle/body idiom. An instance of this class is a handle to one of two private, reference-counted bodies, either rwsf::PrimitiveMemberImp<T> if the member is simple type, or rwsf::TypedMemberImp<T> if the member is a complex type.
Member();
Constructs an empty member handle.
Member(MemberImp* imp);
Constructs a new handle attached to the body imp.
virtual int
exists(const rwsf::XmlName& member);
Determines whether the specified member exists within this. If the member contains an array of elements (maxOccurs>1), returns its length. If the member contains a single element, returns 1. If member does not exist, returns 0.
virtual std::vector<rwsf::Member>
get(const rwsf::XmlName& member);
Returns the values of the member named in member as a vector of rwsf::Member instances. If the member represents a complex type, this method passes to the get() method of that type. If the member represents a simple type, the method returns an empty vector.
virtual void
set(const rwsf::XmlName& member,
const std::vector<rwsf::Member>& values);
Sets the values of the member named by member, using the data in the rwsf::Member instances contained in the vector values. If the member represents a complex type, the method passes to the set() method of that type. If the member represents a simple type, the method does nothing.
MemberImp&
body() const;
Returns a reference to the body. If the body pointer is null, throws a rwsf::ExternalException exception.
template <class T>
static Member
createPrimitive(const T& value);
Returns a new rwsf::Member instance templatized on a primitive type. As a primitive type, this instance contains no instances of nested classes, and so has no generic get(), set(), and exists() methods.
template <class T>
static Member
createTyped(const T& value);
Returns a new rwsf::Member instance templatized on a complex type. This instance provides generic get(),set(), and exists() methods to access its members.
static std::vector<rwsf::Member>
get(rwsf::Member m, std::string xpath);
A generic get the supports access to nested members by name without having to specify the type of the member. This method uses the XPath expression xpath to return the values for nested members represented by the rwsf::Member m. The return vector contains rwsf::Member instances that wrap the values of the elements or attributes contained in the member.
The XPath expression must be relative, beginning either with a dot (.) or with an identifier. The leaf node may be either an element or an attribute. For attributes, you can use the "@" character for clarity, but it is not required.
If the path is valid but the member does not exist, the method returns an empty vector. If the path is not valid, the method throws a rwsf::Exception.
static std::vector<rwsf::Member>
get(rwsf::Member m, std::string xpath,
const rwsf::XmlNamespaceStack& nsStack);
A generic get the supports access to nested members by name without having to specify the type of the member. This method uses the XPath expression xpath to return the values for nested members represented by the rwsf::Member m. The return vector contains rwsf::Member instances that wrap the values of the elements or attributes contained in the member.
The XPath expression must relative, beginning either with a dot (.) or with an identifier. The leaf node may be either an element or an attribute. For attributes, you can use the "@" character for clarity, but it is not required.
The namespace stack parameter nsStack allows member names qualified with a namespace to be resolved. Create the namespace stack as follows:
rwsf::XmlNamespaceStack nsStack; // for each namespace that needs to be resolved rwsf::XmlNamespace namespaceItem; namespaceItem.setPrefix("n"); namespaceItem.setURI("http://www.hprim.org/hprimXML"); nsStack.pushScope(); nsStack.addNamespace(namespaceItem);
results = rwsf::Member::get(top, "n:actesNGAP", nsStack);
If the path is valid but the member does not exist, the method returns an empty vector. If the path is not valid, the method throws a rwsf::Exception.
static void
set(rwsf::Member m, std::string xpath,
const std::vector<rwsf::Member>& values);
A generic set the supports setting the values of nested members by name without having to specify the type of the member. This method uses the XPath expression xpath to set the values for a nested member represented by the rwsf::Member m based on the values contained in values.
The XPath expression must relative, beginning either with a dot (.) or with an identifier. The leaf node may be either an element or an attribute. For attributes, you can use the "@" character for clarity, but it is not required.
If the path is valid but m does not exist, this method creates it, using the factory methods (see rwsf::XmlBindingFactory). If the path is not valid, throws a rwsf::Exception.
static int
exists(rwsf::Member m, std::string xpath);
Determines whether xpath represents a valid path to the member represented by rwsf::Member m.
Return values are:
-1 |
Invalid path |
0 |
Path valid, but no member exists |
n |
Number of elements in the member |
The XPath expression must relative, beginning either with a dot (.) or with an identifier. The leaf node may be either an element or an attribute. For attributes, you can use the "@" character for clarity, but it is not required.
If the path is valid but the member does not exist, this method creates it using the factory methods (see rwsf::XmlBindingFactory).
template<class T>
void
operator>>(const Member& m, T& value);
Inserts value into rwsf::Member m.
©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.