diff --git a/aintrospection2/src/aintrospection.cpp b/aintrospection2/src/aintrospection.cpp index 88ce96e61b0cf7762f8e06d0e2e02a0e2de15430..b84e9f41c6fdfa718c3b5f5e29f427b09b3d4ea7 100644 --- a/aintrospection2/src/aintrospection.cpp +++ b/aintrospection2/src/aintrospection.cpp @@ -172,7 +172,7 @@ int main ( int argc, char * argv[] ) { tokens.emplace_back("Algorithms", sax::Token::TokenType::END_ELEMENT); tokens.emplace_back("Summary", sax::Token::TokenType::END_ELEMENT); - sax::SaxComposeInterface::printStdout ( tokens ); + sax::SaxComposeInterface::composeStdout ( tokens ); } measurements::end ( ); diff --git a/alib2data/test-src/alphabet/SymbolTest.cpp b/alib2data/test-src/alphabet/SymbolTest.cpp index 2fabec48512abf325b208cee50f659f18adf08c3..ddd126aa22cf1cbcd864d417f88dea2a85f5bf58 100644 --- a/alib2data/test-src/alphabet/SymbolTest.cpp +++ b/alib2data/test-src/alphabet/SymbolTest.cpp @@ -43,11 +43,9 @@ void SymbolTest::testXMLParser ( ) { { ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( symbol ); - std::string tmp; - sax::SaxComposeInterface::printMemory ( tmp, tokens ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque < sax::Token > tokens2; - sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); + ext::deque < sax::Token > tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); alphabet::Symbol symbol2 = factory::XmlDataFactory::fromTokens ( std::move( tokens2 ) ); CPPUNIT_ASSERT ( symbol == symbol2 ); diff --git a/alib2data/test-src/automaton/AutomatonTemplatesTest.cpp b/alib2data/test-src/automaton/AutomatonTemplatesTest.cpp index 4df14a0c5b830e6b7ac55e6b5cc60b2c778c92d6..d047f916cde2e19697631bc41c293080624a7482 100644 --- a/alib2data/test-src/automaton/AutomatonTemplatesTest.cpp +++ b/alib2data/test-src/automaton/AutomatonTemplatesTest.cpp @@ -41,8 +41,7 @@ void AutomatonTemplatesTest::testDFAParser ( ) { CPPUNIT_ASSERT ( automaton == automaton ); { ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( automaton ); - std::string tmp; - sax::SaxComposeInterface::printMemory ( tmp, tokens ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); ext::deque < sax::Token > tokens2; sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); @@ -52,8 +51,7 @@ void AutomatonTemplatesTest::testDFAParser ( ) { } { ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( automaton ); - std::string tmp; - sax::SaxComposeInterface::printMemory ( tmp, tokens ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); ext::deque < sax::Token > tokens2; sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); diff --git a/alib2data/test-src/automaton/AutomatonTest.cpp b/alib2data/test-src/automaton/AutomatonTest.cpp index 772953b34e509a81340f300fc1bb88f1be035429..74a0eb1c799a68ca998db69cde3972ada92fe477 100644 --- a/alib2data/test-src/automaton/AutomatonTest.cpp +++ b/alib2data/test-src/automaton/AutomatonTest.cpp @@ -55,11 +55,9 @@ void AutomatonTest::testDFAParser() { CPPUNIT_ASSERT( automaton == automaton ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(automaton); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); automaton::DFA < char, int > automaton2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( automaton == automaton2 ); @@ -302,12 +300,10 @@ void AutomatonTest::testNFTAParser() { CPPUNIT_ASSERT( automaton == automaton ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(automaton); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); std::cout << tmp << std::endl; - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); automaton::NFTA < char, unsigned, int > automaton2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( automaton == automaton2 ); diff --git a/alib2data/test-src/common/SparseBoolVectorTest.cpp b/alib2data/test-src/common/SparseBoolVectorTest.cpp index 60af87c9d4b70170a71a8e7882e89f3911aa7d0d..5a4b2c3b7a327868654fe563f8aa8880fe5db9fe 100644 --- a/alib2data/test-src/common/SparseBoolVectorTest.cpp +++ b/alib2data/test-src/common/SparseBoolVectorTest.cpp @@ -295,12 +295,10 @@ void SparseBoolVectorTest::testXmlApi() { common::SparseBoolVector data ( ref ); ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens( data ); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); // std::cout << tmp << std::endl; - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); common::SparseBoolVector data2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); /* std::cout << data.data ( ) << std::endl; diff --git a/alib2data/test-src/grammar/GrammarTest.cpp b/alib2data/test-src/grammar/GrammarTest.cpp index fc6321048792ed920d12612bc5a3b12872d67be4..574dd79d28d1ca98c795f5a08821173a1af40cc3 100644 --- a/alib2data/test-src/grammar/GrammarTest.cpp +++ b/alib2data/test-src/grammar/GrammarTest.cpp @@ -53,11 +53,9 @@ void GrammarTest::testUnrestrictedParser() { CPPUNIT_ASSERT( grammar == grammar ); ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::UnrestrictedGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -80,11 +78,9 @@ void GrammarTest::testUnrestrictedParser() { CPPUNIT_ASSERT( grammar == grammar ); ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::ContextPreservingUnrestrictedGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -107,11 +103,9 @@ void GrammarTest::testRegularParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::RightRG < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -135,13 +129,11 @@ void GrammarTest::testRegularParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); std::cout << tmp << std::endl; - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::RightLG < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -167,11 +159,9 @@ void GrammarTest::testContextFreeParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::LG < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -195,11 +185,9 @@ void GrammarTest::testContextFreeParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::EpsilonFreeCFG < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -223,11 +211,9 @@ void GrammarTest::testContextFreeParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::CFG < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -251,11 +237,9 @@ void GrammarTest::testContextFreeParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::CNF < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -279,11 +263,9 @@ void GrammarTest::testContextFreeParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::GNF < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -309,11 +291,9 @@ void GrammarTest::testContextSensitiveParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::CSG < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); @@ -336,11 +316,9 @@ void GrammarTest::testContextSensitiveParser() { CPPUNIT_ASSERT( grammar == grammar ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(grammar); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); grammar::NonContractingGrammar < > grammar2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( grammar == grammar2 ); diff --git a/alib2data/test-src/label/LabelTest.cpp b/alib2data/test-src/label/LabelTest.cpp index 4d6f7d21a9a36a25df7e99e956823c3bd2cb6343..52d72a983b83b525554b6db670fd697b08bfe3fa 100644 --- a/alib2data/test-src/label/LabelTest.cpp +++ b/alib2data/test-src/label/LabelTest.cpp @@ -42,11 +42,9 @@ void LabelTest::testXMLParser() { { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(label); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); label::Label label2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( label == label2 ); diff --git a/alib2data/test-src/regexp/RegExpTest.cpp b/alib2data/test-src/regexp/RegExpTest.cpp index 20072199cbceed757159b8b9c112a89a18c41db5..b1ebe4e92b473b1aba948a8803b40461c58214a7 100644 --- a/alib2data/test-src/regexp/RegExpTest.cpp +++ b/alib2data/test-src/regexp/RegExpTest.cpp @@ -107,11 +107,9 @@ void RegExpTest::testXMLParser() { { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(regexp); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); regexp::RegExp regexp2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( regexp == regexp2 ); diff --git a/alib2data/test-src/rte/RTETest.cpp b/alib2data/test-src/rte/RTETest.cpp index ae4283cb9223cd22123946ec36440ba38b906a44..adb51870b0f7a7f12e61dbaa0a31505981e03019 100644 --- a/alib2data/test-src/rte/RTETest.cpp +++ b/alib2data/test-src/rte/RTETest.cpp @@ -123,11 +123,9 @@ void RTETest::testXMLParser ( ) { factory::XmlDataFactory::toStdout ( rte ); { ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( rte ); - std::string tmp; - sax::SaxComposeInterface::printMemory ( tmp, tokens ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque < sax::Token > tokens2; - sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); + ext::deque < sax::Token > tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); rte::RTE rte2 = factory::XmlDataFactory::fromTokens ( std::move ( tokens2 ) ); CPPUNIT_ASSERT ( rte == rte2 ); diff --git a/alib2data/test-src/string/StringTest.cpp b/alib2data/test-src/string/StringTest.cpp index f7a8646d45479c1d9feacb71fbea909dbb6ac0be..9c75e3c6f826c8a031587f9fe45c4eeaf7d89b0a 100644 --- a/alib2data/test-src/string/StringTest.cpp +++ b/alib2data/test-src/string/StringTest.cpp @@ -58,13 +58,11 @@ void StringTest::testXMLParser ( ) { string::String string ( linearString ); { ext::deque < sax::Token > tokens = factory::XmlDataFactory::toTokens ( string ); - std::string tmp; - sax::SaxComposeInterface::printMemory ( tmp, tokens ); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); std::cout << tmp << std::endl; - ext::deque < sax::Token > tokens2; - sax::SaxParseInterface::parseMemory ( tmp, tokens2 ); + ext::deque < sax::Token > tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); string::String string2 = factory::XmlDataFactory::fromTokens ( std::move( tokens2 ) ); CPPUNIT_ASSERT ( string == string2 ); diff --git a/alib2data/test-src/tree/PatternTest.cpp b/alib2data/test-src/tree/PatternTest.cpp index f5c7ecfdc169575dcad0d94837cca2f31631f049..71b52508884e30d6371306fdf400eca9fee781e3 100644 --- a/alib2data/test-src/tree/PatternTest.cpp +++ b/alib2data/test-src/tree/PatternTest.cpp @@ -45,11 +45,9 @@ void PatternTest::testRankedPatternParser() { tree.getContent().nicePrint(std::cout); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); tree::RankedPattern < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( tree == tree2 ); @@ -95,11 +93,9 @@ void PatternTest::testUnrankedPatternParser() { tree.getContent().nicePrint(std::cout); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); tree::UnrankedPattern < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( tree == tree2 ); @@ -145,11 +141,9 @@ void PatternTest::testPrefixRankedPatternParser() { CPPUNIT_ASSERT( pattern2 == pattern2 ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(pattern2); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); tree::PrefixRankedPattern < > pattern3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( pattern2 == pattern3 ); @@ -176,13 +170,11 @@ void PatternTest::testPrefixRankedBarPatternParser() { CPPUNIT_ASSERT( pattern2 == pattern2 ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(pattern2); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); std::cout << tmp << std::endl << std::endl; - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); tree::PrefixRankedBarPattern < > pattern3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( pattern2 == pattern3 ); diff --git a/alib2data/test-src/tree/TreeTest.cpp b/alib2data/test-src/tree/TreeTest.cpp index 500599cde450e1ef873418b7c277dd0184f7ae51..46d4678e170e1c34f5981fc8218a2946125b3201 100644 --- a/alib2data/test-src/tree/TreeTest.cpp +++ b/alib2data/test-src/tree/TreeTest.cpp @@ -66,11 +66,9 @@ void TreeTest::testRankedTreeParser() { tree.getContent().nicePrint(std::cout); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); tree::RankedTree < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( tree == tree2 ); @@ -190,12 +188,10 @@ void TreeTest::testUnrankedTreeParser() { tree.getContent().nicePrint(std::cout); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); std::cout << std::endl << tmp << std::endl << std::endl; - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); tree::UnrankedTree < > tree2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( tree == tree2 ); @@ -296,13 +292,11 @@ void TreeTest::testPrefixRankedBarParser() { CPPUNIT_ASSERT( tree2 == tree2 ); { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(tree2); - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); std::cout << tmp << std::endl << std::endl; - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); tree::PrefixRankedBarTree < > tree3 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( tree2 == tree3 ); diff --git a/alib2raw/src/tree/raw/UnrankedTree.h b/alib2raw/src/tree/raw/UnrankedTree.h index d58ce6b2a07e27813e5eb5fa7aed3448a51ee431..dbab86aae9e4201b877332cc5421b18f6abebaa6 100644 --- a/alib2raw/src/tree/raw/UnrankedTree.h +++ b/alib2raw/src/tree/raw/UnrankedTree.h @@ -38,7 +38,7 @@ template < class SymbolType > void rawApi < tree::UnrankedTree < SymbolType > >::compose ( std::ostream & output, const tree::UnrankedTree < SymbolType > & tree ) { ext::deque < sax::Token > tokens; composeContent ( tokens, tree.getContent ( ) ); - sax::SaxComposeInterface::printStream ( output, tokens ); + sax::SaxComposeInterface::composeStream ( output, tokens ); } template < class SymbolType > diff --git a/alib2xml/src/abstraction/XmlTokensComposerAbstraction.hpp b/alib2xml/src/abstraction/XmlTokensComposerAbstraction.hpp index 0a9eb56a68f042fb701e2a6a5c49ff1a9c69cf16..01e882adedecd980385251d43460fb05f4e82a15 100644 --- a/alib2xml/src/abstraction/XmlTokensComposerAbstraction.hpp +++ b/alib2xml/src/abstraction/XmlTokensComposerAbstraction.hpp @@ -18,7 +18,7 @@ public: if ( ! this->inputsReady ( ) ) return false; - sax::SaxComposeInterface::printFile ( std::get < 1 > ( this->m_params )->getConstValueReference ( ), std::get < 0 > ( this->m_params )->getConstValueReference ( ) ); + sax::SaxComposeInterface::composeFile ( std::get < 1 > ( this->m_params )->getConstValueReference ( ), std::get < 0 > ( this->m_params )->getConstValueReference ( ) ); return true; } }; diff --git a/alib2xml/src/abstraction/XmlTokensParserAbstraction.hpp b/alib2xml/src/abstraction/XmlTokensParserAbstraction.hpp index 321c555db1ae4a471408ba8728fb24aa6c88d02f..b8dab71dbcde9f9d3330b1da27c5a4c1943927ea 100644 --- a/alib2xml/src/abstraction/XmlTokensParserAbstraction.hpp +++ b/alib2xml/src/abstraction/XmlTokensParserAbstraction.hpp @@ -18,9 +18,7 @@ public: if ( ! this->inputsReady ( ) ) return false; - ext::deque < sax::Token > tokens; - sax::SaxParseInterface::parseFile ( std::get < 0 > ( this->m_params )->getConstValueReference ( ), tokens ); - this->m_data = tokens; + this->m_data = sax::SaxParseInterface::parseFile ( std::get < 0 > ( this->m_params )->getConstValueReference ( ) ); return true; } }; diff --git a/alib2xml/src/factory/XmlDataFactory.hpp b/alib2xml/src/factory/XmlDataFactory.hpp index b11b29da669aeef5680ecf2dea671eff6e5761f7..1fe51d47ada42c08b1fc900d9862137223c8f5d0 100644 --- a/alib2xml/src/factory/XmlDataFactory.hpp +++ b/alib2xml/src/factory/XmlDataFactory.hpp @@ -41,10 +41,7 @@ public: */ template < class T > operator T ( ) { - ext::deque < sax::Token > tokens; - sax::SaxParseInterface::parseFile ( filename, tokens ); - - return fromTokens ( std::move( tokens ) ); + return fromTokens ( sax::SaxParseInterface::parseFile ( filename ) ); } }; @@ -62,10 +59,7 @@ public: */ template < class T > operator T ( ) { - ext::deque < sax::Token > tokens; - sax::SaxParseInterface::parseMemory ( string, tokens ); - - return fromTokens ( std::move ( tokens ) ); + return fromTokens ( sax::SaxParseInterface::parseMemory ( string ) ); } }; @@ -77,10 +71,7 @@ public: */ template < class T > operator T ( ) { - ext::deque < sax::Token > tokens; - sax::SaxParseInterface::parseStdin ( tokens ); - - return fromTokens ( std::move ( tokens ) ); + return fromTokens ( sax::SaxParseInterface::parseStdin ( ) ); } }; @@ -97,10 +88,8 @@ public: */ template < class T > operator T ( ) { - ext::deque < sax::Token > tokens; - sax::SaxParseInterface::parseStream ( in, tokens ); + return fromTokens ( sax::SaxParseInterface::parseStream ( in ) ); - return fromTokens ( std::move ( tokens ) ); } }; @@ -154,7 +143,7 @@ public: template < class T > static void toFile ( const T & data, const std::string & filename ) { ext::deque < sax::Token > tokens = toTokens < T > ( data ); - sax::SaxComposeInterface::printFile ( filename, tokens ); + sax::SaxComposeInterface::composeFile ( filename, tokens ); } /** @@ -165,10 +154,7 @@ public: template < class T > static std::string toString ( const T & data ) { ext::deque < sax::Token > tokens = toTokens < T > ( data ); - std::string str; - sax::SaxComposeInterface::printMemory ( str, tokens ); - - return str; + return sax::SaxComposeInterface::composeMemory ( tokens ); } /** @@ -178,7 +164,7 @@ public: template < class T > static void toStdout ( const T & data ) { ext::deque < sax::Token > tokens = toTokens < T > ( data ); - sax::SaxComposeInterface::printStdout ( tokens ); + sax::SaxComposeInterface::composeStdout ( tokens ); } /** @@ -188,7 +174,7 @@ public: template < class T > static void toStream ( const T & data, std::ostream & out ) { ext::deque < sax::Token > tokens = toTokens < T > ( data ); - sax::SaxComposeInterface::printStream ( out, tokens ); + sax::SaxComposeInterface::composeStream ( out, tokens ); } /** diff --git a/alib2xml/src/registry/XmlRegistry.cpp b/alib2xml/src/registry/XmlRegistry.cpp index bbf1f4ce0100a85a701a48acbc71dd8b3a0930be..b6861bfd16c174e7d8b2134db7e80b56b66fdb79 100644 --- a/alib2xml/src/registry/XmlRegistry.cpp +++ b/alib2xml/src/registry/XmlRegistry.cpp @@ -59,4 +59,5 @@ std::shared_ptr < abstraction::BinaryOperationAbstraction < void, const ext::deq return res; } + } /* namespace abstraction */ diff --git a/alib2xml/src/sax/SaxComposeInterface.cpp b/alib2xml/src/sax/SaxComposeInterface.cpp index eda471667b8c27c510092fb1e4ae91fbf3066561..bce6fb8c5a3482a5b32a65a401b9938053ae3119 100644 --- a/alib2xml/src/sax/SaxComposeInterface.cpp +++ b/alib2xml/src/sax/SaxComposeInterface.cpp @@ -17,41 +17,47 @@ namespace sax { -void SaxComposeInterface::printMemory(std::string& xmlOut, const ext::deque<Token>& in) { +void SaxComposeInterface::composeMemory(std::string& xmlOut, const ext::deque<Token>& in) { xmlBufferPtr buf = xmlBufferCreate(); xmlTextWriterPtr writer = xmlNewTextWriterMemory(buf, 0); - SaxComposeInterface::xmlSAXUserPrint(writer, in); + SaxComposeInterface::xmlSAXUserCompose(writer, in); xmlFreeTextWriter(writer); xmlOut = (const char*) buf->content; xmlBufferFree(buf); } -void SaxComposeInterface::printFile(const std::string& filename, const ext::deque<Token>& in) { +std::string SaxComposeInterface::composeMemory ( const ext::deque < Token > & in ) { + ext::string res; + SaxComposeInterface::composeMemory ( res, in ); + return res; +} + +void SaxComposeInterface::composeFile(const std::string& filename, const ext::deque<Token>& in) { xmlTextWriterPtr writer = xmlNewTextWriterFilename(filename.c_str(), 0); - SaxComposeInterface::xmlSAXUserPrint(writer, in); + SaxComposeInterface::xmlSAXUserCompose(writer, in); xmlFreeTextWriter(writer); } -void SaxComposeInterface::printStdout(const ext::deque<Token>& in) { - SaxComposeInterface::printFile("-", in); +void SaxComposeInterface::composeStdout(const ext::deque<Token>& in) { + SaxComposeInterface::composeFile("-", in); } -void SaxComposeInterface::printStream(std::ostream& out, const ext::deque<Token>& in) { +void SaxComposeInterface::composeStream(std::ostream& out, const ext::deque<Token>& in) { xmlBufferPtr buf = xmlBufferCreate(); xmlTextWriterPtr writer = xmlNewTextWriterMemory(buf, 0); - SaxComposeInterface::xmlSAXUserPrint(writer, in); + SaxComposeInterface::xmlSAXUserCompose(writer, in); xmlFreeTextWriter(writer); out << (const char*) buf->content; xmlBufferFree(buf); } -void SaxComposeInterface::xmlSAXUserPrint(xmlTextWriterPtr writer, const ext::deque<Token>& in) { +void SaxComposeInterface::xmlSAXUserCompose(xmlTextWriterPtr writer, const ext::deque<Token>& in) { measurements::start("Sax Composer", measurements::Type::FINALIZE); xmlTextWriterStartDocument(writer, NULL, NULL, NULL); #ifdef DEBUG diff --git a/alib2xml/src/sax/SaxComposeInterface.h b/alib2xml/src/sax/SaxComposeInterface.h index c894e9ab0d3aeeb66b34c27fd7f4b35c44614820..fe6472733fb0382864b9a7e954afeb65627b4002 100644 --- a/alib2xml/src/sax/SaxComposeInterface.h +++ b/alib2xml/src/sax/SaxComposeInterface.h @@ -15,40 +15,50 @@ namespace sax { /** - * This class performs parsing of file or string containing XML. Contains callback - * methods for libxml SAX parser. + * This class performs composing of XML Tokens to file, string, or stream. Contains callback + * method for libxml SAX composer. */ class SaxComposeInterface { - static void xmlSAXUserPrint(xmlTextWriterPtr writer, const ext::deque<Token>& in); + static void xmlSAXUserCompose(xmlTextWriterPtr writer, const ext::deque<Token>& in); public: /** - * Parses the string containing XML. - * @param xmlIn input XML - * @param out list of tokens that are returned - * @throws CommonException when an error occurs (e.g. XML is not valid) + * Composes the XML to a string. + * @param xmlOut resulting XML + * @param in list of xml tokens + * @throws CommonException when an error occurs (e.g. xml tokens incorrectly nested) */ - static void printMemory(std::string& xmlOut, const ext::deque<Token>& in); + static void composeMemory(std::string& xmlOut, const ext::deque<Token>& in); /** - * Parses the file containing XML. - * @param filename input XML - * @param out list of tokens that are returned - * @throws CommonException when an error occurs (e.g. file doesn't exist, XML is not valid) + * Composes the XML to a string. + * @param in list of xml tokens + * @return resulting XML + * @throws CommonException when an error occurs (e.g. xml tokens incorrectly nested) */ - static void printFile(const std::string& filename, const ext::deque<Token>& in); - + static std::string composeMemory ( const ext::deque < Token > & in ); + + /** + * Composes the XML to a file. + * @param filename resulting XML file destination + * @param in list of xml tokens + * @throws CommonException when an error occurs (e.g. xml tokens incorrectly nested) + */ + static void composeFile(const std::string& filename, const ext::deque<Token>& in); + /** - * Parses the XML from stdin. - * @param out list of tokens that are returned + * Composes the XML to a stdout. + * @param in list of xml tokens + * @throws CommonException when an error occurs (e.g. xml tokens incorrectly nested) */ - static void printStdout(const ext::deque<Token>& in); + static void composeStdout(const ext::deque<Token>& in); /** - * Parses the XML from stream. - * @param in input XML - * @param out list of tokens that are returned + * Composes the XML to a stream. + * @param out resulting XML stream destination + * @param in list of xml tokens + * @throws CommonException when an error occurs (e.g. xml tokens incorrectly nested) */ - static void printStream(std::ostream& out, const ext::deque<Token>& in); + static void composeStream(std::ostream& out, const ext::deque<Token>& in); }; } /* namespace sax */ diff --git a/alib2xml/src/sax/SaxParseInterface.cpp b/alib2xml/src/sax/SaxParseInterface.cpp index 204fade1291c6e79acd142b6c68d63bc787fd036..cccb9c45a3030d6d7e0dbacc286d14d62919d10b 100644 --- a/alib2xml/src/sax/SaxParseInterface.cpp +++ b/alib2xml/src/sax/SaxParseInterface.cpp @@ -33,6 +33,12 @@ void SaxParseInterface::parseMemory(const std::string& xmlIn, ext::deque<Token>& } } +ext::deque < Token > SaxParseInterface::parseMemory ( const std::string& xmlIn ) { + ext::deque < Token > tokens; + SaxParseInterface::parseMemory ( xmlIn, tokens ); + return tokens; +} + void SaxParseInterface::parseFile(const std::string& filename, ext::deque<Token>& out) { xmlTextReaderPtr reader = xmlNewTextReaderFilename(filename.c_str()); @@ -47,15 +53,31 @@ void SaxParseInterface::parseFile(const std::string& filename, ext::deque<Token> } } +ext::deque < Token > SaxParseInterface::parseFile ( const std::string & filename ) { + ext::deque < Token > tokens; + SaxParseInterface::parseFile ( filename, tokens ); + return tokens; +} + void SaxParseInterface::parseStdin(ext::deque<Token>& out) { SaxParseInterface::parseFile("-", out); } +ext::deque < Token > SaxParseInterface::parseStdin ( ) { + return SaxParseInterface::parseFile ( "-" ); +} + void SaxParseInterface::parseStream(std::istream& in, ext::deque<Token>& out) { std::string input(std::istreambuf_iterator<char>(in), (std::istreambuf_iterator<char>())); SaxParseInterface::parseMemory(input, out); } +ext::deque < Token > SaxParseInterface::parseStream ( std::istream & in ) { + ext::deque < Token > tokens; + SaxParseInterface::parseStream ( in, tokens ); + return tokens; +} + int SaxParseInterface::xmlSAXUserParse(xmlTextReaderPtr reader, ext::deque<Token>& out) { int ret = xmlTextReaderRead(reader); measurements::start("Sax Parser", measurements::Type::INIT); diff --git a/alib2xml/src/sax/SaxParseInterface.h b/alib2xml/src/sax/SaxParseInterface.h index d844330fd313a3272311c64329a2f41f93e3f46d..8a0f886ad53f07953dcf237a6a2d46bcd0c5e78b 100644 --- a/alib2xml/src/sax/SaxParseInterface.h +++ b/alib2xml/src/sax/SaxParseInterface.h @@ -15,8 +15,8 @@ namespace sax { /** - * This class performs parsing of file or string containing XML. Contains callback - * methods for libxml SAX parser. + * This class performs token parsing of file, string, or stream containing XML. Contains callback + * method for libxml SAX parser. */ class SaxParseInterface { static int xmlSAXUserParse(xmlTextReaderPtr writer, ext::deque<Token>& out); @@ -24,31 +24,64 @@ public: /** * Parses the string containing XML. * @param xmlIn input XML - * @param out list of tokens that are returned + * @param out parsed list of xml tokens * @throws CommonException when an error occurs (e.g. XML is not valid) */ static void parseMemory(const std::string& xmlIn, ext::deque<Token>& out); + /** + * Parses the string containing XML. + * @param xmlIn input XML + * @return parsed list of xml tokens + * @throws CommonException when an error occurs (e.g. XML is not valid) + */ + static ext::deque < Token > parseMemory ( const std::string & xmlIn ); + /** * Parses the file containing XML. * @param filename input XML - * @param out list of tokens that are returned + * @param out parsed list of xml tokens * @throws CommonException when an error occurs (e.g. file doesn't exist, XML is not valid) */ static void parseFile(const std::string& filename, ext::deque<Token>& out); - + + /** + * Parses the file containing XML. + * @param filename input XML + * @return parsed list of xml tokens + * @throws CommonException when an error occurs (e.g. file doesn't exist, XML is not valid) + */ + static ext::deque < Token > parseFile ( const std::string& filename ); + /** * Parses the XML from stdin. - * @param out list of tokens that are returned + * @param out parsed list of xml tokens + * @throws CommonException when an error occurs (e.g. XML is not valid) */ static void parseStdin(ext::deque<Token>& out); - + + /** + * Parses the XML from stdin. + * @return parsed list of xml tokens + * @throws CommonException when an error occurs (e.g. XML is not valid) + */ + static ext::deque < Token > parseStdin ( ); + /** * Parses the XML from stream. * @param in input XML - * @param out list of tokens that are returned + * @param out parsed list of xml tokens + * @throws CommonException when an error occurs (e.g. XML is not valid) */ static void parseStream(std::istream& in, ext::deque<Token>& out); + + /** + * Parses the XML from stream. + * @param in input XML + * @return parsed list of xml tokens + * @throws CommonException when an error occurs (e.g. XML is not valid) + */ + static ext::deque < Token > parseStream ( std::istream & in ); }; } /* namespace sax */ diff --git a/alib2xml/test-src/primitive/PrimitiveTest.cpp b/alib2xml/test-src/primitive/PrimitiveTest.cpp index ca2efbb4d1afab633d46c061d0dc1669255e4f01..8b1cd2a21e2032f55b60d0d48179e60d339682d8 100644 --- a/alib2xml/test-src/primitive/PrimitiveTest.cpp +++ b/alib2xml/test-src/primitive/PrimitiveTest.cpp @@ -24,11 +24,9 @@ void PrimitiveTest::testXMLParser() { { ext::deque<sax::Token> tokens = factory::XmlDataFactory::toTokens(primitive); std::cout << tokens << std::endl; - std::string tmp; - sax::SaxComposeInterface::printMemory(tmp, tokens); + std::string tmp = sax::SaxComposeInterface::composeMemory ( tokens ); - ext::deque<sax::Token> tokens2; - sax::SaxParseInterface::parseMemory(tmp, tokens2); + ext::deque<sax::Token> tokens2 = sax::SaxParseInterface::parseMemory ( tmp ); primitive::Primitive primitive2 = factory::XmlDataFactory::fromTokens (std::move(tokens2)); CPPUNIT_ASSERT( primitive == primitive2 ); diff --git a/alib2xml/test-src/sax/SaxTest.cpp b/alib2xml/test-src/sax/SaxTest.cpp index e3532c4236680c6244552976e16c4b3025c766f1..983fd15b8810b6676b5ff04bad71db2471a474bd 100644 --- a/alib2xml/test-src/sax/SaxTest.cpp +++ b/alib2xml/test-src/sax/SaxTest.cpp @@ -23,7 +23,7 @@ void SaxTest::testSax ( ) { std::cout << tokens << std::endl; std::string tmp2; - sax::SaxComposeInterface::printMemory ( tmp2, tokens ); + sax::SaxComposeInterface::composeMemory ( tmp2, tokens ); CPPUNIT_ASSERT ( tmp == tmp2 );