kdeprint Library API Documentation

printcapentry.cpp

00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001,2002 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., 59 Temple Place - Suite 330,
00017  *  Boston, MA 02111-1307, USA.
00018  **/
00019 
00020 #include "printcapentry.h"
00021 
00022 QString Field::toString() const
00023 {
00024     QString s = name;
00025     switch (type)
00026     {
00027         case String:
00028             s += ("=" + value);
00029             break;
00030         case Integer:
00031             s += ("#" + value);
00032             break;
00033         case Boolean:
00034             if (!value.toInt())
00035                 s += "@";
            break;
    }
    return s;
}

bool PrintcapEntry::writeEntry(QTextStream& t)
{
    t << comment << endl;
    t << name;
    if (aliases.count() > 0)
        t << '|' << aliases.join("|");
00036     t << ':';
00037     for (QMap<QString,Field>::ConstIterator it=fields.begin(); it!=fields.end(); ++it)
00038     {
00039         t << '\\' << endl << "    :";
00040         t << (*it).name;
00041         switch ((*it).type)
00042         {
00043             case Field::String:
00044                 t << '=' << (*it).value << ':';
00045                 break;
00046             case Field::Integer:
00047                 t << '#' << (*it).value << ':';
00048                 break;
00049             case Field::Boolean:
00050                 t << ':';
00051                 break;
00052             default:
00053                 t << endl << endl;
00054                 return false;
00055         }
00056     }
00057     t << endl;
00058     if (!postcomment.isEmpty())
00059         t << postcomment << endl;
00060     t << endl;
00061     return true;
00062 }
00063 
00064 void PrintcapEntry::addField(const QString& name, Field::Type type, const QString& value)
00065 {
00066     Field   f;
00067     f.name = name;
00068     f.type = type;
00069     f.value = value;
00070     fields[name] = f;
00071 }
00072 
KDE Logo
This file is part of the documentation for kdeprint Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 3 19:24:24 2005 by doxygen 1.3.6 written by Dimitri van Heesch, © 1997-2003