Merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Matthias Brantner
Approved revision: 11048
Merged at revision: 11202
Proposed branch: lp:~paul-lucas/zorba/pjl-misc
Merge into: lp:zorba
Diff against target: 84 lines (+38/-5)
1 file modified
include/zorba/internal/ztd.h (+38/-5)
To merge this branch: bzr merge lp:~paul-lucas/zorba/pjl-misc
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+145037@code.launchpad.net

Commit message

Fixed to_string() for char* type.

Description of the change

Fixed to_string() for char* type.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

The attempt to merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job pjl-misc-2013-01-25T22-49-47.678Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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

The attempt to merge lp:~paul-lucas/zorba/pjl-misc into lp:zorba failed. Below is the output from the failed tests.

CMake Error at /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake:275 (message):
  Validation queue job pjl-misc-2013-01-26T01-31-45.923Z is finished. The
  final status was:

  1 tests did not succeed - changes not commited.

Error in read script: /home/ceej/zo/testing/zorbatest/tester/TarmacLander.cmake

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 pjl-misc-2013-01-26T16-39-50.663Z 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.

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 pjl-misc-2013-01-28T22-08-14.979Z 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 'include/zorba/internal/ztd.h'
2--- include/zorba/internal/ztd.h 2012-12-08 00:09:48 +0000
3+++ include/zorba/internal/ztd.h 2013-01-26 16:33:24 +0000
4@@ -260,16 +260,35 @@
5
6 /**
7 * \internal
8+ * Tests whether a given type \a T is a C string type.
9+ *
10+ * @tparam T The type to check.
11+ */
12+template<typename T>
13+class is_c_string {
14+ typedef typename ZORBA_TR1_NS::remove_pointer<T>::type T_base;
15+ typedef typename ZORBA_TR1_NS::add_const<T_base>::type T_base_const;
16+public:
17+ static bool const value =
18+ ZORBA_TR1_NS::is_same<T_base_const*,char const*>::value
19+ || ZORBA_TR1_NS::is_same<T_base_const*,unsigned char const*>::value
20+ || ZORBA_TR1_NS::is_same<T_base_const*,signed char const*>::value;
21+};
22+
23+/**
24+ * \internal
25 * Converts an object to its string representation.
26 *
27 * @tparam T The object type that:
28+ * - is not an array
29 * - is not a pointer
30 * - has an <code>ostream& operator&lt;&lt;(ostream&,T const&)</code> defined
31 * @param t The object.
32 * @return Returns a string representation of the object.
33 */
34 template<typename T> inline
35-typename std::enable_if<!ZORBA_TR1_NS::is_pointer<T>::value
36+typename std::enable_if<!ZORBA_TR1_NS::is_array<T>::value
37+ && !ZORBA_TR1_NS::is_pointer<T>::value
38 && has_insertion_operator<T>::value,
39 std::string>::type
40 to_string( T const &t ) {
41@@ -345,7 +364,7 @@
42
43 /**
44 * \internal
45- * Specialization of \c to_string() for pointer types.
46+ * Specialization of \c to_string() for pointer types other than C strings.
47 *
48 * @tparam T The pointer type.
49 * @param p The pointer.
50@@ -353,10 +372,13 @@
51 * otherwise returns \c "<null>".
52 */
53 template<typename T> inline
54-typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value,std::string>::type
55+typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value
56+ && !is_c_string<T>::value,
57+ std::string>::type
58 to_string( T p ) {
59- typedef typename ZORBA_TR1_NS::remove_pointer<T>::type const* T_const_ptr;
60- return p ? to_string( *static_cast<T_const_ptr>( p ) ) : "<null>";
61+ typedef typename ZORBA_TR1_NS::remove_pointer<T>::type T_base;
62+ typedef typename ZORBA_TR1_NS::add_const<T_base>::type T_base_const;
63+ return p ? to_string( *static_cast<T_base_const*>( p ) ) : "<null>";
64 }
65
66 /**
67@@ -370,6 +392,17 @@
68 return s ? s : "<null>";
69 }
70
71+/**
72+ * \internal
73+ * Specialization of \c to_string() for C strings.
74+ *
75+ * @param s The C string.
76+ * @return Returns a string representation of the object.
77+ */
78+inline std::string to_string( unsigned char const *s ) {
79+ return s ? reinterpret_cast<char const*>( s ) : "<null>";
80+}
81+
82 ////////// misc ///////////////////////////////////////////////////////////////
83
84 /**

Subscribers

People subscribed via source and target branches