Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch 
into lp:zorba.

Commit message:
added comments and getContentType() method to SequenceType class

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/187917

added comments and getContentType() method to SequenceType class
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/187917
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/typeident.h'
--- include/zorba/typeident.h	2013-09-16 09:08:27 +0000
+++ include/zorba/typeident.h	2013-09-26 20:59:19 +0000
@@ -35,10 +35,6 @@
  * SequenceType may be returned by methods of Zorba's C++ API. The class also
  * provides static methods to create instances of SequenceType, which can then
  * be passed as arguments to other methods of Zorba's C++ API.
- *
- * Note: This class is reference counted. When writing multi-threaded clients,
- * it is the responibility of the client code to synchronize assignments to the
- * SmartPtr holding this object.
  */
 class ZORBA_DLL_PUBLIC SequenceType
 {
@@ -51,18 +47,18 @@
     FUNCTION_TYPE,            // function(*) and subtypes
     STRUCTURED_ITEM_TYPE,     // structured-item()
     NODE_TYPE,                // node()
-    DOCUMENT_TYPE,
-    ELEMENT_TYPE,
-    SCHEMA_ELEMENT_TYPE,
-    ATTRIBUTE_TYPE,
-    SCHEMA_ATTRIBUTE_TYPE,
-    PI_TYPE,
-    TEXT_TYPE,
-    COMMENT_TYPE,
-    NAMESPACE_TYPE,
-    JSON_ITEM_TYPE,
-    JSON_OBJECT_TYPE,
-    JSON_ARRAY_TYPE,
+    DOCUMENT_TYPE,            // document-node() and subtypes
+    ELEMENT_TYPE,             // element() and subtypes
+    SCHEMA_ELEMENT_TYPE,      // schema-element() and subtypes
+    ATTRIBUTE_TYPE,           // attribute() and subtypes
+    SCHEMA_ATTRIBUTE_TYPE,    // schema-attribute() and subtypes
+    PI_TYPE,                  // processing-instruction() and subtypes
+    TEXT_TYPE,                // text()
+    COMMENT_TYPE,             // comment()
+    NAMESPACE_TYPE,           // namespace-node()
+    JSON_ITEM_TYPE,           // json-item()
+    JSON_OBJECT_TYPE,         // object()
+    JSON_ARRAY_TYPE,          // array()
     INVALID_TYPE
   } Kind;
   
@@ -176,28 +172,88 @@
    */
   ~SequenceType();
 
+  /**
+   *
+   */
   bool isValid() const;
 
+  /**
+   *
+   */
   Kind getKind() const;
 
+  /**
+   *
+   */
   Quantifier getQuantifier() const;
 
+  /**
+   * If this is an atomic or union type, this method returns the URI of
+   * the type name. For other kinds of types, an empty string is returned.
+   */
   String getTypeUri() const;
 
+  /**
+   * If this is an atomic or union type, this method returns the local part of
+   * the type name. For other kinds of types, an empty string is returned.
+   */
   String getTypeLocalName() const;
 
+  /**
+   * If this is an element() or attribute() type that contains a NodeName,
+   * this method returns the URI of that NodeName. In all other cases, an
+   * empty string is returned.
+   */
   String getNodeUri() const;
 
+  /**
+   * If this is an element() or attribute() type that contains a NodeName,
+   * this method returns the URI of that NodeName. If this is a 
+   * processing-instruction() that contains a TargetName, that TargetName is
+   * returned. In all other cases, an empty string is returned.
+   */
   String getNodeLocalName() const;
 
+  /**
+   * If this is an element() or attribute() type that does not contain a
+   * NodeName, this method returns true. In all other cases, false is returned.
+   */
   bool isWildcard() const;
 
+  /**
+   * If this is an document-node() type that contains an embedded element()
+   * type, this method returns the embedded element() type. In all other cases,
+   * an invalid SequenceType is returned.
+   */
+  SequenceType getContentType() const;
+
+  /**
+   * If this is an element() or attribute() type that contains a TypeName, this
+   * method returns the URI of that TypeName. If this is a schema-element(N) or
+   * schema-attribute(N) type, the method returns the URI of the XMLSchema type
+   * associated with the global element or attribute declaration N. In all other
+   * cases, it returns an empty string.
+   */
   String getContentTypeUri() const;
 
+  /**
+   * If this is an element() or attribute() type that contains a TypeName, this
+   * method returns the local name of that TypeName. If this is a schema-element(N)
+   * or schema-attribute(N) type, the method returns the local name of the
+   * XMLSchema type associated with the global element or attribute declaration N.
+   * In all other cases, it returns an empty string.
+   */
   String getContentTypeLocalName() const;
 
+  /**
+   * Return true if this type is a schema-element() or schema-attribute() type,
+   * Otherwise return false.
+   */
   bool isSchemaTest() const;
 
+  /**
+   *
+   */
   std::ostream& emit(std::ostream&) const;
 
  private:

=== modified file 'src/api/sequencetype.cpp'
--- src/api/sequencetype.cpp	2013-09-16 09:44:52 +0000
+++ src/api/sequencetype.cpp	2013-09-26 20:59:19 +0000
@@ -527,13 +527,19 @@
 
 SequenceType::Quantifier SequenceType::getQuantifier() const
 {
+  if (theType == NULL)
+    return QUANT_INVALID;
+
   return (theType->get_quantifier());
 }
 
 
 SequenceType::Kind SequenceType::getKind() const
 {
-  switch(theType->type_kind()) 
+  if (theType == NULL)
+    return INVALID_TYPE;
+
+  switch (theType->type_kind()) 
   {
   case XQType::EMPTY_KIND:
   {
@@ -705,6 +711,30 @@
 }
 
 
+SequenceType SequenceType::getContentType() const
+{
+  switch (theType->type_kind())
+  {
+  case XQType::NODE_TYPE_KIND:
+  {
+    const NodeXQType* nt = static_cast<const NodeXQType*>(theType);
+
+    store::StoreConsts::NodeKind nodeKind = nt->get_node_kind();
+
+    if (nodeKind == store::StoreConsts::documentNode)
+    {
+      const XQType* contentType = nt->get_content_type();
+
+      return Unmarshaller::createSequenceType(contentType);
+    }
+  }
+  default:
+  {
+    return Unmarshaller::createSequenceType(NULL);
+  }
+  }
+}
+
 String SequenceType::getContentTypeUri() const
 {
   switch (theType->type_kind())
@@ -765,7 +795,11 @@
   {
     const NodeXQType* nt = static_cast<const NodeXQType*>(theType);
 
-    if (nt->get_node_name() == NULL)
+    store::StoreConsts::NodeKind nodeKind = nt->get_node_kind();
+
+    if (nt->get_node_name() == NULL &&
+        (nodeKind == store::StoreConsts::elementNode ||
+         nodeKind == store::StoreConsts::attributeNode))
       return true;
   }
 

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to