All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Filter.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/fe/serialization/xml/Filter.cpp
22 
23  \brief Support for the Filter serialization.
24 */
25 
26 // TerraLib
27 #include "../../../fe/Filter.h"
28 #include "../../../xml/AbstractWriter.h"
29 #include "../../../xml/Reader.h"
30 #include "AbstractOp.h"
31 #include "Filter.h"
32 
33 // STL
34 #include <cassert>
35 #include <memory>
36 
38 {
39  assert(reader.getNodeType() == te::xml::START_ELEMENT);
40  assert(reader.getElementLocalName() == "Filter");
41 
42  std::auto_ptr<te::fe::Filter> filter(new te::fe::Filter);
43 
44  reader.next();
45 
46  filter->setOp(te::fe::serialize::AbstractOp::getInstance().read(reader));
47 
48  assert(reader.getNodeType() == te::xml::END_ELEMENT);
49  reader.next();
50 
51  return filter.release();
52 }
53 
55 {
56  if(filter == 0)
57  return;
58 
59  writer.writeStartElement("ogc:Filter");
60 
61  AbstractOp::getInstance().write(filter->getOp(), writer);
62 
63  writer.writeEndElement("ogc:Filter");
64 }
This class models a XML reader object.
Definition: Reader.h:55
virtual void writeStartElement(const std::string &qName)=0
TEFEEXPORT te::fe::Filter * ReadFilter(te::xml::Reader &reader)
Definition: Filter.cpp:37
AbstractOp * getOp() const
It returns main filter operation.
Definition: Filter.cpp:56
This class models a XML writer object.
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
A Filter is any valid predicate expression.
static AbstractOp & getInstance()
It returns a reference to the singleton instance.
A filter is any valid predicate expression.
Definition: Filter.h:52
Auxiliary classes and functions to serialize filter operations from a XML document.
virtual NodeType getNodeType() const =0
It return the type of node read.
TEFEEXPORT void Save(const te::fe::Filter *filter, te::xml::AbstractWriter &writer)
Definition: Filter.cpp:54
virtual void writeEndElement(const std::string &qName)=0
virtual bool next()=0
It gets the next event to be read.