Paul J. Lucas has proposed merging lp:~zorba-coders/zorba/bug-1180633 into 
lp:zorba.

Commit message:
Now using proper types for xs:integer and friends.

Requested reviews:
  Paul J. Lucas (paul-lucas)
Related bugs:
  Bug #1180633 in Zorba: "Add full support for xs:integer derived types, e.g., 
xs:positiveInteger"
  https://bugs.launchpad.net/zorba/+bug/1180633

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1180633/+merge/164242

Now using proper types for xs:integer and friends.
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1180633/+merge/164242
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/store/api/item_factory.h'
--- src/store/api/item_factory.h	2013-03-27 20:01:19 +0000
+++ src/store/api/item_factory.h	2013-05-16 18:29:30 +0000
@@ -320,13 +320,13 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#nonPositiveInteger]
    * @param value
    */
-  virtual bool createNonPositiveInteger(Item_t& result, const xs_integer& value) = 0;
+  virtual bool createNonPositiveInteger(Item_t& result, const xs_nonPositiveInteger& value) = 0;
 
   /**
    * Specification: [http://www.w3.org/TR/xmlschema-2/#negativeInteger]
    * @param value
    */
-  virtual bool createNegativeInteger(Item_t& result, const xs_integer& value) = 0;
+  virtual bool createNegativeInteger(Item_t& result, const xs_negativeInteger& value) = 0;
 
   /**
    * Specification: [http://www.w3.org/TR/xmlschema-2/#long]

=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp	2013-05-09 00:21:51 +0000
+++ src/store/naive/atomic_items.cpp	2013-05-16 18:29:30 +0000
@@ -2691,7 +2691,7 @@
 
 bool DecimalItem::getEBV() const
 {
-  return !!theValue.sign();
+  return !!theValue;
 }
 
 
@@ -2732,379 +2732,140 @@
   class IntegerItemImpl
 ********************************************************************************/
 
