WIP: use pt::Stream instead of a template argument
This commit is contained in:
12 files changed
+777
-707
No files matched your search
+25
-31
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015-2021, Tomasz Sowa
|
||||
* Copyright (c) 2015-2024, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,6 +35,7 @@
|
||||
#ifndef headerfile_ezc_outstreams
|
||||
#define headerfile_ezc_outstreams
|
||||
|
||||
#include "textstream/stream.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
@@ -44,18 +45,17 @@ namespace Ezc
|
||||
{
|
||||
|
||||
|
||||
template<class StreamType, bool is_pikotools_stream = false>
|
||||
class OutStreams
|
||||
{
|
||||
public:
|
||||
|
||||
typedef std::map<std::wstring, StreamType*> StreamsMap;
|
||||
typedef std::vector<StreamType*> StreamsTab;
|
||||
typedef std::map<std::wstring, pt::Stream*> StreamsMap;
|
||||
typedef std::vector<pt::Stream*> StreamsTab;
|
||||
|
||||
StreamsMap streams_map;
|
||||
StreamsTab streams_tab;
|
||||
|
||||
void ResizeTab(size_t len);
|
||||
void ResizeTab(pt::Stream & stream_type, size_t len);
|
||||
|
||||
void ClearMap();
|
||||
void ClearTab();
|
||||
@@ -68,40 +68,35 @@ public:
|
||||
};
|
||||
|
||||
|
||||
template<class StreamType, bool is_pikotools_stream>
|
||||
OutStreams<StreamType, is_pikotools_stream>::~OutStreams()
|
||||
OutStreams::~OutStreams()
|
||||
{
|
||||
ClearTab();
|
||||
}
|
||||
|
||||
template<class StreamType, bool is_pikotools_stream>
|
||||
OutStreams<StreamType, is_pikotools_stream>::OutStreams()
|
||||
OutStreams::OutStreams()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class StreamType, bool is_pikotools_stream>
|
||||
OutStreams<StreamType, is_pikotools_stream>::OutStreams(const OutStreams<StreamType, is_pikotools_stream> & o)
|
||||
OutStreams::OutStreams(const OutStreams & o)
|
||||
{
|
||||
// we do not copy streams but creating new ones
|
||||
ResizeTab(o.streams_tab.size());
|
||||
//ResizeTab(o.streams_tab.size());
|
||||
}
|
||||
|
||||
|
||||
template<class StreamType, bool is_pikotools_stream>
|
||||
OutStreams<StreamType, is_pikotools_stream> & OutStreams<StreamType, is_pikotools_stream>::operator=(const OutStreams<StreamType, is_pikotools_stream> & o)
|
||||
OutStreams & OutStreams::operator=(const OutStreams & o)
|
||||
{
|
||||
// we do not copy streams but creating new ones
|
||||
streams_map.clear();
|
||||
ResizeTab(o.streams_tab.size());
|
||||
//ResizeTab(o.streams_tab.size());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class StreamType, bool is_pikotools_stream>
|
||||
void OutStreams<StreamType, is_pikotools_stream>::ClearTab()
|
||||
void OutStreams::ClearTab()
|
||||
{
|
||||
for(size_t i=0 ; i<streams_tab.size() ; ++i)
|
||||
delete streams_tab[i];
|
||||
@@ -111,8 +106,7 @@ void OutStreams<StreamType, is_pikotools_stream>::ClearTab()
|
||||
}
|
||||
|
||||
|
||||
template<class StreamType, bool is_pikotools_stream>
|
||||
void OutStreams<StreamType, is_pikotools_stream>::ResizeTab(size_t len)
|
||||
void OutStreams::ResizeTab(pt::Stream & stream_type, size_t len)
|
||||
{
|
||||
if( streams_tab.size() != len )
|
||||
{
|
||||
@@ -122,7 +116,7 @@ void OutStreams<StreamType, is_pikotools_stream>::ResizeTab(size_t len)
|
||||
streams_tab.resize(len);
|
||||
|
||||
for( ; i<streams_tab.size() ; ++i)
|
||||
streams_tab[i] = new StreamType();
|
||||
streams_tab[i] = stream_type.new_empty();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -137,23 +131,23 @@ void OutStreams<StreamType, is_pikotools_stream>::ResizeTab(size_t len)
|
||||
}
|
||||
|
||||
|
||||
template<class StreamType, bool is_pikotools_stream>
|
||||
void OutStreams<StreamType, is_pikotools_stream>::ClearMap()
|
||||
void OutStreams::ClearMap()
|
||||
{
|
||||
typename StreamsMap::iterator i;
|
||||
|
||||
for(i=streams_map.begin() ; i != streams_map.end() ; ++i)
|
||||
{
|
||||
StreamType & str = *(i->second);
|
||||
pt::Stream & str = *(i->second);
|
||||
str.clear();
|
||||
|
||||
if constexpr(is_pikotools_stream)
|
||||
{
|
||||
str.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
str.str(L"");
|
||||
}
|
||||
// if constexpr(is_pikotools_stream)
|
||||
// {
|
||||
// str.clear();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// str.str(L"");
|
||||
// }
|
||||
}
|
||||
|
||||
streams_map.clear();
|
||||
|
||||
Reference in new issue
Block a user