← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/create-user-typed-atomic-item into lp:zorba

 

Ghislain Fourny has proposed merging lp:~zorba-coders/zorba/create-user-typed-atomic-item into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)
  Matthias Brantner (matthias-brantner)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/create-user-typed-atomic-item/+merge/120560

Introduces an item factory function to create atomic items with a user-defined type.
-- 
https://code.launchpad.net/~zorba-coders/zorba/create-user-typed-atomic-item/+merge/120560
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'include/zorba/item_factory.h'
--- include/zorba/item_factory.h	2012-08-16 18:31:02 +0000
+++ include/zorba/item_factory.h	2012-08-21 13:23:26 +0000
@@ -778,6 +778,17 @@
       assignElementTypedValue(Item& aElement,
                               std::vector<Item>& aTypedValue) = 0;
 
+      /**
+       * Create an atomic item having a user-defined atomic type.
+       *
+       * @param aBaseItem the base item of the item to create.
+       * @param aTypeName the name of the type of the item to create.
+       *
+       * @return a new atomic item having the given user-defined atomic type.
+       */
+      virtual Item
+      createUserTypedAtomicItem(Item& aBaseItem, Item& aTypeName) = 0;
+
   }; // class ItemFactory
 
 } // namespace zorba

=== modified file 'src/api/itemfactoryimpl.cpp'
--- src/api/itemfactoryimpl.cpp	2012-08-16 18:31:02 +0000
+++ src/api/itemfactoryimpl.cpp	2012-08-21 13:23:26 +0000
@@ -950,11 +950,18 @@
   return &*lItem;
 }
 
-
-
-
 #endif /* ZORBA_WITH_JSON */
 
+zorba::Item ItemFactoryImpl::createUserTypedAtomicItem(
+    Item& aBaseItem,
+    Item& aTypeName)
+{
+  store::Item_t lRes;
+  store::Item_t lBaseItem = Unmarshaller::getInternalItem(aBaseItem);
+  store::Item_t lTypeName = Unmarshaller::getInternalItem(aTypeName);
+  theItemFactory->createUserTypedAtomicItem(lRes, lBaseItem, lTypeName);
+  return &*lRes;
+}
 
 } // namespace zorba
 /* vim:set et sw=2 ts=2: */

=== modified file 'src/api/itemfactoryimpl.h'
--- src/api/itemfactoryimpl.h	2012-08-16 18:31:02 +0000
+++ src/api/itemfactoryimpl.h	2012-08-21 13:23:26 +0000
@@ -278,6 +278,9 @@
 
 #endif /* ZORBA_WITH_JSON */
 
+      virtual Item
+      createUserTypedAtomicItem(Item& aBaseItem, Item& aTypeName);
+
     protected:
       store::ItemFactory* theItemFactory;
 


Follow ups