printcapentry.h
00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License version 2 as published by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 **/ 00019 00020 #ifndef PRINTCAPENTRY_H 00021 #define PRINTCAPENTRY_H 00022 00023 #if !defined( _KDEPRINT_COMPILE ) && defined( __GNUC__ ) 00024 #warning internal header, do not use except if you are a KDEPrint developer 00025 #endif 00026 00027 #include <qstring.h> 00028 #include <qmap.h> 00029 #include <qstringlist.h> 00030 #include <qtextstream.h> 00031 00039 class Field 00040 { 00041 public: 00042 enum Type { String, Integer, Boolean }; 00043 Field() : type(String) {} 00044 Field(const Field &f) : type(f.type), name(f.name), value(f.value) {} 00045 Field& operator= (const Field& f) 00046 { 00047 type = f.type; 00048 name = f.name; 00049 value = f.value; 00050 return (*this); 00051 } 00052 QString toString() const; 00053 00054 Type type; 00055 QString name; 00056 QString value; 00057 }; 00058 00066 class PrintcapEntry 00067 { 00068 public: 00069 QString name; 00070 QStringList aliases; 00071 QString comment; 00072 QMap<QString,Field> fields; 00073 QString postcomment; 00074 00075 bool has(const QString& f) const { return fields.contains(f); } 00076 QString field(const QString& f) const { return fields[f].value; } 00077 bool writeEntry(QTextStream&); 00078 void addField(const QString& name, Field::Type type = Field::Boolean, const QString& value = QString::null); 00079 }; 00080 00081 #endif