changed: added two new parameters to Generator class: template<class StreamType, bool is_pikotools_stream = false, bool is_autoescape_stream = false> class Generator

changed: added one new parameter to Outstreams class: template<class StreamType, bool is_pikotools_stream = false> class OutStreams
removed macros: EZC_GENERATOR_HAS_PT_STREAM, EZC_GENERATOR_HAS_WINIX_STREAM
This commit is contained in:
Tomasz Sowa 2021-07-12 23:00:11 +02:00
parent ae6a5c52a1
commit 44407c2a4b
2 changed files with 305 additions and 302 deletions

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (c) 2015, Tomasz Sowa * Copyright (c) 2015-2021, Tomasz Sowa
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -47,7 +47,7 @@ namespace Ezc
{ {
template<class StreamType> template<class StreamType, bool is_pikotools_stream = false>
class OutStreams class OutStreams
{ {
public: public:
@ -65,36 +65,35 @@ public:
~OutStreams(); ~OutStreams();
OutStreams(); OutStreams();
OutStreams(const OutStreams<StreamType> & o); OutStreams(const OutStreams & o);
OutStreams<StreamType> & operator=(const OutStreams<StreamType> & o); OutStreams & operator=(const OutStreams & o);
}; };
template<class StreamType> template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType>::~OutStreams() OutStreams<StreamType, is_pikotools_stream>::~OutStreams()
{ {
ClearTab(); ClearTab();
} }
template<class StreamType> template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType>::OutStreams() OutStreams<StreamType, is_pikotools_stream>::OutStreams()
{ {
} }
template<class StreamType> template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType>::OutStreams(const OutStreams<StreamType> & o) OutStreams<StreamType, is_pikotools_stream>::OutStreams(const OutStreams<StreamType, is_pikotools_stream> & o)
{ {
// we do not copy streams but creating new ones // we do not copy streams but creating new ones
ResizeTab(o.streams_tab.size()); ResizeTab(o.streams_tab.size());
} }
template<class StreamType> template<class StreamType, bool is_pikotools_stream>
OutStreams<StreamType> & OutStreams<StreamType>::operator=(const OutStreams<StreamType> & o) OutStreams<StreamType, is_pikotools_stream> & OutStreams<StreamType, is_pikotools_stream>::operator=(const OutStreams<StreamType, is_pikotools_stream> & o)
{ {
// we do not copy streams but creating new ones // we do not copy streams but creating new ones
streams_map.clear(); streams_map.clear();
@ -104,8 +103,8 @@ return *this;
} }
template<class StreamType> template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType>::ClearTab() void OutStreams<StreamType, is_pikotools_stream>::ClearTab()
{ {
for(size_t i=0 ; i<streams_tab.size() ; ++i) for(size_t i=0 ; i<streams_tab.size() ; ++i)
delete streams_tab[i]; delete streams_tab[i];
@ -115,8 +114,8 @@ void OutStreams<StreamType>::ClearTab()
} }
template<class StreamType> template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType>::ResizeTab(size_t len) void OutStreams<StreamType, is_pikotools_stream>::ResizeTab(size_t len)
{ {
if( streams_tab.size() != len ) if( streams_tab.size() != len )
{ {
@ -141,8 +140,8 @@ void OutStreams<StreamType>::ResizeTab(size_t len)
} }
template<class StreamType> template<class StreamType, bool is_pikotools_stream>
void OutStreams<StreamType>::ClearMap() void OutStreams<StreamType, is_pikotools_stream>::ClearMap()
{ {
typename StreamsMap::iterator i; typename StreamsMap::iterator i;
@ -150,12 +149,14 @@ void OutStreams<StreamType>::ClearMap()
{ {
StreamType & str = *(i->second); StreamType & str = *(i->second);
#ifdef EZC_GENERATOR_HAS_PT_STREAM if constexpr(is_pikotools_stream)
{
str.clear(); str.clear();
#else }
else
{
str.str(L""); str.str(L"");
#endif }
} }
streams_map.clear(); streams_map.clear();