2021-06-20 14:13:23 +02:00
|
|
|
/*
|
|
|
|
* This file is a part of PikoTools
|
|
|
|
* and is distributed under the (new) BSD licence.
|
|
|
|
* Author: Tomasz Sowa <t.sowa@ttmath.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2021, Tomasz Sowa
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name Tomasz Sowa nor the names of contributors to this
|
|
|
|
* project may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
|
|
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef headerfile_picotools_textstream_stream
|
|
|
|
#define headerfile_picotools_textstream_stream
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
|
|
namespace pt
|
|
|
|
{
|
|
|
|
class Space;
|
|
|
|
class Date;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Stream
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~Stream() {};
|
|
|
|
|
|
|
|
virtual void clear() = 0;
|
|
|
|
virtual bool empty() const = 0;
|
|
|
|
virtual size_t size() const = 0;
|
|
|
|
virtual void reserve(size_t len) = 0;
|
|
|
|
virtual size_t capacity() const = 0;
|
|
|
|
|
2021-06-20 16:46:08 +02:00
|
|
|
virtual void to_str(std::string & str, bool clear_string = true) const = 0;
|
|
|
|
virtual void to_str(std::wstring & str, bool clear_string = true) const = 0;
|
|
|
|
|
|
|
|
virtual std::string to_str() const = 0;
|
|
|
|
virtual std::wstring to_wstr() const = 0;
|
2021-06-20 14:13:23 +02:00
|
|
|
|
|
|
|
virtual Stream & operator<<(const char * str) = 0;
|
|
|
|
virtual Stream & operator<<(const std::string & str) = 0;
|
|
|
|
|
|
|
|
virtual Stream & operator<<(const wchar_t * str) = 0;
|
|
|
|
virtual Stream & operator<<(const std::wstring & str) = 0;
|
|
|
|
|
|
|
|
virtual Stream & operator<<(char) = 0;
|
|
|
|
virtual Stream & operator<<(unsigned char) = 0;
|
|
|
|
virtual Stream & operator<<(wchar_t) = 0;
|
|
|
|
virtual Stream & operator<<(bool) = 0;
|
|
|
|
virtual Stream & operator<<(short) = 0;
|
|
|
|
virtual Stream & operator<<(int) = 0;
|
|
|
|
virtual Stream & operator<<(long) = 0;
|
|
|
|
virtual Stream & operator<<(long long) = 0;
|
|
|
|
virtual Stream & operator<<(unsigned short) = 0;
|
|
|
|
virtual Stream & operator<<(unsigned int) = 0;
|
|
|
|
virtual Stream & operator<<(unsigned long) = 0;
|
|
|
|
virtual Stream & operator<<(unsigned long long) = 0;
|
|
|
|
virtual Stream & operator<<(float) = 0;
|
|
|
|
virtual Stream & operator<<(double) = 0;
|
|
|
|
virtual Stream & operator<<(long double) = 0;
|
|
|
|
virtual Stream & operator<<(const void *) = 0; // printing a pointer
|
|
|
|
virtual Stream & operator<<(const Space & space) = 0;
|
|
|
|
virtual Stream & operator<<(const Date & date) = 0;
|
|
|
|
|
added to Space: long double to Space::Value and methods for converting from/to long double
added global methods for converting float/string double/string and long double/string (convert/double.h|cpp):
float to_float(const char * str, const char ** after = nullptr);
float to_float(const wchar_t * str, const wchar_t ** after = nullptr);
double to_double(const char * str, const char ** after = nullptr);
double to_double(const wchar_t * str, const wchar_t ** after = nullptr);
long double to_long_double(const char * str, const char ** after = nullptr);
long double to_long_double(const wchar_t * str, const wchar_t ** after = nullptr);
float to_float(const std::string & str, const char ** after = nullptr);
float to_float(const std::wstring & str, const wchar_t ** after = nullptr);
double to_double(const std::string & str, const char ** after = nullptr);
double to_double(const std::wstring & str, const wchar_t ** after = nullptr);
long double to_long_double(const std::string & str, const char ** after = nullptr);
long double to_long_double(const std::wstring & str, const wchar_t ** after = nullptr);
std::string to_str(float val);
std::wstring to_wstr(float val);
std::string to_str(double val);
std::wstring to_wstr(double val);
std::string to_str(long double val);
std::wstring to_wstr(long double val);
2021-06-23 17:01:43 +02:00
|
|
|
virtual char get_char(size_t index) const = 0;
|
|
|
|
virtual wchar_t get_wchar(size_t index) const = 0;
|
|
|
|
|
2021-06-20 14:13:23 +02:00
|
|
|
// min width for integer output
|
|
|
|
// if the output value has less digits then first zeroes are added
|
|
|
|
// (0 turn off)
|
|
|
|
//Stream & int_min_width(size_t min_width);
|
|
|
|
|
|
|
|
// template<typename arg_char_type, size_t arg_stack_size, size_t arg_heap_block_size>
|
|
|
|
// Stream & operator<<(const Stream<arg_char_type, arg_stack_size, arg_heap_block_size> & arg);
|
|
|
|
|
|
|
|
// template<typename in_buffer_type>
|
|
|
|
// Stream & write(const in_buffer_type * buf, size_t len);
|
|
|
|
|
|
|
|
// write double value in a specified format
|
|
|
|
// format is the same as in the snprintf function, e.g. write("%f", 10.0)
|
|
|
|
//virtual Stream & write(const char * format, double val) = 0;
|
|
|
|
//virtual Stream & write(const wchar_t * format, double val) = 0;
|
|
|
|
|
|
|
|
// what is it?
|
|
|
|
//Stream & fill_up_if_needed(wchar_t fill_up_char, size_t existing_length);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|