~ubuntu-branches/ubuntu/intrepid/gnunet/intrepid

« back to all changes in this revision

Viewing changes to src/setup/qt/gstring.cc

  • Committer: Bazaar Package Importer
  • Author(s): Stephan Hermann
  • Date: 2008-01-31 17:40:18 UTC
  • mfrom: (1.2.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20080131174018-sfnbb8wv7p4nmut1
Tags: 0.7.3-2ubuntu1
* Merge from debian unstable, remaining changes:
  - debian/rules:
    = Make use of code from cdbs' clean-la.mk file to clear the
      dependency_libs field in all .la files in the gnunet-dev package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
     This file is part of GNUnet.
 
3
     (C) 2007 Christian Grothoff (and other contributing authors)
 
4
 
 
5
     GNUnet is free software; you can redistribute it and/or modify
 
6
     it under the terms of the GNU General Public License as published
 
7
     by the Free Software Foundation; either version 2, or (at your
 
8
     option) any later version.
 
9
 
 
10
     GNUnet is distributed in the hope that it will be useful, but
 
11
     WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
     General Public License for more details.
 
14
 
 
15
     You should have received a copy of the GNU General Public License
 
16
     along with GNUnet; see the file COPYING.  If not, write to the
 
17
     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
18
     Boston, MA 02111-1307, USA.
 
19
*/
 
20
/**
 
21
 * @file src/setup/qt/gstring.cc
 
22
 * @brief Extended QString
 
23
 * @author Nils Durner
 
24
 */
 
25
 
 
26
#include <QtCore/QByteArray>
 
27
 
 
28
#include "gstring.h"
 
29
 
 
30
GString::GString(const char *str) : QString(str)
 
31
{
 
32
  cstr = NULL;
 
33
}
 
34
 
 
35
GString::GString() : QString()
 
36
{
 
37
  cstr = NULL;
 
38
}
 
39
 
 
40
GString::~GString()
 
41
{
 
42
  if (cstr)
 
43
    ::free(cstr);
 
44
}
 
45
 
 
46
GString &GString::operator=(const QString &src)
 
47
{
 
48
  if (cstr)
 
49
  {
 
50
    ::free(cstr);
 
51
    cstr = NULL;
 
52
  }
 
53
 
 
54
  QString::operator=(src);
 
55
  return *this;
 
56
}
 
57
 
 
58
GString &GString::operator=(const GString &src)
 
59
{
 
60
  if (cstr)
 
61
  {
 
62
    ::free(cstr);
 
63
    cstr = NULL;
 
64
  }
 
65
 
 
66
  QString::operator=(src);
 
67
  return *this;
 
68
}
 
69
 
 
70
GString &GString::operator=(const char *src)
 
71
{
 
72
  if (cstr)
 
73
  {
 
74
    ::free(cstr);
 
75
    cstr = NULL;
 
76
  }
 
77
 
 
78
  QString::operator=(src);
 
79
  return *this;
 
80
}
 
81
 
 
82
GString::GString(QString &src) : QString(src)
 
83
{
 
84
  cstr = NULL;
 
85
}
 
86
 
 
87
char *GString::toCString()
 
88
{
 
89
  QByteArray bytes = toLocal8Bit();
 
90
  
 
91
  if (cstr)
 
92
    ::free(cstr);
 
93
  
 
94
  return cstr = strdup(bytes.data());
 
95
}
 
96
 
 
97
char *GString::toUtf8CStr()
 
98
{
 
99
  QByteArray bytes = toUtf8();
 
100
  
 
101
  if (cstr)
 
102
    ::free(cstr);
 
103
  
 
104
  return cstr = strdup(bytes.data());
 
105
}
 
106
 
 
107
/* end of gstring.cc */