Merge lp:~zorba-coders/zorba/more-numconversions into lp:zorba

Proposed by Till Westmann
Status: Merged
Approved by: Matthias Brantner
Approved revision: 11118
Merged at revision: 11121
Proposed branch: lp:~zorba-coders/zorba/more-numconversions
Merge into: lp:zorba
Diff against target: 76 lines (+44/-0)
3 files modified
src/zorbatypes/integer.h (+2/-0)
src/zorbatypes/numconversions.cpp (+22/-0)
src/zorbatypes/numconversions.h (+20/-0)
To merge this branch: bzr merge lp:~zorba-coders/zorba/more-numconversions
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Till Westmann Approve
Review via email: mp+132208@code.launchpad.net

Commit message

add to_xs_unsignedByte and to_xs_unsignedShort

Description of the change

add to_xs_unsignedByte and to_xs_unsignedShort

To post a comment you must log in.
Revision history for this message
Till Westmann (tillw) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job more-numconversions-2012-10-30T21-31-41.316Z is finished. The final status was:

All tests succeeded!

Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Voting does not meet specified criteria. Required: Approve > 1, Disapprove < 1, Needs Fixing < 1, Pending < 1. Got: 1 Approve, 1 Pending.

Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job more-numconversions-2012-11-02T01-31-02.32Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/zorbatypes/integer.h'
2--- src/zorbatypes/integer.h 2012-09-19 21:16:15 +0000
3+++ src/zorbatypes/integer.h 2012-10-30 21:29:21 +0000
4@@ -524,6 +524,8 @@
5
6 friend xs_int to_xs_int( INTEGER_IMPL_LL const& );
7 friend xs_long to_xs_long( INTEGER_IMPL_LL const& );
8+ friend xs_unsignedByte to_xs_unsignedByte( INTEGER_IMPL_LL const& );
9+ friend xs_unsignedShort to_xs_unsignedShort( INTEGER_IMPL_LL const& );
10 friend xs_unsignedInt to_xs_unsignedInt( INTEGER_IMPL_LL const& );
11 friend xs_unsignedLong to_xs_unsignedLong( INTEGER_IMPL_LL const& );
12
13
14=== modified file 'src/zorbatypes/numconversions.cpp'
15--- src/zorbatypes/numconversions.cpp 2012-09-19 21:16:15 +0000
16+++ src/zorbatypes/numconversions.cpp 2012-10-30 21:29:21 +0000
17@@ -70,6 +70,28 @@
18 }
19 #endif /* ZORBA_WITH_BIG_INTEGER */
20
21+xs_unsignedByte to_xs_unsignedByte( xs_integer const &i ) {
22+#ifdef ZORBA_WITH_BIG_INTEGER
23+ zstring const temp( i.toString() );
24+ return ztd::aton<xs_unsignedByte>( temp.c_str() );
25+#else
26+ if ( i.is_xs_unsignedByte() )
27+ return static_cast<xs_unsignedByte>( i.value_ );
28+ throw RANGE_ERROR( i, "xs:unsignedByte" );
29+#endif /* ZORBA_WITH_BIG_INTEGER */
30+}
31+
32+xs_unsignedShort to_xs_unsignedShort( xs_integer const &i ) {
33+#ifdef ZORBA_WITH_BIG_INTEGER
34+ zstring const temp( i.toString() );
35+ return ztd::aton<xs_unsignedShort>( temp.c_str() );
36+#else
37+ if ( i.is_xs_unsignedShort() )
38+ return static_cast<xs_unsignedShort>( i.value_ );
39+ throw RANGE_ERROR( i, "xs:unsignedShort" );
40+#endif /* ZORBA_WITH_BIG_INTEGER */
41+}
42+
43 xs_unsignedInt to_xs_unsignedInt( xs_integer const &i ) {
44 #ifdef ZORBA_WITH_BIG_INTEGER
45 zstring const temp( i.toString() );
46
47=== modified file 'src/zorbatypes/numconversions.h'
48--- src/zorbatypes/numconversions.h 2012-09-19 21:16:15 +0000
49+++ src/zorbatypes/numconversions.h 2012-10-30 21:29:21 +0000
50@@ -69,6 +69,26 @@
51 #endif /* ZORBA_WITH_BIG_INTEGER */
52
53 /**
54+ * Converts an \c xs:integer value to an \c xs:unsignedByte.
55+ *
56+ * @param i The \c xs:integer value to convert.
57+ * @return Returns said value.
58+ * @throws std::range_error if the \c xs:integer value can not be accurately
59+ * represented as an \c xs:unsignedByte.
60+ */
61+xs_unsignedByte to_xs_unsignedByte( xs_integer const &i );
62+
63+/**
64+ * Converts an \c xs:integer value to an \c xs:unsignedShort.
65+ *
66+ * @param i The \c xs:integer value to convert.
67+ * @return Returns said value.
68+ * @throws std::range_error if the \c xs:integer value can not be accurately
69+ * represented as an \c xs:unsignedShort.
70+ */
71+xs_unsignedShort to_xs_unsignedShort( xs_integer const &i );
72+
73+/**
74 * Converts an \c xs:integer value to an \c xs:unsignedInt.
75 *
76 * @param i The \c xs:integer value to convert.

Subscribers

People subscribed via source and target branches