Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / IdString.h
index 407a113..fc435d6 100644 (file)
@@ -15,6 +15,8 @@
 #include <iosfwd>
 #include <string>
 
+#include <boost/utility/string_ref_fwd.hpp>
+
 #include "zypp/sat/detail/PoolMember.h"
 
 ///////////////////////////////////////////////////////////////////
@@ -22,7 +24,7 @@ namespace zypp
 { /////////////////////////////////////////////////////////////////
 
   class IdString;
-  typedef std::tr1::unordered_set<IdString> IdStringSet;
+  typedef std::unordered_set<IdString> IdStringSet;
 
   ///////////////////////////////////////////////////////////////////
   //
@@ -43,17 +45,23 @@ namespace zypp
 
     public:
       /** Default ctor, empty string. */
-      IdString() : _id( sat::detail::emptyId ) {}
+      constexpr IdString() : _id( sat::detail::emptyId ) {}
 
       /** Ctor from id. */
-      explicit IdString( IdType id_r ) : _id( id_r ) {}
+      constexpr explicit IdString( IdType id_r ) : _id( id_r ) {}
 
       /** Ctor from string. */
       explicit IdString( const char * str_r );
 
+      /** Ctor from string (pointer,length). */
+      IdString( const char * str_r, unsigned len_r );
+
       /** Ctor from string. */
       explicit IdString( const std::string & str_r );
 
+      /** Ctor from boost::string_ref. */
+      explicit IdString( boost::string_ref str_r );
+
     public:
       /** No or Null string ( Id \c 0 ). */
       static const IdString Null;
@@ -63,13 +71,13 @@ namespace zypp
 
     public:
       /** Evaluate in a boolean context <tt>( != \c Null )</tt>. */
-      explicit operator bool() const
+      constexpr explicit operator bool() const
       { return _id; }
 
       /** Whether the string is empty.
        * This is true for \ref Null and \ref Empty.
        */
-      bool empty() const
+      constexpr bool empty() const
       { return( _id == sat::detail::emptyId || _id == sat::detail::noId ); }
 
       /** The strings size. */
@@ -83,6 +91,10 @@ namespace zypp
       std::string asString() const
       { return c_str(); }
 
+      /** Explicit conversion to std::string */
+      explicit operator std::string() const
+      { return asString(); }
+
     public:
       /** Fast compare equal. */
       bool compareEQ( const IdString & rhs ) const