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
=== modified file 'include/zorba/internal/ztd.h'
--- include/zorba/internal/ztd.h 2012-12-08 00:09:48 +0000
+++ include/zorba/internal/ztd.h 2013-01-26 16:33:24 +0000
@@ -260,16 +260,35 @@
260260
261/**261/**
262 * \internal262 * \internal
263 * Tests whether a given type \a T is a C string type.
264 *
265 * @tparam T The type to check.
266 */
267template<typename T>
268class is_c_string {
269 typedef typename ZORBA_TR1_NS::remove_pointer<T>::type T_base;
270 typedef typename ZORBA_TR1_NS::add_const<T_base>::type T_base_const;
271public:
272 static bool const value =
273 ZORBA_TR1_NS::is_same<T_base_const*,char const*>::value
274 || ZORBA_TR1_NS::is_same<T_base_const*,unsigned char const*>::value
275 || ZORBA_TR1_NS::is_same<T_base_const*,signed char const*>::value;
276};
277
278/**
279 * \internal
263 * Converts an object to its string representation.280 * Converts an object to its string representation.
264 *281 *
265 * @tparam T The object type that:282 * @tparam T The object type that:
283 * - is not an array
266 * - is not a pointer284 * - is not a pointer
267 * - has an <code>ostream& operator&lt;&lt;(ostream&,T const&)</code> defined285 * - has an <code>ostream& operator&lt;&lt;(ostream&,T const&)</code> defined
268 * @param t The object.286 * @param t The object.
269 * @return Returns a string representation of the object.287 * @return Returns a string representation of the object.
270 */288 */
271template<typename T> inline289template<typename T> inline
272typename std::enable_if<!ZORBA_TR1_NS::is_pointer<T>::value290typename std::enable_if<!ZORBA_TR1_NS::is_array<T>::value
291 && !ZORBA_TR1_NS::is_pointer<T>::value
273 && has_insertion_operator<T>::value,292 && has_insertion_operator<T>::value,
274 std::string>::type293 std::string>::type
275to_string( T const &t ) {294to_string( T const &t ) {
@@ -345,7 +364,7 @@
345364
346/**365/**
347 * \internal366 * \internal
348 * Specialization of \c to_string() for pointer types.367 * Specialization of \c to_string() for pointer types other than C strings.
349 *368 *
350 * @tparam T The pointer type.369 * @tparam T The pointer type.
351 * @param p The pointer.370 * @param p The pointer.
@@ -353,10 +372,13 @@
353 * otherwise returns \c "<null>".372 * otherwise returns \c "<null>".
354 */373 */
355template<typename T> inline374template<typename T> inline
356typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value,std::string>::type375typename std::enable_if<ZORBA_TR1_NS::is_pointer<T>::value
376 && !is_c_string<T>::value,
377 std::string>::type
357to_string( T p ) {378to_string( T p ) {
358 typedef typename ZORBA_TR1_NS::remove_pointer<T>::type const* T_const_ptr;379 typedef typename ZORBA_TR1_NS::remove_pointer<T>::type T_base;
359 return p ? to_string( *static_cast<T_const_ptr>( p ) ) : "<null>";380 typedef typename ZORBA_TR1_NS::add_const<T_base>::type T_base_const;
381 return p ? to_string( *static_cast<T_base_const*>( p ) ) : "<null>";
360}382}
361383
362/**384/**
@@ -370,6 +392,17 @@
370 return s ? s : "<null>";392 return s ? s : "<null>";
371}393}
372394
395/**
396 * \internal
397 * Specialization of \c to_string() for C strings.
398 *
399 * @param s The C string.
400 * @return Returns a string representation of the object.
401 */
402inline std::string to_string( unsigned char const *s ) {
403 return s ? reinterpret_cast<char const*>( s ) : "<null>";
404}
405
373////////// misc ///////////////////////////////////////////////////////////////406////////// misc ///////////////////////////////////////////////////////////////
374407
375/**408/**

Subscribers

People subscribed via source and target branches