Qt 4.8
Classes | Public Types | Public Functions | Static Public Functions | Public Variables | List of all members
QProcessEnvironmentPrivate Class Reference

#include <qprocess_p.h>

Inheritance diagram for QProcessEnvironmentPrivate:
QSharedData

Classes

struct  MutexLocker
 
struct  OrderedMutexLocker
 

Public Types

typedef QHash< Key, ValueHash
 
typedef QProcEnvKey Key
 
typedef QHash< QString, KeyNameHash
 
typedef QProcEnvValue Value
 

Public Functions

void insert (const QProcessEnvironmentPrivate &other)
 
QStringList keys () const
 
QString nameToString (const Key &name) const
 
Key prepareName (const QString &name) const
 
Value prepareValue (const QString &value) const
 
QStringList toList () const
 
QString valueToString (const Value &value) const
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Static Public Functions

static QProcessEnvironment fromList (const QStringList &list)
 

Public Variables

Hash hash
 
QMutex mutex
 
NameHash nameMap
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Definition at line 146 of file qprocess_p.h.

Typedefs

◆ Hash

Definition at line 212 of file qprocess_p.h.

◆ Key

Definition at line 149 of file qprocess_p.h.

◆ NameHash

Definition at line 216 of file qprocess_p.h.

◆ Value

Definition at line 150 of file qprocess_p.h.

Functions

◆ fromList()

QProcessEnvironment QProcessEnvironmentPrivate::fromList ( const QStringList list)
static

Definition at line 167 of file qprocess.cpp.

Referenced by QProcess::setEnvironment().

168 {
171  end = list.constEnd();
172  for ( ; it != end; ++it) {
173  int pos = it->indexOf(QLatin1Char('='));
174  if (pos < 1)
175  continue;
176 
177  QString value = it->mid(pos + 1);
178  QString name = *it;
179  name.truncate(pos);
180  env.insert(name, value);
181  }
182  return env;
183 }
The QProcessEnvironment class holds the environment variables that can be passed to a program...
Definition: qprocess.h:68
#define it(className, varName)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
Definition: qlist.h:269
The QString class provides a Unicode character string.
Definition: qstring.h:83
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
const char * name
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
Definition: qstring.cpp:3706
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
Definition: qlist.h:279
static const KeyPair *const end
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void insert(const QString &name, const QString &value)
Inserts the environment variable of name name and contents value into this QProcessEnvironment object...
Definition: qprocess.cpp:337
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:272

◆ insert()

void QProcessEnvironmentPrivate::insert ( const QProcessEnvironmentPrivate other)

Definition at line 196 of file qprocess.cpp.

Referenced by QProcessEnvironment::insert().

197 {
199  end = other.hash.constEnd();
200  for ( ; it != end; ++it)
201  hash.insert(it.key(), it.value());
202 
203 #ifdef Q_OS_UNIX
205  nend = other.nameMap.constEnd();
206  for ( ; nit != nend; ++nit)
207  nameMap.insert(nit.key(), nit.value());
208 #endif
209 }
#define it(className, varName)
const_iterator ConstIterator
Qt-style synonym for QHash::const_iterator.
Definition: qhash.h:474
The QHash class is a template class that provides a hash-table-based dictionary.
Definition: qdatastream.h:66
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
const Key key(const T &value) const
Returns the first key mapped to value.
Definition: qhash.h:674
static const KeyPair *const end

◆ keys()

QStringList QProcessEnvironmentPrivate::keys ( ) const

Definition at line 185 of file qprocess.cpp.

Referenced by QProcessEnvironment::keys().

186 {
187  QStringList result;
188  result.reserve(hash.size());
190  end = hash.constEnd();
191  for ( ; it != end; ++it)
192  result << nameToString(it.key());
193  return result;
194 }
#define it(className, varName)
const_iterator ConstIterator
Qt-style synonym for QHash::const_iterator.
Definition: qhash.h:474
QString nameToString(const Key &name) const
Definition: qprocess_p.h:153
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
static const KeyPair *const end
void reserve(int size)
Reserve space for alloc elements.
Definition: qlist.h:496

◆ nameToString()

QString QProcessEnvironmentPrivate::nameToString ( const Key name) const
inline

Definition at line 153 of file qprocess_p.h.

Referenced by keys(), and toList().

153 { return name; }
const char * name

◆ prepareName()

Key QProcessEnvironmentPrivate::prepareName ( const QString name) const
inline

◆ prepareValue()

Value QProcessEnvironmentPrivate::prepareValue ( const QString value) const
inline

Definition at line 154 of file qprocess_p.h.

Referenced by QProcessEnvironment::insert().

154 { return value; }

◆ toList()

QStringList QProcessEnvironmentPrivate::toList ( ) const

Definition at line 150 of file qprocess.cpp.

Referenced by QProcessEnvironment::toStringList().

151 {
152  QStringList result;
153  result.reserve(hash.size());
155  end = hash.constEnd();
156  for ( ; it != end; ++it) {
157  QString data = nameToString(it.key());
158  QString value = valueToString(it.value());
159  data.reserve(data.length() + value.length() + 1);
160  data.append(QLatin1Char('='));
161  data.append(value);
162  result << data;
163  }
164  return result;
165 }
#define it(className, varName)
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
const_iterator ConstIterator
Qt-style synonym for QHash::const_iterator.
Definition: qhash.h:474
QString nameToString(const Key &name) const
Definition: qprocess_p.h:153
The QString class provides a Unicode character string.
Definition: qstring.h:83
QString valueToString(const Value &value) const
Definition: qprocess_p.h:155
void reserve(int size)
Attempts to allocate memory for at least size characters.
Definition: qstring.h:881
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static const char * data(const QByteArray &arr)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
QString & append(QChar c)
Definition: qstring.cpp:1777
int size() const
Returns the number of items in the hash.
Definition: qhash.h:295
static const KeyPair *const end
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void reserve(int size)
Reserve space for alloc elements.
Definition: qlist.h:496

◆ valueToString()

QString QProcessEnvironmentPrivate::valueToString ( const Value value) const
inline

Definition at line 155 of file qprocess_p.h.

Referenced by toList(), and QProcessEnvironment::value().

155 { return value; }

Properties

◆ hash

Hash QProcessEnvironmentPrivate::hash

◆ mutex

QMutex QProcessEnvironmentPrivate::mutex
mutable

◆ nameMap

NameHash QProcessEnvironmentPrivate::nameMap
mutable

The documentation for this class was generated from the following files: