• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Solid

predicateparse.cpp

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2006 Kevin Ottens <ervin@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License version 2 as published by the Free Software Foundation.
00007 
00008     This library is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011     Library General Public License for more details.
00012 
00013     You should have received a copy of the GNU Library General Public License
00014     along with this library; see the file COPYING.LIB.  If not, write to
00015     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016     Boston, MA 02110-1301, USA.
00017 
00018 */
00019 
00020 extern "C"
00021 {
00022 #include "predicateparse.h"
00023 
00024 void PredicateParse_mainParse(const char *_code);
00025 }
00026 
00027 #include "predicate.h"
00028 
00029 #include <stdlib.h>
00030 
00031 #include <QtCore/QStringList>
00032 
00033 static Solid::Predicate *s_result = 0;
00034 
00035 Solid::Predicate Solid::Predicate::fromString(const QString &predicate)
00036 {
00037     PredicateParse_mainParse(predicate.toAscii());
00038 
00039     if (s_result == 0)
00040     {
00041         return Predicate();
00042     }
00043     else
00044     {
00045         Predicate result(*s_result);
00046         delete s_result;
00047         s_result = 0;
00048         return result;
00049     }
00050 }
00051 
00052 
00053 void PredicateParse_setResult(void *result)
00054 {
00055     s_result = (Solid::Predicate *) result;
00056 }
00057 
00058 void PredicateParse_errorDetected()
00059 {
00060     if (s_result != 0)
00061     {
00062         delete s_result;
00063         s_result = 0;
00064     }
00065 }
00066 
00067 void *PredicateParse_newAtom(char *interface, char *property, void *value)
00068 {
00069     QString iface(interface);
00070     QString prop(property);
00071     QVariant *val = (QVariant *)value;
00072 
00073     Solid::Predicate *result = new Solid::Predicate(iface, prop, *val);
00074 
00075     delete val;
00076     free(interface);
00077     free(property);
00078 
00079     return result;
00080 }
00081 
00082 void *PredicateParse_newMaskAtom(char *interface, char *property, void *value)
00083 {
00084     QString iface(interface);
00085     QString prop(property);
00086     QVariant *val = (QVariant *)value;
00087 
00088     Solid::Predicate *result = new Solid::Predicate(iface, prop, *val, Solid::Predicate::Mask);
00089 
00090     delete val;
00091     free(interface);
00092     free(property);
00093 
00094     return result;
00095 }
00096 
00097 
00098 void *PredicateParse_newIsAtom(char *interface)
00099 {
00100     QString iface(interface);
00101 
00102     Solid::Predicate *result = new Solid::Predicate(iface);
00103 
00104     free(interface);
00105 
00106     return result;
00107 }
00108 
00109 
00110 void *PredicateParse_newAnd(void *pred1, void *pred2)
00111 {
00112     Solid::Predicate *result = new Solid::Predicate();
00113 
00114     Solid::Predicate *p1 = (Solid::Predicate *)pred1;
00115     Solid::Predicate *p2 = (Solid::Predicate *)pred2;
00116 
00117     *result = *p1  & *p2;
00118 
00119     delete p1;
00120     delete p2;
00121 
00122     return result;
00123 }
00124 
00125 
00126 void *PredicateParse_newOr(void *pred1, void *pred2)
00127 {
00128     Solid::Predicate *result = new Solid::Predicate();
00129 
00130     Solid::Predicate *p1 = (Solid::Predicate *)pred1;
00131     Solid::Predicate *p2 = (Solid::Predicate *)pred2;
00132 
00133     *result = *p1 | *p2;
00134 
00135     delete p1;
00136     delete p2;
00137 
00138     return result;
00139 }
00140 
00141 
00142 void *PredicateParse_newStringValue(char *val)
00143 {
00144     QString s(val);
00145 
00146     free(val);
00147 
00148     return new QVariant(s);
00149 }
00150 
00151 
00152 void *PredicateParse_newBoolValue(int val)
00153 {
00154     bool b = (val != 0);
00155     return new QVariant(b);
00156 }
00157 
00158 
00159 void *PredicateParse_newNumValue(int val)
00160 {
00161     return new QVariant(val);
00162 }
00163 
00164 
00165 void *PredicateParse_newDoubleValue(double val)
00166 {
00167     return new QVariant(val);
00168 }
00169 
00170 
00171 void *PredicateParse_newEmptyStringListValue()
00172 {
00173     return new QVariant(QStringList());
00174 }
00175 
00176 
00177 void *PredicateParse_newStringListValue(char *name)
00178 {
00179     QStringList list;
00180     list << QString(name);
00181 
00182     free(name);
00183 
00184     return new QVariant(list);
00185 }
00186 
00187 
00188 void *PredicateParse_appendStringListValue(char *name, void *list)
00189 {
00190     QVariant *variant = (QVariant *)list;
00191 
00192     QStringList new_list = variant->toStringList();
00193 
00194     new_list << QString(name);
00195 
00196     delete variant;
00197     free(name);
00198 
00199     return new QVariant(new_list);
00200 }

Solid

Skip menu "Solid"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal