namespace PT renamed to pt

This commit is contained in:
Tomasz Sowa 2021-05-20 16:11:12 +02:00
parent 6f50626dda
commit b574289054
35 changed files with 628 additions and 641 deletions

View File

@ -38,7 +38,7 @@
#include "inttostr.h" #include "inttostr.h"
namespace PT namespace pt
{ {
std::string to_str(unsigned long long value, int base) std::string to_str(unsigned long long value, int base)

View File

@ -42,7 +42,7 @@
namespace PT namespace pt
{ {

View File

@ -38,7 +38,7 @@
#include "misc.h" #include "misc.h"
namespace PT namespace pt
{ {

View File

@ -42,7 +42,7 @@
#include "text.h" #include "text.h"
namespace PT namespace pt
{ {
void SetOverflow(bool * was_overflow, bool val); void SetOverflow(bool * was_overflow, bool val);

View File

@ -44,7 +44,7 @@
namespace PT namespace pt
{ {
template<typename CharType, typename StrType> template<typename CharType, typename StrType>

View File

@ -43,7 +43,7 @@
#include "misc.h" #include "misc.h"
namespace PT namespace pt
{ {

View File

@ -40,7 +40,7 @@
#include "text_private.h" #include "text_private.h"
namespace PT namespace pt
{ {
// white_chars table should be sorted (a binary search algorithm is used to find a character) // white_chars table should be sorted (a binary search algorithm is used to find a character)

View File

@ -41,7 +41,7 @@
#include <string> #include <string>
namespace PT namespace pt
{ {
bool is_white(wchar_t c, bool check_additional_chars = true, bool treat_new_line_as_white = true); bool is_white(wchar_t c, bool check_additional_chars = true, bool treat_new_line_as_white = true);

View File

@ -42,7 +42,7 @@
#include "text.h" #include "text.h"
namespace PT namespace pt
{ {
namespace pt_private namespace pt_private
@ -302,7 +302,7 @@ bool is_substr_nc_generic(const StringType1 * short_str, const StringType2 * lon
} // namespace pt_private } // namespace pt_private
} // namespace PT } // namespace pt
#endif #endif

View File

@ -40,7 +40,7 @@
namespace PT namespace pt
{ {
@ -81,7 +81,7 @@ CSVParser::Status CSVParser::parse_file(const wchar_t * file_name, Space & out_s
{ {
std::string file_name_utf8; std::string file_name_utf8;
PT::WideToUTF8(file_name, file_name_utf8); WideToUTF8(file_name, file_name_utf8);
return parse_file(file_name_utf8.c_str(), out_space); return parse_file(file_name_utf8.c_str(), out_space);
} }
@ -295,7 +295,7 @@ bool correct;
do do
{ {
PT::UTF8ToInt(file, c, correct); UTF8ToInt(file, c, correct);
if( !file ) if( !file )
return lastc; return lastc;
@ -348,7 +348,7 @@ bool correct;
do do
{ {
size_t len = PT::UTF8ToInt(pchar_ascii, c, correct); size_t len = UTF8ToInt(pchar_ascii, c, correct);
pchar_ascii += len; pchar_ascii += len;
} }
while( *pchar_ascii && !correct ); while( *pchar_ascii && !correct );

View File

@ -43,7 +43,7 @@
#include <fstream> #include <fstream>
namespace PT namespace pt
{ {
/* /*

View File

@ -41,7 +41,7 @@
#include <string.h> #include <string.h>
namespace PT namespace pt
{ {

View File

@ -44,7 +44,7 @@
namespace PT namespace pt
{ {

View File

@ -39,7 +39,7 @@
namespace PT namespace pt
{ {
@ -74,7 +74,7 @@ void FileLog::init(const std::wstring & log_file, bool log_stdout, int log_level
this->log_stdout = log_stdout; this->log_stdout = log_stdout;
this->log_level = log_level; this->log_level = log_level;
this->save_each_line = save_each_line; this->save_each_line = save_each_line;
PT::WideToUTF8(log_file, this->log_file); WideToUTF8(log_file, this->log_file);
} }
@ -100,7 +100,7 @@ void FileLog::open_file()
} }
void FileLog::save_log(PT::WTextStream * buffer) void FileLog::save_log(WTextStream * buffer)
{ {
if( buffer->empty() ) if( buffer->empty() )
return; return;
@ -111,7 +111,7 @@ void FileLog::save_log(PT::WTextStream * buffer)
{ {
if( log_stdout ) if( log_stdout )
{ {
PT::WideStreamToUTF8(*buffer, std::cout); WideStreamToUTF8(*buffer, std::cout);
} }
if( !log_file.empty() ) if( !log_file.empty() )
@ -126,7 +126,7 @@ void FileLog::save_log(PT::WTextStream * buffer)
if( file ) if( file )
{ {
PT::WideStreamToUTF8(*buffer, file); WideStreamToUTF8(*buffer, file);
file.flush(); file.flush();
} }
} }

View File

@ -42,7 +42,7 @@
#include "textstream/textstream.h" #include "textstream/textstream.h"
namespace PT namespace pt
{ {
@ -55,7 +55,7 @@ public:
virtual ~FileLog(); virtual ~FileLog();
virtual void init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line); virtual void init(const std::wstring & log_file, bool log_stdout, int log_level, bool save_each_line);
virtual void save_log(PT::WTextStream * buffer); virtual void save_log(WTextStream * buffer);
virtual int get_log_level(); virtual int get_log_level();
virtual bool should_save_each_line(); virtual bool should_save_each_line();

View File

@ -45,7 +45,7 @@
#include "morm.h" #include "morm.h"
#endif #endif
namespace PT namespace pt
{ {
@ -73,13 +73,13 @@ Log::~Log()
} }
void Log::SetLogBuffer(PT::WTextStream * buffer) void Log::SetLogBuffer(WTextStream * buffer)
{ {
this->buffer = buffer; this->buffer = buffer;
} }
PT::WTextStream * Log::GetLogBuffer() WTextStream * Log::GetLogBuffer()
{ {
return buffer; return buffer;
} }
@ -136,7 +136,7 @@ Log & Log::operator<<(const char * s)
{ {
if( buffer && file_log && s && current_level <= file_log->get_log_level() ) if( buffer && file_log && s && current_level <= file_log->get_log_level() )
{ {
PT::UTF8ToWide(s, *buffer, false); UTF8ToWide(s, *buffer, false);
} }
return *this; return *this;
@ -148,7 +148,7 @@ Log & Log::operator<<(const std::string & s)
{ {
if( buffer && file_log && current_level <= file_log->get_log_level() ) if( buffer && file_log && current_level <= file_log->get_log_level() )
{ {
PT::UTF8ToWide(s, *buffer, false); UTF8ToWide(s, *buffer, false);
} }
return *this; return *this;
@ -160,7 +160,7 @@ Log & Log::operator<<(const std::string * s)
{ {
if( buffer && file_log && current_level <= file_log->get_log_level() ) if( buffer && file_log && current_level <= file_log->get_log_level() )
{ {
PT::UTF8ToWide(*s, *buffer, false); UTF8ToWide(*s, *buffer, false);
} }
return *this; return *this;
@ -290,7 +290,7 @@ Log & Log::operator<<(double s)
Log & Log::operator<<(const PT::Space & s) Log & Log::operator<<(const Space & s)
{ {
if( buffer && file_log && current_level <= file_log->get_log_level() ) if( buffer && file_log && current_level <= file_log->get_log_level() )
{ {
@ -302,7 +302,7 @@ Log & Log::operator<<(const PT::Space & s)
Log & Log::operator<<(const PT::Date & date) Log & Log::operator<<(const Date & date)
{ {
if( buffer && file_log && current_level <= file_log->get_log_level() ) if( buffer && file_log && current_level <= file_log->get_log_level() )
{ {

View File

@ -51,7 +51,7 @@ namespace morm
} }
namespace PT namespace pt
{ {
@ -93,8 +93,8 @@ public:
Log(); Log();
virtual ~Log(); virtual ~Log();
virtual void SetLogBuffer(PT::WTextStream * buffer); virtual void SetLogBuffer(WTextStream * buffer);
virtual PT::WTextStream * GetLogBuffer(); virtual WTextStream * GetLogBuffer();
void SetFileLog(FileLog * file_log); void SetFileLog(FileLog * file_log);
FileLog * GetFileLog(); FileLog * GetFileLog();
@ -128,8 +128,8 @@ public:
//virtual Log & operator<<(float s); // added //virtual Log & operator<<(float s); // added
virtual Log & operator<<(double s); virtual Log & operator<<(double s);
virtual Log & operator<<(const PT::Space & space); virtual Log & operator<<(const Space & space);
virtual Log & operator<<(const PT::Date & date); virtual Log & operator<<(const Date & date);
#ifdef PT_HAS_MORM #ifdef PT_HAS_MORM
virtual Log & operator<<(morm::Model & model); virtual Log & operator<<(morm::Model & model);
@ -145,7 +145,7 @@ public:
template<typename char_type, size_t stack_size, size_t heap_block_size> template<typename char_type, size_t stack_size, size_t heap_block_size>
Log & operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf); Log & operator<<(const TextStreamBase<char_type, stack_size, heap_block_size> & buf);
@ -157,7 +157,7 @@ public:
protected: protected:
// buffer for the log // buffer for the log
PT::WTextStream * buffer; WTextStream * buffer;
// file logger // file logger
FileLog * file_log; FileLog * file_log;
@ -205,7 +205,7 @@ Log & Log::log_string_generic(const StringType & value, size_t max_size)
template<typename char_type, size_t stack_size, size_t heap_block_size> template<typename char_type, size_t stack_size, size_t heap_block_size>
Log & Log::operator<<(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & buf) Log & Log::operator<<(const TextStreamBase<char_type, stack_size, heap_block_size> & buf)
{ {
if( buffer && file_log && current_level <= file_log->get_log_level() ) if( buffer && file_log && current_level <= file_log->get_log_level() )
{ {

View File

@ -42,7 +42,7 @@
namespace PT namespace pt
{ {
@ -165,7 +165,7 @@ void MainOptionsParser::convert_str(const char * src, std::wstring & dst)
{ {
if( should_use_utf8 ) if( should_use_utf8 )
{ {
PT::UTF8ToWide(src, dst); UTF8ToWide(src, dst);
} }
else else
{ {
@ -181,7 +181,7 @@ void MainOptionsParser::convert_str(const char * src, size_t len, std::wstring &
{ {
if( should_use_utf8 ) if( should_use_utf8 )
{ {
PT::UTF8ToWide(src, len, dst); UTF8ToWide(src, len, dst);
} }
else else
{ {

View File

@ -43,7 +43,7 @@
#include <vector> #include <vector>
namespace PT namespace pt
{ {

View File

@ -41,7 +41,7 @@
#include <iostream> #include <iostream>
namespace PT namespace pt
{ {
/* /*

View File

@ -42,7 +42,7 @@
#include "convert/convert.h" #include "convert/convert.h"
namespace PT namespace pt
{ {
Space::Space() Space::Space()
@ -922,7 +922,7 @@ std::string Space::to_str() const
if( type == type_wstring ) if( type == type_wstring )
{ {
PT::TextStream stream; TextStream stream;
serialize_string_buffer(value.value_wstring.c_str(), stream, Escape::no_escape); serialize_string_buffer(value.value_wstring.c_str(), stream, Escape::no_escape);
stream.to_string(str); stream.to_string(str);
return str; return str;
@ -942,7 +942,7 @@ std::wstring Space::to_wstr() const
if( type == type_string ) if( type == type_string )
{ {
PT::UTF8ToWide(value.value_string, str); UTF8ToWide(value.value_string, str);
return str; return str;
} }
@ -1277,7 +1277,7 @@ std::wstring Space::serialize_to_space_wstr(bool pretty_print) const
void Space::serialize_to_space_to(std::string & str, bool pretty_print) const void Space::serialize_to_space_to(std::string & str, bool pretty_print) const
{ {
PT::TextStream stream; TextStream stream;
serialize_to_space_stream(stream, pretty_print); serialize_to_space_stream(stream, pretty_print);
stream.to_string(str); stream.to_string(str);
@ -1286,7 +1286,7 @@ void Space::serialize_to_space_to(std::string & str, bool pretty_print) const
void Space::serialize_to_space_to(std::wstring & str, bool pretty_print) const void Space::serialize_to_space_to(std::wstring & str, bool pretty_print) const
{ {
PT::WTextStream stream; WTextStream stream;
serialize_to_space_stream(stream, pretty_print); serialize_to_space_stream(stream, pretty_print);
stream.to_string(str); stream.to_string(str);
@ -1312,7 +1312,7 @@ std::wstring Space::serialize_to_json_wstr() const
void Space::serialize_to_json_to(std::string & str) const void Space::serialize_to_json_to(std::string & str) const
{ {
PT::TextStream stream; TextStream stream;
serialize_to_json_stream(stream); serialize_to_json_stream(stream);
stream.to_string(str); stream.to_string(str);
@ -1321,7 +1321,7 @@ void Space::serialize_to_json_to(std::string & str) const
void Space::serialize_to_json_to(std::wstring & str) const void Space::serialize_to_json_to(std::wstring & str) const
{ {
PT::WTextStream stream; WTextStream stream;
serialize_to_json_stream(stream); serialize_to_json_stream(stream);
stream.to_string(str); stream.to_string(str);
@ -1429,7 +1429,7 @@ bool Space::has_value(const char * val) const
{ {
for(size_t i=0 ; i < value.value_table.size() ; ++i) for(size_t i=0 ; i < value.value_table.size() ; ++i)
{ {
PT::Space * table_item = value.value_table[i]; Space * table_item = value.value_table[i];
if( table_item->type == type_string ) if( table_item->type == type_string )
{ {
@ -1459,7 +1459,7 @@ bool Space::has_value(const wchar_t * val) const
{ {
for(size_t i=0 ; i < value.value_table.size() ; ++i) for(size_t i=0 ; i < value.value_table.size() ; ++i)
{ {
PT::Space * table_item = value.value_table[i]; Space * table_item = value.value_table[i];
if( table_item->type == type_wstring ) if( table_item->type == type_wstring )
{ {
@ -1934,7 +1934,7 @@ void Space::remove_child_space(const wchar_t * name)
{ {
for(size_t i=0 ; i<child_spaces->size() ; ) for(size_t i=0 ; i<child_spaces->size() ; )
{ {
PT::Space * child = (*child_spaces)[i]; Space * child = (*child_spaces)[i];
if( child->name && (*child->name) == name ) if( child->name && (*child->name) == name )
{ {
@ -1960,7 +1960,7 @@ void Space::remove_child_space(size_t index)
{ {
if( child_spaces && index < child_spaces->size() ) if( child_spaces && index < child_spaces->size() )
{ {
PT::Space * child = (*child_spaces)[index]; Space * child = (*child_spaces)[index];
delete child; delete child;
child = nullptr; child = nullptr;

View File

@ -50,7 +50,7 @@
namespace PT namespace pt
{ {
@ -915,7 +915,7 @@ protected:
wchar_t buffer[50]; wchar_t buffer[50];
size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); size_t buffer_len = sizeof(buffer) / sizeof(wchar_t);
PT::Toa(value.value_long, buffer, buffer_len); Toa(value.value_long, buffer, buffer_len);
serialize_string_buffer(buffer, str, Escape::escape_space); serialize_string_buffer(buffer, str, Escape::escape_space);
} }
@ -1095,7 +1095,7 @@ protected:
wchar_t buffer[50]; wchar_t buffer[50];
size_t buffer_len = sizeof(buffer) / sizeof(wchar_t); size_t buffer_len = sizeof(buffer) / sizeof(wchar_t);
PT::Toa(value.value_long, buffer, buffer_len); Toa(value.value_long, buffer, buffer_len);
serialize_string_buffer(buffer, str, Escape::escape_json); serialize_string_buffer(buffer, str, Escape::escape_json);
} }

View File

@ -42,7 +42,7 @@
#include "convert/strtoint.h" #include "convert/strtoint.h"
namespace PT namespace pt
{ {
@ -145,7 +145,7 @@ SpaceParser::Status SpaceParser::ParseJSONFile(const wchar_t * file_name)
{ {
std::string file_name_utf8; std::string file_name_utf8;
PT::WideToUTF8(file_name, file_name_utf8); WideToUTF8(file_name, file_name_utf8);
return ParseJSONFile(file_name_utf8.c_str()); return ParseJSONFile(file_name_utf8.c_str());
} }
@ -195,7 +195,7 @@ SpaceParser::Status SpaceParser::ParseSpaceFile(const wchar_t * file_name)
{ {
std::string file_name_utf8; std::string file_name_utf8;
PT::WideToUTF8(file_name, file_name_utf8); WideToUTF8(file_name, file_name_utf8);
return ParseSpaceFile(file_name_utf8.c_str()); return ParseSpaceFile(file_name_utf8.c_str());
} }
@ -972,7 +972,7 @@ bool correct;
do do
{ {
PT::UTF8ToInt(file, c, correct); UTF8ToInt(file, c, correct);
if( !file ) if( !file )
return lastc; return lastc;
@ -1025,7 +1025,7 @@ bool correct;
do do
{ {
size_t len = PT::UTF8ToInt(pchar_ascii, c, correct); size_t len = UTF8ToInt(pchar_ascii, c, correct);
pchar_ascii += len; pchar_ascii += len;
} }
while( *pchar_ascii && !correct ); while( *pchar_ascii && !correct );

View File

@ -43,7 +43,7 @@
namespace PT namespace pt
{ {

View File

@ -49,7 +49,7 @@
// for snprintf // for snprintf
#include <cstdio> #include <cstdio>
namespace PT namespace pt
{ {
@ -109,8 +109,8 @@ public:
TextStreamBase & operator<<(unsigned long long); TextStreamBase & operator<<(unsigned long long);
TextStreamBase & operator<<(double); TextStreamBase & operator<<(double);
TextStreamBase & operator<<(const void *); // printing a pointer TextStreamBase & operator<<(const void *); // printing a pointer
TextStreamBase & operator<<(const PT::Space & space); TextStreamBase & operator<<(const Space & space);
TextStreamBase & operator<<(const PT::Date & date); TextStreamBase & operator<<(const Date & date);
// min width for integer output // min width for integer output
// if the output value has less digits then first zeroes are added // if the output value has less digits then first zeroes are added
@ -469,7 +469,7 @@ wchar_t buf[100];
template<typename char_type, size_t stack_size, size_t heap_block_size> template<typename char_type, size_t stack_size, size_t heap_block_size>
TextStreamBase<char_type, stack_size, heap_block_size> & TextStreamBase<char_type, stack_size, heap_block_size> &
TextStreamBase<char_type, stack_size, heap_block_size>::operator<<(const PT::Space & space) TextStreamBase<char_type, stack_size, heap_block_size>::operator<<(const Space & space)
{ {
space.serialize_to_space_stream(*this, true); space.serialize_to_space_stream(*this, true);
@ -480,7 +480,7 @@ return *this;
template<typename char_type, size_t stack_size, size_t heap_block_size> template<typename char_type, size_t stack_size, size_t heap_block_size>
TextStreamBase<char_type, stack_size, heap_block_size> & TextStreamBase<char_type, stack_size, heap_block_size> &
TextStreamBase<char_type, stack_size, heap_block_size>::operator<<(const PT::Date & date) TextStreamBase<char_type, stack_size, heap_block_size>::operator<<(const Date & date)
{ {
date.Serialize(*this); date.Serialize(*this);

View File

@ -40,7 +40,7 @@
namespace PT namespace pt
{ {

View File

@ -40,7 +40,7 @@
namespace PT namespace pt
{ {

View File

@ -42,7 +42,7 @@
#include "textstream/textstream.h" #include "textstream/textstream.h"
namespace PT namespace pt
{ {
/*! /*!

View File

@ -38,7 +38,7 @@
#include "utf8_private.h" #include "utf8_private.h"
namespace PT namespace pt
{ {
namespace private_namespace namespace private_namespace
@ -277,7 +277,7 @@ return chars;
} // namespace private_namespace } // namespace private_namespace
} // namespace PT } // namespace pt

View File

@ -41,7 +41,7 @@
#include "textstream/textstream.h" #include "textstream/textstream.h"
namespace PT namespace pt
{ {
bool UTF8_CheckRange(int c); bool UTF8_CheckRange(int c);
@ -138,7 +138,7 @@ bool correct, was_error = false;
} }
else else
{ {
len = PT::UTF8ToInt(utf8, utf8_len, z, correct); // the len will be different from zero len = pt::UTF8ToInt(utf8, utf8_len, z, correct); // the len will be different from zero
} }
if( !correct ) if( !correct )
@ -215,6 +215,6 @@ void WideToUTF8Generic(TextStreamBase<char_type, stack_size, heap_block_size> &
} // namespace private_namespace } // namespace private_namespace
} // namespace PT } // namespace pt
#endif #endif

View File

@ -43,7 +43,7 @@
#include "utf8_private.h" #include "utf8_private.h"
namespace PT namespace pt
{ {
@ -263,7 +263,7 @@ void WideStreamToUTF8(StreamTypeIn & buffer, StreamTypeOut & utf8, int mode)
} // namespace PT } // namespace pt
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -46,14 +46,10 @@ namespace pt_convert_tests
void make_tests(); void make_tests();
} }
} }

View File

@ -44,14 +44,11 @@
namespace pt namespace pt
{ {
// remove me in the future (when PT will be changed to pt)
using namespace PT;
namespace pt_csvparser_tests namespace pt_csvparser_tests
{ {
void test_csvparser(const char * input_str, const char * expected_json) void test_csvparser(const char * input_str, const char * expected_json)
{ {
CSVParser csv_parser; CSVParser csv_parser;

View File

@ -45,13 +45,10 @@
namespace pt namespace pt
{ {
// remove me in the future (when PT will be changed to pt)
using namespace PT;
namespace pt_mainoptions_tests namespace pt_mainoptions_tests
{ {
struct MainOptionsParserOutputTest struct MainOptionsParserOutputTest
{ {
MainOptionsParser::Status status; MainOptionsParser::Status status;
@ -83,7 +80,7 @@ bool has_space_in_str(const char * arg)
{ {
while( *arg ) while( *arg )
{ {
if( PT::is_white((wchar_t)*arg) ) if( is_white((wchar_t)*arg) )
return true; return true;
arg += 1; arg += 1;