Skip to content
Snippets Groups Projects
Commit 8a77c965 authored by Tomáš Pecka's avatar Tomáš Pecka
Browse files

Cli builtin dot: Save in multiple formats

parent dde1943f
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -8,16 +8,31 @@
#include "Dot.h"
#include <registration/AlgoRegistration.hpp>
#include <cstdlib>
#include <algorithm>
#include <cctype>
 
namespace cli {
 
namespace builtin {
 
std::vector < std::string> Dot::m_DotAllowedTypes { "dot", "xdot", "ps", "pdf", "svg", "svgz", "fig", "png", "gif", "jpg", "jpeg", "json", "imap", "cmapx" };
void Dot::dot ( const std::string & data ) {
std::system ( ( "dot -Tx11 <<DOTDATA\n" + data + "\nDOTDATA" ).c_str ( ) );
( void ) std::system( ( "dot -Tx11 <<DOTDATA\n" + data + "\nDOTDATA" ).c_str ( ) );
}
void Dot::dot ( const std::string & data, const std::string & outputType, const std::string & outputFile ) {
std::string outputTypeLower;
std::transform ( outputType.begin( ), outputType.end(), std::back_inserter ( outputTypeLower ), ::tolower);
if ( std::find ( m_DotAllowedTypes.begin( ), m_DotAllowedTypes.end ( ), outputType ) == m_DotAllowedTypes.end ( ) )
throw exception::CommonException ( "Dot outputType is invalid." );
( void ) std::system ( ( "dot -T" + outputTypeLower + " -o " + outputFile + "<<DOTDATA\n" + data + "\nDOTDATA" ).c_str ( ) );
}
 
auto DotString = registration::AbstractRegister < Dot, void, const std::string & > ( Dot::dot );
auto DotTx11 = registration::AbstractRegister < Dot, void, const std::string & > ( Dot::dot );
auto DotTpng = registration::AbstractRegister < Dot, void, const std::string &, const std::string &, const std::string & > ( Dot::dot );
 
} /* namespace builtin */
 
......
......@@ -9,6 +9,7 @@
#define _DOT_H_
 
#include <string>
#include <vector>
 
namespace cli {
 
......@@ -17,9 +18,13 @@ namespace builtin {
class Dot {
public:
/**
* Removes dead states from FSM. Melichar 2.29
* Cli builtin for DOT format visualization
*/
static void dot( const std::string & dot );
static void dot ( const std::string & data, const std::string & outputType, const std::string & outputFile );
private:
static std::vector < std::string > m_DotAllowedTypes;
};
 
} /* namespace builtin */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment