Skip to content
Snippets Groups Projects
Commit 15f4431c authored by Jan Trávníček's avatar Jan Trávníček
Browse files

better summary xml

parent 5cab2e36
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -12,13 +12,7 @@
#include <exception/CommonException.h>
#include <lexer/Lexer.h>
#include <parser/Parser.h>
#include <container/ObjectsMap.h>
#include <container/ObjectsSet.h>
#include <container/ObjectsPair.h>
#include <container/ObjectsVector.h>
#include <container/ObjectsTuple.h>
#include <primitive/String.h>
#include <factory/XmlDataFactory.hpp>
 
int main ( int argc, char * argv[] ) {
try {
......@@ -90,19 +84,90 @@ int main ( int argc, char * argv[] ) {
cli::Parser parser ( cli::Lexer ( "introspect names" ) );
parser.parse ( )->run ( environment );
} else if ( summary.isSet ( ) ) {
ext::set < ext::pair < std::string, std::string > > casts = abstraction::Registry::listCasts ( );
ext::set < std::string > algos = abstraction::Registry::listAlgorithms ( );
ext::map < std::string, ext::set < ext::pair < ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > >, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > > > > > overs;
for ( const std::string & algo : algos )
overs.insert ( std::make_pair ( algo, abstraction::Registry::listOverloads ( algo ) ) );
ext::pair <
ext::set < ext::pair < std::string, std::string > >,
ext::map < std::string, ext::set < ext::pair < ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > >, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > > > > >
> res = ext::make_pair ( casts, overs );
alib::XmlDataFactory::toStdout ( res );
ext::deque < sax::Token > tokens;
tokens.emplace_back("Summary", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back("Casts", sax::Token::TokenType::START_ELEMENT);
for ( const ext::pair < std::string, std::string > & cast : abstraction::Registry::listCasts ( ) ) {
tokens.emplace_back("Cast", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back("From", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back(cast.second, sax::Token::TokenType::CHARACTER);
tokens.emplace_back("From", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("To", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back(cast.first, sax::Token::TokenType::CHARACTER);
tokens.emplace_back("To", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Cast", sax::Token::TokenType::END_ELEMENT);
}
tokens.emplace_back("Casts", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Algorithms", sax::Token::TokenType::START_ELEMENT);
for ( const std::string & algo : abstraction::Registry::listAlgorithms ( ) ) {
tokens.emplace_back("Algorithm", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back("Name", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back(algo, sax::Token::TokenType::CHARACTER);
tokens.emplace_back("Name", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Overloads", sax::Token::TokenType::START_ELEMENT);
for ( const ext::pair < ext::pair < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier > >, ext::vector < ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > > > & over : abstraction::Registry::listOverloads ( algo ) ) {
tokens.emplace_back("Overload", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back("Returns", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back("Type", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back(over.first.first, sax::Token::TokenType::CHARACTER);
tokens.emplace_back("Type", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Qualifications", sax::Token::TokenType::START_ELEMENT);
for ( abstraction::ParamQualifiers::ParamQualifier qualifier : over.first.second ) {
tokens.emplace_back ( "Qualifier", sax::Token::TokenType::START_ELEMENT);
switch ( qualifier ) {
case abstraction::ParamQualifiers::ParamQualifier::CONST:
tokens.emplace_back("const", sax::Token::TokenType::CHARACTER);
break;
case abstraction::ParamQualifiers::ParamQualifier::LREF:
tokens.emplace_back("lref", sax::Token::TokenType::CHARACTER);
break;
case abstraction::ParamQualifiers::ParamQualifier::RREF:
tokens.emplace_back("rref", sax::Token::TokenType::CHARACTER);
break;
}
tokens.emplace_back ( "Qualifier", sax::Token::TokenType::END_ELEMENT);
}
tokens.emplace_back("Qualifications", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Returns", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Params", sax::Token::TokenType::START_ELEMENT);
for ( const ext::tuple < std::string, ext::set < abstraction::ParamQualifiers::ParamQualifier >, std::string > & param : over.second ) {
tokens.emplace_back("Param", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back("Type", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back(std::get < 0 > ( param ), sax::Token::TokenType::CHARACTER);
tokens.emplace_back("Type", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Qualifications", sax::Token::TokenType::START_ELEMENT);
for ( abstraction::ParamQualifiers::ParamQualifier qualifier : std::get < 1 > ( param ) ) {
tokens.emplace_back ( "Qualifier", sax::Token::TokenType::START_ELEMENT);
switch ( qualifier ) {
case abstraction::ParamQualifiers::ParamQualifier::CONST:
tokens.emplace_back("const", sax::Token::TokenType::CHARACTER);
break;
case abstraction::ParamQualifiers::ParamQualifier::LREF:
tokens.emplace_back("lref", sax::Token::TokenType::CHARACTER);
break;
case abstraction::ParamQualifiers::ParamQualifier::RREF:
tokens.emplace_back("rref", sax::Token::TokenType::CHARACTER);
break;
}
tokens.emplace_back ( "Qualifier", sax::Token::TokenType::END_ELEMENT);
}
tokens.emplace_back("Qualifications", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Name", sax::Token::TokenType::START_ELEMENT);
tokens.emplace_back(std::get < 2 > ( param ), sax::Token::TokenType::CHARACTER);
tokens.emplace_back("Name", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Param", sax::Token::TokenType::END_ELEMENT);
}
tokens.emplace_back("Params", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Overload", sax::Token::TokenType::END_ELEMENT);
}
tokens.emplace_back("Overloads", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Algorithm", sax::Token::TokenType::END_ELEMENT);
}
tokens.emplace_back("Algorithms", sax::Token::TokenType::END_ELEMENT);
tokens.emplace_back("Summary", sax::Token::TokenType::END_ELEMENT);
sax::SaxComposeInterface::printStdout ( tokens );
}
 
measurements::end ( );
......
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