/home/martin/workspace/OpenStreetNav/src/sqllib/strings/SqlCreatorFactory.cpp
Go to the documentation of this file.
00001 /*
00002  * SqlCreatorFactory.cpp
00003  *
00004  *  Created on: Dec 5, 2011
00005  *      Author: martin
00006  */
00007 
00008 #include "SqlCreatorFactory.h"
00009 #include "CompositeSqlCreator.h"
00010 #include "SimpleSqlCreator.h"
00011 #include <exception>
00012 
00013 namespace sqllib
00014 {
00015 
00016 std::shared_ptr<SqlCreator> sqllib::SqlCreatorFactory::create(const boost::property_tree::ptree& tree)
00017 {
00018     if (tree.get<std::string>("type") == "intersect" || tree.get<std::string>("type") == "union")
00019     {
00020         std::vector<std::shared_ptr<SqlCreator> > vect;
00021         for (auto it = tree.get_child("children").begin(); it != tree.get_child("children").end(); ++it)
00022         {
00023             vect.push_back(create(it->second));
00024         }
00025         std::string ending = tree.get<std::string>("ending", "");
00026         return std::shared_ptr<SqlCreator>(new CompositeSqlCreator(tree.get<std::string>("type"), vect, ending));
00027     }
00028     if (tree.get<std::string>("type") == "simple")
00029     {
00030         return std::shared_ptr<SqlCreator>(new SimpleSqlCreator(tree.get<std::string>("query")));
00031     }
00032     throw std::exception();
00033     return std::shared_ptr<SqlCreator>();
00034 }
00035 
00036 } /* namespace sqllib */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines