Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-04-04 01:26:37

0001 #ifndef FWCore_Utilities_OftenEmptyCString_h
0002 #define FWCore_Utilities_OftenEmptyCString_h
0003 
0004 /* Class is optimized to not require any additional memory
0005 if the string passes is empty. A nullptr will be replaced with
0006 the empty string as well.
0007 */
0008 
0009 namespace edm {
0010   class OftenEmptyCString {
0011   public:
0012     OftenEmptyCString() : m_value(emptyString()) {}
0013     ~OftenEmptyCString();
0014     explicit OftenEmptyCString(const char*);
0015     OftenEmptyCString(OftenEmptyCString const&);
0016     OftenEmptyCString(OftenEmptyCString&&) noexcept;
0017     OftenEmptyCString& operator=(OftenEmptyCString const&);
0018     OftenEmptyCString& operator=(OftenEmptyCString&&) noexcept;
0019 
0020     const char* c_str() const noexcept { return m_value; }
0021 
0022   private:
0023     static const char* emptyString();
0024     void deleteIfNotEmpty();
0025     char const* m_value;
0026   };
0027 }  // namespace edm
0028 
0029 #endif