ado/PrintDataSets.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 examples/ado/PrintDataSets.cpp
22 
23  \brief It displays the values of all the datasets of a data source.
24 */
25 
26 // Example
27 #include "ADOExamples.h"
28 
29 // TerraLib
30 #include <terralib/common.h>
33 
34 // STL
35 #include <iostream>
36 
37 
39 {
40  if(ds == 0 || !ds->isOpened())
41  {
42  std::cout << "The informed data source is NULL or is closed!" << std::endl;
43  return;
44  }
45 
46  std::vector<std::string> datasets = ds->getDataSetNames();
47 
48  for(std::size_t i = 0; i < datasets.size(); ++i)
49  {
50  // Retrieve the dataset by its name
51  std::unique_ptr<te::da::DataSet> dataset(ds->getDataSet(datasets[i]));
52 
53  // Print its data to the standard output
54  PrintDataSetValues(datasets[i], dataset.get());
55  }
56 }
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
virtual bool isOpened() const =0
It returns true if the data source is opened, otherwise it returns false.
Examples that show how to access/manipulate an ADO data source.
static te::dt::Date ds(2010, 01, 01)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
void PrintDataSets(te::da::DataSource *ds)
It prints datasets in a given data source.
virtual std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
virtual std::unique_ptr< DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. This method always returns a disconnected dataset...
This file contains include headers for the TerraLib Common Runtime module.
A dataset is the unit of information manipulated by the data access module of TerraLib.
void PrintDataSetValues(const std::string &datasetName, te::da::DataSet *dataset)
It prints the data of a given dataset.