-#ifdef ZORBA_WITH_BIG_INTEGER
-size_t IntegerItemImpl::alloc_size() const
-{
-  return IntegerItem::alloc_size() + ztd::alloc_sizeof( theValue );
-}
-#endif /* ZORBA_WITH_BIG_INTEGER */
-
-size_t IntegerItemImpl::dynamic_size() const
-{
-  return sizeof( *this );
-}
-
-
-long IntegerItemImpl::compare(Item const* other, long, const XQPCollator*) const
-{
-  try
-  {
-    return theValue.compare(other->getIntegerValue());
-  }
-  catch (ZorbaException const& )
-  {
-    return getDecimalValue().compare(other->getDecimalValue());
-  }
-}
-
-
-xs_decimal IntegerItemImpl::getDecimalValue() const
-{
-  return xs_decimal(theValue);
-}
-
-
-xs_long IntegerItemImpl::getLongValue() const
-{
-  try
-  {
-    return to_xs_long(theValue);
-  }
-  catch ( std::range_error const& )
-  {
-    RAISE_ERROR_NO_LOC(err::FORG0001,
-    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
-                 getStringValue(),
-                 "xs:integer",
-                 "xs:long"));
-  }
-}
-
-
-xs_unsignedInt IntegerItemImpl::getUnsignedIntValue() const
-{
-  try 
-  {
-    return to_xs_unsignedInt(theValue);
-  }
-  catch ( std::range_error const& ) 
-  {
-    RAISE_ERROR_NO_LOC(err::FORG0001,
-    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
-                 getStringValue(),
-                 "xs:integer",
-                 "xs:unsignedInt"));
-  }
-}
-
-
-store::Item* IntegerItemImpl::getType() const
-{
-  return GET_STORE().theSchemaTypeNames[store::XS_INTEGER];
-}
-
-
-bool IntegerItemImpl::getEBV() const
-{
-  return !!theValue.sign();
-}
-
-
-zstring IntegerItemImpl::getStringValue() const
-{
-  return theValue.toString();
-}
-
-
-void IntegerItemImpl::getStringValue2(zstring& val) const
-{
-  val = theValue.toString();
-}
-
-uint32_t IntegerItemImpl::hash(long, const XQPCollator*) const
-{
-  return theValue.hash();
-}
-
-
-void IntegerItemImpl::appendStringValue(zstring& buf) const
-{
-  buf += theValue.toString();
-}
-
-
-zstring IntegerItemImpl::show() const
-{
-  zstring res("xs:integer(");
-  appendStringValue(res);
-  res += ")";
-  return res;
-}
-
-
-/*******************************************************************************
-  class NonPositiveIntegerItem
-********************************************************************************/
-
-#ifdef ZORBA_WITH_BIG_INTEGER
-size_t NonPositiveIntegerItem::alloc_size() const
-{
-  return IntegerItem::alloc_size() + ztd::alloc_sizeof( theValue );
-}
-#endif /* ZORBA_WITH_BIG_INTEGER */
-
-size_t NonPositiveIntegerItem::dynamic_size() const
-{
-  return sizeof( *this );
-}
-
-
-long NonPositiveIntegerItem::compare(Item const* other, long, const XQPCollator*) const
-{
-  try
-  {
-    return theValue.compare(other->getIntegerValue());
-  }
-  catch (ZorbaException const&)
-  {
-    return getDecimalValue().compare(other->getDecimalValue());
-  }
-}
-
-
-bool NonPositiveIntegerItem::equals(
-    const store::Item* other,
-    long,
-    const XQPCollator* ) const
-{
-  try
-  {
-    return theValue == other->getIntegerValue();
-  }
-  catch (ZorbaException const&)
-  {
-    return getDecimalValue() == other->getDecimalValue();
-  }
-}
-
-
-store::Item* NonPositiveIntegerItem::getType() const
-{
-  return GET_STORE().theSchemaTypeNames[store::XS_NON_POSITIVE_INTEGER];
-}
-
-
-xs_decimal NonPositiveIntegerItem::getDecimalValue() const
-{
-  return xs_decimal(theValue);
-}
-
-
-xs_integer NonPositiveIntegerItem::getIntegerValue() const
-{
-  return xs_integer(theValue);
-}
-
-
-xs_long NonPositiveIntegerItem::getLongValue() const
-{
-  try
-  {
-    return to_xs_long(theValue);
-  }
-  catch ( std::range_error const& )
-  {
-    RAISE_ERROR_NO_LOC(err::FORG0001,
-    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
-                 getStringValue(),
-                 "xs:nonPositiveInteger",
-                 "xs:long"));
-  }
-}
-
-zstring NonPositiveIntegerItem::getStringValue() const
-{
-  return theValue.toString();
-}
-
-
-void NonPositiveIntegerItem::getStringValue2(zstring& val) const
-{
-  val = theValue.toString();
-}
-
-uint32_t NonPositiveIntegerItem::hash(long, const XQPCollator*) const
-{
-  return theValue.hash();
-}
-
-
-void NonPositiveIntegerItem::appendStringValue(zstring& buf) const
-{
-  buf += theValue.toString();
-}
-
-bool NonPositiveIntegerItem::getEBV() const
-{
-  return !!theValue.sign();
-}
-
-zstring NonPositiveIntegerItem::show() const
-{
-  zstring res("xs:nonPositiveInteger(");
-  appendStringValue(res);
-  res += ")";
-  return res;
-}
-
-
-/*******************************************************************************
-  class NegativeIntegerItem
-********************************************************************************/
-store::Item* NegativeIntegerItem::getType() const
-{
-  return GET_STORE().theSchemaTypeNames[store::XS_NEGATIVE_INTEGER];
-}
-
-
-zstring NegativeIntegerItem::show() const
-{
-  zstring res("xs:negativeInteger(");
-  appendStringValue(res);
-  res += ")";
-  return res;
-}
-
-
-/*******************************************************************************
-  class NonNegativeIntegerItem
-********************************************************************************/
-
-#ifdef ZORBA_WITH_BIG_INTEGER
-size_t NonNegativeIntegerItem::alloc_size() const
-{
-  return IntegerItem::alloc_size() + ztd::alloc_sizeof( theValue );
-}
-#endif /* ZORBA_WITH_BIG_INTEGER */
-
-size_t NonNegativeIntegerItem::dynamic_size() const
-{
-  return sizeof( *this );
-}
-
-long NonNegativeIntegerItem::compare( Item const *other, long,
-                                      const XQPCollator* ) const {
-  try
-  {
-    return theValue.compare( other->getUnsignedIntegerValue() );
-  }
-  catch ( ZorbaException const& )
-  {
-    return getDecimalValue().compare( other->getDecimalValue() );
-  }
-}
-
-bool NonNegativeIntegerItem::equals( const store::Item* other, long,
-                                     const XQPCollator* ) const
-{
-  try
-  {
-    return theValue == other->getUnsignedIntegerValue();
-  }
-  catch (ZorbaException const&)
-  {
-    return getDecimalValue() == other->getDecimalValue();
-  }
-}
-
-
-store::Item* NonNegativeIntegerItem::getType() const
-{
-  return GET_STORE().theSchemaTypeNames[store::XS_NON_NEGATIVE_INTEGER];
-}
-
-
-xs_decimal NonNegativeIntegerItem::getDecimalValue() const
-{
-  return xs_decimal(theValue);
-}
-
-
-xs_integer NonNegativeIntegerItem::getIntegerValue() const
-{
-  return xs_integer(theValue);
-}
-
-
-xs_long NonNegativeIntegerItem::getLongValue() const
-{
-  try
-  {
-    return to_xs_long(theValue);
-  }
-  catch (const std::range_error& )
-  {
-    RAISE_ERROR_NO_LOC(err::FORG0001,
-    ERROR_PARAMS(ZED(FORG0001_NoCastTo_234),
-                 getStringValue(),
-                 "xs:nonNegativeInteger",
-                 "xs:long"));
-  }
-}
-
-
-zstring NonNegativeIntegerItem::getStringValue() const
-{
-  return theValue.toString();
-}
-
-
-void NonNegativeIntegerItem::getStringValue2(zstring& val) const
-{
-  val = theValue.toString();
-}
-
-uint32_t NonNegativeIntegerItem::hash(long, const XQPCollator*) const
-{
-  return theValue.hash();
-}
-
-
-void NonNegativeIntegerItem::appendStringValue(zstring& buf) const
-{
-  buf += theValue.toString();
-}
-
-bool NonNegativeIntegerItem::getEBV() const
-{
-  return !!theValue.sign();
-}
-
-zstring NonNegativeIntegerItem::show() const
-{
-  zstring res("xs:nonNegativeInteger(");
-  appendStringValue(res);
-  res += ")";
-  return res;
-}
-
-
-/*******************************************************************************
-  class PositiveIntegerItem
-********************************************************************************/
-store::Item* PositiveIntegerItem::getType() const
-{
-  return GET_STORE().theSchemaTypeNames[store::XS_POSITIVE_INTEGER];
-}
-
-
-zstring PositiveIntegerItem::show() const
-{
-  zstring res("xs:positiveInteger(");
-  appendStringValue(res);
-  res += ")";
-  return res;
-}
+template<class I>
+size_t IntegerItemImpl<I>::alloc_size() const {
+  return AtomicItem::alloc_size() + ztd::alloc_sizeof( theValue );
+}
+
+template<class I>
+size_t IntegerItemImpl<I>::dynamic_size() const {
+  return sizeof( *this );
+}
+
+template<class I>
+void IntegerItemImpl<I>::appendStringValue(zstring& buf) const {
+  buf += ztd::to_string( theValue );
+}
+
+template<class I>
+long IntegerItemImpl<I>::compare( Item const *other, long timezone,
+                                  XQPCollator const* ) const {
+  return theValue.compare( other->getIntegerValue() );
+}
+
+template<class I>
+bool IntegerItemImpl<I>::equals( store::Item const *other, long timezone,
+                         XQPCollator const* ) const {
+  return theValue == other->getIntegerValue();
+}
+
+template<class I>
+xs_decimal IntegerItemImpl<I>::getDecimalValue() const {
+  return xs_decimal( theValue );
+}
+
+template<class I>
+xs_integer IntegerItemImpl<I>::getIntegerValue() const {
+  return xs_integer( theValue );
+}
+
+template<class I>
+bool IntegerItemImpl<I>::getEBV() const {
+  return !!theValue;
+}
+
+template<class I>
+xs_long IntegerItemImpl<I>::getLongValue() const {
+  try {
+    return to_xs_long( theValue );
+  }
+  catch ( std::range_error const& ) {
+    throw XQUERY_EXCEPTION(
+      err::FORG0001,
+      ERROR_PARAMS(
+        ZED( FORG0001_NoCastTo_234 ),
+        getStringValue(),
+        getTypeCode(),
+        "xs:long"
+      )
+    );
+  }
+}
+
+template<class I>
+zstring IntegerItemImpl<I>::getStringValue() const {
+  return ztd::to_string( theValue );
+}
+
+template<class I>
+void IntegerItemImpl<I>::getStringValue2( zstring &val ) const {
+  val = ztd::to_string( theValue );
+}
+
+template<class I>
+store::Item* IntegerItemImpl<I>::getType() const {
+  return GET_STORE().theSchemaTypeNames[ getTypeCode() ];
+}
+
+template<class I>
+xs_nonNegativeInteger IntegerItemImpl<I>::getUnsignedIntegerValue() const {
+  try {
+    return xs_nonNegativeInteger( theValue );
+  }
+  catch ( std::exception const& ) {
+    throw XQUERY_EXCEPTION(
+      err::FORG0001,
+      ERROR_PARAMS(
+        ZED( FORG0001_NoCastTo_234 ),
+        getStringValue(),
+        getTypeCode(),
+        "xs:long"
+      )
+    );
+  }
+}
+
+template<class I>
+xs_unsignedInt IntegerItemImpl<I>::getUnsignedIntValue() const {
+  try {
+    return to_xs_unsignedInt( theValue );
+  }
+  catch ( std::range_error const& ) {
+    throw XQUERY_EXCEPTION(
+      err::FORG0001,
+      ERROR_PARAMS(
+        ZED( FORG0001_NoCastTo_234 ),
+        getStringValue(),
+        getTypeCode(),
+        "xs:unsignedInt"
+      )
+    );
+  }
+}
+
+template<class I>
+uint32_t IntegerItemImpl<I>::hash( long timezone, XQPCollator const* ) const {
+  return theValue.hash();
+}
+
+template<class I>
+bool IntegerItemImpl<I>::isNaN() const {
+  return theValue != theValue;
+}
+
+template<class I>
+zstring IntegerItemImpl<I>::show() const {
+  ostringstream oss;
+  oss << getTypeCode() << '(' << getStringValue() << ')';
+  return oss.str();
+}
+
+// instantiate
+template class IntegerItemImpl<xs_integer>;
+template class IntegerItemImpl<xs_negativeInteger>;
+template class IntegerItemImpl<xs_nonNegativeInteger>;
+template class IntegerItemImpl<xs_nonPositiveInteger>;
+template class IntegerItemImpl<xs_positiveInteger>;
 
 
 /*******************************************************************************
@@ -3417,7 +3178,7 @@
 
 xs_integer UnsignedIntItem::getIntegerValue() const
 {
-  return Integer(theValue);
+  return xs_integer(theValue);
 }
 
 

=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h	2013-05-15 23:22:01 +0000
+++ src/store/naive/atomic_items.h	2013-05-16 18:29:30 +0000
@@ -1503,252 +1503,58 @@
 };
 
 
-/*******************************************************************************
-  class IntegerItem
-********************************************************************************/
-class IntegerItem : public AtomicItem
-{
-protected:
-  IntegerItem(store::SchemaTypeCode t) : AtomicItem(t) {}
-
-public:
-  virtual xs_decimal getDecimalValue() const = 0;
-
-  virtual xs_integer getIntegerValue() const = 0;
-
-  virtual xs_long getLongValue() const = 0;
-
-  bool isNaN() const { return false; }
-};
-
-
-/*******************************************************************************
-  class IntegerItemImpl
-********************************************************************************/
-class IntegerItemImpl : public IntegerItem
-{
+///////////////////////////////////////////////////////////////////////////////
+
+template<class ValueType>
+class IntegerItemImpl : public AtomicItem {
   friend class BasicItemFactory;
+  friend class IndexConditionImpl;
   friend class AtomicItem;
 
 protected:
-  xs_integer theValue;
+  typedef ValueType value_type;
+  value_type theValue;
 
 protected:
-  IntegerItemImpl(store::SchemaTypeCode t, const xs_integer& v)
-    :
-    IntegerItem(t),
-    theValue(v)
+  IntegerItemImpl( store::SchemaTypeCode t, value_type const &v ) :
+    AtomicItem( t ),
+    theValue( v )
   {
   }
 
-  IntegerItemImpl(store::SchemaTypeCode t) : IntegerItem(t) {}
+  IntegerItemImpl( store::SchemaTypeCode t ) : AtomicItem( t ) { }
 
 public:
-#ifdef ZORBA_WITH_BIG_INTEGER
   size_t alloc_size() const;
-#endif /* ZORBA_WITH_BIG_INTEGER */
   size_t dynamic_size() const;
 
+  void appendStringValue( zstring &buf ) const;
   xs_decimal getDecimalValue() const;
-
-  xs_integer getIntegerValue() const { return theValue; }
-
-  xs_long getLongValue() const; 
-
+  xs_integer getIntegerValue() const;
+  xs_long getLongValue() const;
+  store::Item* getType() const;
+  xs_nonNegativeInteger getUnsignedIntegerValue() const;
   xs_unsignedInt getUnsignedIntValue() const;
 
-  xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; }
-
-  zstring getStringValue() const;
-
-  void getStringValue2(zstring&) const;
-
-  void appendStringValue(zstring&) const;
-
-  store::Item* getType() const;
-
-  uint32_t hash(long = 0, const XQPCollator* c = 0) const;
-
-  long compare(const Item* other, long tz = 0, const XQPCollator* c = 0) const;
-
-  bool equals(const Item* other, long tz = 0, const XQPCollator* c = 0) const
-  {
-    try
-    {
-      return theValue == other->getIntegerValue();
-    }
-    catch (ZorbaException const&)
-    {
-      return getDecimalValue() == other->getDecimalValue();
-    }
-  }
-
-  bool getEBV() const;
-
-  zstring show() const;
-};
-
-
-/*******************************************************************************
-  class NonPositiveIntegerItem
-********************************************************************************/
-class NonPositiveIntegerItem : public IntegerItem
-{
-  friend class BasicItemFactory;
-
-protected:
-  xs_nonPositiveInteger theValue;
-
-  NonPositiveIntegerItem(store::SchemaTypeCode t, const xs_integer& v)
-    :
-    IntegerItem(t),
-    theValue(v)
-  {
-  }
-
-  NonPositiveIntegerItem(store::SchemaTypeCode t) : IntegerItem(t) {}
-
-public:
-#ifdef ZORBA_WITH_BIG_INTEGER
-  size_t alloc_size() const;
-#endif /* ZORBA_WITH_BIG_INTEGER */
-  size_t dynamic_size() const;
-
-  xs_decimal getDecimalValue() const;
-
-  xs_integer getIntegerValue() const;
-
-  xs_long getLongValue() const;
-
-  zstring getStringValue() const;
-
-  void getStringValue2(zstring& val) const;
-
-  void appendStringValue(zstring&) const;
-
-  virtual store::Item* getType() const;
-
-  uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;
-
-  long compare(
-        const Item* other,
-        long timezone = 0,
-        const XQPCollator* aCollation = 0) const;
-
-  bool equals(
-        const store::Item* other,
-        long timezone = 0,
-        const XQPCollator* aCollation = 0) const;
-
-  bool getEBV() const;
-
-  virtual zstring show() const;
-};
-
-
-/*******************************************************************************
-  class NegativeIntegerItem
-********************************************************************************/
-class NegativeIntegerItem : public NonPositiveIntegerItem
-{
-  friend class BasicItemFactory;
-
-protected:
-  NegativeIntegerItem(store::SchemaTypeCode t, const xs_integer& v)
-    :
-    NonPositiveIntegerItem(t, v)
-  {
-  }
-
-  NegativeIntegerItem(store::SchemaTypeCode t) : NonPositiveIntegerItem(t) {}
-
-public:
-  store::Item* getType() const;
-
-  zstring show() const;
-};
-
-
-/*******************************************************************************
-  class NonNegativeIntegerItem
-********************************************************************************/
-class NonNegativeIntegerItem : public IntegerItem
-{
-  friend class BasicItemFactory;
-
-protected:
-  xs_nonNegativeInteger theValue;
-
-  NonNegativeIntegerItem(store::SchemaTypeCode t, const xs_nonNegativeInteger& v)
-    :
-    IntegerItem(t),
-    theValue(v)
-  {
-  }
-
-  NonNegativeIntegerItem(store::SchemaTypeCode t) : IntegerItem(t) {}
-
-public:
-#ifdef ZORBA_WITH_BIG_INTEGER
-  size_t alloc_size() const;
-#endif /* ZORBA_WITH_BIG_INTEGER */
-  size_t dynamic_size() const;
-
-  xs_decimal getDecimalValue() const;
-
-  xs_integer getIntegerValue() const;
-
-  xs_long getLongValue() const;
-
-  xs_nonNegativeInteger getUnsignedIntegerValue() const { return theValue; }
-
-  zstring getStringValue() const;
-
-  void getStringValue2(zstring& val) const;
-
-  void appendStringValue(zstring&) const;
-
-  virtual store::Item* getType() const;
-
-  uint32_t hash(long = 0, const XQPCollator* aCollation = 0) const;
-
-  long compare(
-        const Item* other,
-        long timezone = 0,
-        const XQPCollator* aCollation = 0) const;
-
-  bool equals(
-        const store::Item* other,
-        long timezone = 0,
-        const XQPCollator* aCollation = 0) const;
-
-  bool getEBV() const;
-
-  virtual zstring show() const;
-};
-
-
-/*******************************************************************************
-  class PositiveIntegerItem
-********************************************************************************/
-class PositiveIntegerItem : public  NonNegativeIntegerItem
-{
-  friend class BasicItemFactory;
-
-protected:
-  PositiveIntegerItem(store::SchemaTypeCode t, const xs_positiveInteger& v) 
-    :
-    NonNegativeIntegerItem(t, v)
-  {
-  }
-
-  PositiveIntegerItem(store::SchemaTypeCode t) : NonNegativeIntegerItem(t) {}
-
-public:
-  store::Item* getType() const;
-
-  zstring show() const;
-};
+  long compare( const Item* other, long timezone = 0,
+                const XQPCollator* aCollation = 0) const;
+
+  bool equals( const store::Item* other, long timezone = 0,
+               const XQPCollator* aCollation = 0) const;
+
+  bool getEBV() const;
+  zstring getStringValue() const;
+  void getStringValue2(zstring& val) const;
+  uint32_t hash(long timezone = 0, const XQPCollator* aCollation = 0) const;
+  bool isNaN() const;
+  zstring show() const;
+};
+
+typedef IntegerItemImpl<xs_integer>             IntegerItem;
+typedef IntegerItemImpl<xs_negativeInteger>     NegativeIntegerItem;
+typedef IntegerItemImpl<xs_nonNegativeInteger>  NonNegativeIntegerItem;
+typedef IntegerItemImpl<xs_nonPositiveInteger>  NonPositiveIntegerItem;
+typedef IntegerItemImpl<xs_positiveInteger>     PositiveIntegerItem;
 
 
 /*******************************************************************************

=== modified file 'src/store/naive/simple_item_factory.cpp'
--- src/store/naive/simple_item_factory.cpp	2013-05-08 01:05:04 +0000
+++ src/store/naive/simple_item_factory.cpp	2013-05-16 18:29:30 +0000
@@ -343,14 +343,14 @@
 
 bool BasicItemFactory::createInteger(store::Item_t& result, const xs_integer& value)
 {
-  result = new IntegerItemImpl(store::XS_INTEGER, value);
+  result = new IntegerItem(store::XS_INTEGER, value);
   return true;
 }
 
 
 bool BasicItemFactory::createNonPositiveInteger(
     store::Item_t& result,
-    const xs_integer& value)
+    const xs_nonPositiveInteger& value)
 {
   ZORBA_ASSERT(value.sign() <= 0);
   result = new NonPositiveIntegerItem(store::XS_NON_POSITIVE_INTEGER, value);
@@ -360,7 +360,7 @@
 
 bool BasicItemFactory::createNegativeInteger(
     store::Item_t& result,
-    const xs_integer& value)
+    const xs_negativeInteger& value)
 {
   ZORBA_ASSERT(value.sign() < 0);
   result = new NegativeIntegerItem(store::XS_NEGATIVE_INTEGER, value);

=== modified file 'src/store/naive/simple_item_factory.h'
--- src/store/naive/simple_item_factory.h	2013-03-16 20:44:27 +0000
+++ src/store/naive/simple_item_factory.h	2013-05-16 18:29:30 +0000
@@ -158,9 +158,9 @@
 
   bool createPositiveInteger(store::Item_t& result,  const xs_positiveInteger& value );
 
-  bool createNonPositiveInteger(store::Item_t& result, const xs_integer& value);
+  bool createNonPositiveInteger(store::Item_t& result, const xs_nonPositiveInteger& value);
 
-  bool createNegativeInteger(store::Item_t& result,  const xs_integer& value);
+  bool createNegativeInteger(store::Item_t& result,  const xs_negativeInteger& value);
 
   bool createLong(store::Item_t& result, xs_long value);
 

=== modified file 'src/zorbatypes/decimal.h'
--- src/zorbatypes/decimal.h	2013-05-01 15:36:17 +0000
+++ src/zorbatypes/decimal.h	2013-05-16 18:29:30 +0000
@@ -19,6 +19,7 @@
 #define ZORBA_DECIMAL_H
 
 #include <zorba/config.h>
+#include <zorba/internal/ztd.h>
 
 #include "common/common.h"
 #include "util/stl_util.h"
@@ -41,11 +42,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-class Decimal
-{
-
-  friend void serialization::operator&(serialization::Archiver& ar, Decimal& obj);
-
+class Decimal {
+  typedef internal::ztd::explicit_bool explicit_bool;
 public:
 
   ////////// constructors /////////////////////////////////////////////////////
@@ -212,6 +210,7 @@
   uint32_t hash() const;
 
   int sign() const;
+  operator explicit_bool::type() const;
 
   zstring toString( int precision = ZORBA_FLOAT_POINT_PRECISION ) const;
 
@@ -255,6 +254,7 @@
   template<typename F> friend class FloatImpl;
 
   friend xs_long to_xs_long( Decimal const& );
+  friend void serialization::operator&( serialization::Archiver&, Decimal& );
 };
 
 ////////// constructors ///////////////////////////////////////////////////////
@@ -408,6 +408,10 @@
   return value_.sign();
 }
 
+inline Decimal::operator Decimal::explicit_bool::type() const {
+  return explicit_bool::value_of( sign() );
+}
+
 inline zstring Decimal::toString( int precision ) const {
   return toString( value_, precision );
 }

=== modified file 'src/zorbatypes/integer.h'
--- src/zorbatypes/integer.h	2013-05-14 03:55:56 +0000
+++ src/zorbatypes/integer.h	2013-05-16 18:29:30 +0000
@@ -25,6 +25,7 @@
 
 // Zorba
 #include <zorba/config.h>
+#include <zorba/internal/ztd.h>
 #include "common/common.h"
 #include "util/stl_util.h"
 #include "util/string_util.h"
@@ -140,6 +141,7 @@
 
 template<class TraitsType>
 class IntegerImpl {
+  typedef internal::ztd::explicit_bool explicit_bool;
 public:
 #ifdef ZORBA_WITH_BIG_INTEGER
   typedef MAPM value_type;
@@ -541,6 +543,7 @@
   bool is_xs_unsignedLong() const;
   bool is_xs_unsignedShort() const;
   int sign() const;
+  operator explicit_bool::type() const;
   zstring toString() const;
   value_type& value();
   value_type const& value() const;
@@ -1211,12 +1214,17 @@
 
 template<class T>
 inline int IntegerImpl<T>::sign() const {
-  return ztd::lt0( value_ ) ? -1 : value_ > 0 ? 1 : 0;
+  return value_ > 0 ? 1 : value_ < 0 ? -1 : 0;
 }
 
 #endif /* ZORBA_WITH_BIG_INTEGER */
 
 template<class T>
+inline IntegerImpl<T>::operator IntegerImpl<T>::explicit_bool::type() const {
+  return explicit_bool::value_of( sign() );
+}
+
+template<class T>
 inline typename IntegerImpl<T>::value_type& IntegerImpl<T>::value() {
   return value_;
 }

-- 
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