bpp-phyl3  3.0.0
IoTreeFactory.cpp
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #include "IoTreeFactory.h"
6 #include "Newick.h"
7 #include "NexusIoTree.h"
8 #include "Nhx.h"
9 
10 using namespace bpp;
11 
12 const std::string IOTreeFactory::NEWICK_FORMAT = "Newick";
13 const std::string IOTreeFactory::NEXUS_FORMAT = "Nexus";
14 const std::string IOTreeFactory::NHX_FORMAT = "Nhx";
15 
16 ITree* IOTreeFactory::createReader(const std::string& format)
17 {
18  if (format == NEWICK_FORMAT)
19  return new Newick();
20  else if (format == NEXUS_FORMAT)
21  return new NexusIOTree();
22  else if (format == NHX_FORMAT)
23  return new Nhx();
24  else
25  throw Exception("Format " + format + " is not supported for input.");
26 }
27 
28 OTree* IOTreeFactory::createWriter(const std::string& format)
29 {
30  if (format == NEWICK_FORMAT)
31  return new Newick();
32  else if (format == NEXUS_FORMAT)
33  return new NexusIOTree();
34  else if (format == NHX_FORMAT)
35  return new Nhx();
36  else
37  throw Exception("Format " + format + " is not supported for output.");
38 }
static const std::string NEXUS_FORMAT
Definition: IoTreeFactory.h:23
virtual OTree * createWriter(const std::string &format)
Get a new dynamically created OTree object.
static const std::string NHX_FORMAT
Definition: IoTreeFactory.h:24
static const std::string NEWICK_FORMAT
Definition: IoTreeFactory.h:22
virtual ITree * createReader(const std::string &format)
Get a new dynamically created ITree object.
General interface for tree readers.
Definition: IoTree.h:59
The so-called 'newick' parenthetic format.
Definition: Newick.h:58
a simple parser for reading trees from a Nexus file.
Definition: NexusIoTree.h:36
The so-called 'Nhx - New Hampshire eXtended' parenthetic format.
Definition: Nhx.h:62
General interface for tree writers.
Definition: IoTree.h:125
Defines the basic types of data flow nodes.