VirtualBox

Changeset 19530 in vbox for trunk/include


Ignore:
Timestamp:
May 8, 2009 2:39:23 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
47074
Message:

Main: decouple xml classes from COM dependencies (part 2)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/xml.h

    r19520 r19530  
    5454#endif
    5555
    56 #include "VBox/com/string.h"
    57 
    5856/*
    5957 * Shut up MSVC complaining that auto_ptr[_ref] template instantiations (as a
     
    9290{
    9391
     92// Little string class for XML only
     93//////////////////////////////////////////////////////////////////////////////
     94
     95class ministring
     96{
     97public:
     98    ministring()
     99        : m_psz(NULL)
     100    {
     101    }
     102
     103    ministring(const ministring &s)
     104        : m_psz(NULL)
     105    {
     106        copyFrom(s.c_str());
     107    }
     108
     109    ministring(const char *pcsz)
     110        : m_psz(NULL)
     111    {
     112        copyFrom(pcsz);
     113    }
     114
     115    ~ministring()
     116    {
     117        cleanup();
     118    }
     119
     120    void operator=(const char *pcsz)
     121    {
     122        cleanup();
     123        copyFrom(pcsz);
     124    }
     125
     126    void operator=(const ministring &s)
     127    {
     128        cleanup();
     129        copyFrom(s.c_str());
     130    }
     131
     132    const char* c_str() const
     133    {
     134        return m_psz;
     135    }
     136
     137private:
     138    void cleanup()
     139    {
     140        if (m_psz)
     141        {
     142            RTStrFree(m_psz);
     143            m_psz = NULL;
     144        }
     145    }
     146
     147    void copyFrom(const char *pcsz)
     148    {
     149        if (pcsz)
     150            m_psz = RTStrDup(pcsz);
     151    }
     152
     153
     154    char *m_psz;
     155};
     156
    94157// Exceptions
    95158//////////////////////////////////////////////////////////////////////////////
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette