summaryrefslogtreecommitdiffstats
path: root/addon/doxmlparser/src/stringimpl.h
blob: 8931b4231af810f70ea29620fc1f0771de554e35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef STRINGIMPL_H
#define STRINGIMPL_H

#include <qstring.h>
#include "doxmlintf.h"

class StringImpl : public IString
{
  public:
    StringImpl() {}
    StringImpl(const QString &str) : m_str(str) {}
    StringImpl &operator=(const QString &str) 
    { m_str=str; return *this; }
    virtual ~StringImpl() {}
    const char *data() const 
    { return m_str.data(); }

    // IString 
    const char *latin1() const 
    { return m_str.latin1(); }
    const char *utf8() const 
    { m_cstr = m_str.utf8(); return m_cstr.data(); }
    unsigned short unicodeCharAt(int index) const 
    { return m_str.unicode()[index].unicode(); } 
    bool isEmpty() const 
    { return m_str.isEmpty(); }
    int length() const 
    { return m_str.length(); }

    operator QString() const { return m_str; }

  private:
    QString m_str;
    mutable QCString m_cstr; // used as a cache for m_str.utf8() to avoid returning a temporary
};

#endif