added to HTMLParser: filter_file(...) methods for filtering from a file
This commit is contained in:
parent
5b2583b566
commit
f23cabfb2f
|
@ -140,8 +140,8 @@ HTMLParser::Status HTMLParser::parse_xml_file(const std::string & file_name, Spa
|
|||
HTMLParser::Status HTMLParser::parse_xml_file(const wchar_t * file_name, Space & out_space, bool compact_mode, bool clear_space)
|
||||
{
|
||||
std::string file_name_utf8;
|
||||
|
||||
wide_to_utf8(file_name, file_name_utf8);
|
||||
|
||||
return parse_xml_file(file_name_utf8.c_str(), out_space, compact_mode, clear_space);
|
||||
}
|
||||
|
||||
|
@ -174,18 +174,6 @@ void HTMLParser::Filter(const wchar_t * in, std::wstring & out)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void HTMLParser::Init()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void HTMLParser::Uninit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
void HTMLParser::Filter(const std::wstring & in, std::wstring & out)
|
||||
{
|
||||
if( &in == &out )
|
||||
|
@ -203,6 +191,77 @@ void HTMLParser::Filter(const std::wstring & in, std::wstring & out)
|
|||
}
|
||||
|
||||
|
||||
|
||||
HTMLParser::Status HTMLParser::filter_file(const char * file_name, std::wstring & out)
|
||||
{
|
||||
parsing_html = true;
|
||||
reading_from_file = true;
|
||||
|
||||
// open the file before clearing 'out' string, 'out' string can be the same string as the file_name
|
||||
file.clear();
|
||||
file.open(file_name, std::ios_base::binary | std::ios_base::in);
|
||||
|
||||
status = ok;
|
||||
line = 1;
|
||||
stack_len = 0;
|
||||
out_string = &out;
|
||||
out_space = nullptr;
|
||||
line_len = 0;
|
||||
out_string->clear();
|
||||
|
||||
if( file )
|
||||
{
|
||||
Init();
|
||||
Read();
|
||||
Uninit();
|
||||
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
status = cant_open_file;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
HTMLParser::Status HTMLParser::filter_file(const std::string & file_name, std::wstring & out)
|
||||
{
|
||||
return filter_file(file_name.c_str(), out);
|
||||
}
|
||||
|
||||
|
||||
HTMLParser::Status HTMLParser::filter_file(const wchar_t * file_name, std::wstring & out)
|
||||
{
|
||||
std::string file_name_utf8;
|
||||
pt::wide_to_utf8(file_name, file_name_utf8);
|
||||
|
||||
return filter_file(file_name_utf8, out);
|
||||
}
|
||||
|
||||
|
||||
HTMLParser::Status HTMLParser::filter_file(const std::wstring & file_name, std::wstring & out)
|
||||
{
|
||||
return filter_file(file_name.c_str(), out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void HTMLParser::Init()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void HTMLParser::Uninit()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int HTMLParser::get_last_parsed_line()
|
||||
{
|
||||
return line;
|
||||
|
|
|
@ -134,6 +134,11 @@ public:
|
|||
void Filter(const std::wstring & in, std::wstring & out);
|
||||
|
||||
|
||||
HTMLParser::Status filter_file(const char * file_name, std::wstring & out);
|
||||
HTMLParser::Status filter_file(const std::string & file_name, std::wstring & out);
|
||||
HTMLParser::Status filter_file(const wchar_t * file_name, std::wstring & out);
|
||||
HTMLParser::Status filter_file(const std::wstring & file_name, std::wstring & out);
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue