From 248dbddfdf0c6b424621ec09f00fe112483d9ec7 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Fri, 21 Nov 2008 04:13:33 +0000 Subject: [PATCH] Some MORE refactoring of Athenasub (-_-), which includes breaking loading of files. Originally committed to SVN as r2472. --- athenasub/athenasub_2008.vcproj | 18 ++++++- athenasub/include/athenasub/interfaces.h | 13 +++-- athenasub/src/controller.cpp | 29 +++++++++--- athenasub/src/format_handler.h | 4 +- athenasub/src/format_manager.cpp | 46 +++++++++++++++--- athenasub/src/format_manager.h | 9 ++-- athenasub/src/formats/format_ass.cpp | 25 ++++++++-- athenasub/src/formats/format_ass.h | 6 ++- athenasub/src/model.cpp | 8 ++-- athenasub/src/model.h | 5 +- athenasub/src/reader.cpp | 57 ++++++++++++++++++++++ athenasub/src/reader.h | 60 ++++++++++++++++++++++++ athenasub/src/section_entry_dialogue.h | 3 +- athenasub/src/section_entry_style.h | 3 +- athenasub/src/text_reader_cache.cpp | 2 +- athenasub/src/writer.cpp | 53 +++++++++++++++++++++ athenasub/src/writer.h | 58 +++++++++++++++++++++++ unit_test/unit_test.vcproj | 3 ++ 18 files changed, 361 insertions(+), 41 deletions(-) create mode 100644 athenasub/src/reader.cpp create mode 100644 athenasub/src/reader.h create mode 100644 athenasub/src/writer.cpp create mode 100644 athenasub/src/writer.h diff --git a/athenasub/athenasub_2008.vcproj b/athenasub/athenasub_2008.vcproj index c714e22c8..d4f569ed2 100644 --- a/athenasub/athenasub_2008.vcproj +++ b/athenasub/athenasub_2008.vcproj @@ -328,7 +328,7 @@ > + + + + @@ -487,6 +495,14 @@ RelativePath=".\src\text_writer.h" > + + + + diff --git a/athenasub/include/athenasub/interfaces.h b/athenasub/include/athenasub/interfaces.h index 98c4ab092..7650aa55d 100644 --- a/athenasub/include/athenasub/interfaces.h +++ b/athenasub/include/athenasub/interfaces.h @@ -49,6 +49,8 @@ namespace Athenasub { // Prototypes class Range; + class Reader; + class Writer; class ISelection; class IController; class IView; @@ -113,7 +115,7 @@ namespace Athenasub { virtual void DispatchNotifications(Notification notification) const = 0; virtual void Clear() = 0; - virtual void Load(wxInputStream &input,Format format=Format(),const String encoding="") = 0; + virtual void Load(Reader &input,Format format=Format()) = 0; virtual Section AddSection(String name) = 0; virtual Section GetMutableSection(String name) = 0; @@ -125,7 +127,7 @@ namespace Athenasub { virtual Controller CreateController() = 0; virtual void AddListener(View listener) = 0; - virtual void Save(wxOutputStream &output,Format format=Format(),const String encoding="UTF-8") const = 0; + virtual void Save(Writer &output,Format format=Format()) const = 0; virtual String GetUndoMessage(const String owner="") const = 0; virtual String GetRedoMessage(const String owner="") const = 0; @@ -316,6 +318,9 @@ namespace Athenasub { virtual Dialogue CreateDialogue() const = 0; virtual Style CreateStyle() const = 0; + + virtual bool IsBinary() const = 0; + virtual float CanReadFile(Reader &reader) const = 0; // Should return a float from 0.0f to 1.0f indicating how certain it is that it can read it }; @@ -324,8 +329,8 @@ namespace Athenasub { public: virtual ~IFormatHandler() {} - virtual void Load(IModel &model,wxInputStream &file,const String encoding) = 0; - virtual void Save(const IModel &model,wxOutputStream &file,const String encoding) const = 0; + virtual void Load(IModel &model,Reader &file) = 0; + virtual void Save(const IModel &model,Writer &file) const = 0; }; diff --git a/athenasub/src/controller.cpp b/athenasub/src/controller.cpp index ac50e7684..82c4926da 100644 --- a/athenasub/src/controller.cpp +++ b/athenasub/src/controller.cpp @@ -38,6 +38,8 @@ #include "actionlist.h" #include "format_manager.h" #include "selection.h" +#include "reader.h" +#include "writer.h" using namespace Athenasub; @@ -61,9 +63,24 @@ ActionList CController::CreateActionList(const String title,const String owner,b // Load a file void CController::LoadFile(const String filename,const String encoding) { - const Format handler = FormatManager::GetFormatFromFilename(filename,true); - wxFFileInputStream stream(filename.GetWxString()); - model->Load(stream,handler,encoding); + Reader reader(filename,encoding); + std::vector handlers = FormatManager::GetCompatibleFormatList(reader); + size_t len = handlers.size(); + bool success = false; + for (size_t i=0;iLoad(reader,handlers[i]); + success = true; + break; + } catch (Athenasub::Exception &e) { + // Ignore exception + (void) e; + } + } + + if (!success) { + THROW_ATHENA_EXCEPTION_MSG(Exception::No_Format_Handler,"Could not locate a suitable format handler."); + } } @@ -71,9 +88,9 @@ void CController::LoadFile(const String filename,const String encoding) // Save a file void CController::SaveFile(const String filename,const String encoding) { - const Format handler = FormatManager::GetFormatFromFilename(filename,true); - wxFFileOutputStream stream(filename.GetWxString()); - model->Save(stream,handler,encoding); + Format handler = FormatManager::GetFormatFromFilename(filename,true); + Writer writer(filename,encoding); + model->Save(writer,handler); } diff --git a/athenasub/src/format_handler.h b/athenasub/src/format_handler.h index 3b5f5e955..526c57f40 100644 --- a/athenasub/src/format_handler.h +++ b/athenasub/src/format_handler.h @@ -55,8 +55,8 @@ namespace Athenasub { public: //CFormatHandler(IModel& _model) : model(_model) {} - virtual void Load(IModel &model,wxInputStream &file,const String encoding) = 0; - virtual void Save(const IModel &model,wxOutputStream &file,const String encoding) const = 0; + virtual void Load(IModel &model,Reader &file) = 0; + virtual void Save(const IModel &model,Writer &file) const = 0; }; } diff --git a/athenasub/src/format_manager.cpp b/athenasub/src/format_manager.cpp index 9b7750203..1d98b1f7e 100644 --- a/athenasub/src/format_manager.cpp +++ b/athenasub/src/format_manager.cpp @@ -35,6 +35,8 @@ #include "format_manager.h" #include "formats/format_ass.h" +#include "reader.h" +#include "text_reader.h" #include using namespace Athenasub; @@ -56,9 +58,9 @@ void FormatManager::AddFormat(const Format format) // Initialize all built-in formats void FormatManager::InitializeFormats() { - formats.push_back(Format(new FormatASS())); - formats.push_back(Format(new FormatSSA())); - formats.push_back(Format(new FormatASS2())); + AddFormat(Format(new FormatASS())); + AddFormat(Format(new FormatSSA())); + AddFormat(Format(new FormatASS2())); } @@ -80,7 +82,7 @@ int FormatManager::GetFormatCount() //////////// // By index -const Format FormatManager::GetFormatByIndex(const int index) +Format FormatManager::GetFormatByIndex(const int index) { try { return formats.at(index); @@ -93,7 +95,7 @@ const Format FormatManager::GetFormatByIndex(const int index) /////////////// // By filename -const Format FormatManager::GetFormatFromFilename(const String &filename,bool read) +Format FormatManager::GetFormatFromFilename(const String &filename,bool read) { size_t len = formats.size(); for (size_t i=0;i FormatManager::GetCompatibleFormatList(Reader &reader) +{ + // Find all compatible formats and store them with their certainty + std::vector > results; + size_t len = formats.size(); + for (size_t i=0;iCanReadFile(reader); + if (certainty > 0.0f) { + results.push_back(std::pair(certainty,formats[i])); + } + } + + // Functor to sort them + struct Comp { + bool operator() (const std::pair &p1,const std::pair &p2) { + return p1.first > p2.first; + } + }; + + // Sort results and store them + sort(results.begin(),results.end(),Comp()); + len = results.size(); + std::vector finalResults; + for (size_t i=0;i GetCompatibleFormatList(Reader &reader); }; } diff --git a/athenasub/src/formats/format_ass.cpp b/athenasub/src/formats/format_ass.cpp index 9a99aecb4..d8f23b79c 100644 --- a/athenasub/src/formats/format_ass.cpp +++ b/athenasub/src/formats/format_ass.cpp @@ -39,7 +39,9 @@ #include "format_ass_plain.h" #include "version.h" #include "../text_reader.h" +#include "../reader.h" #include "../text_writer.h" +#include "../writer.h" #include #include #include @@ -88,6 +90,19 @@ StringArray FormatASS2::GetWriteExtensions() const } + +////////////////////////////////// +// Check if it can read this file +float FormatASSFamily::CanReadFile(Reader &reader) const +{ + shared_ptr file = reader.GetTextReader(); + if (!file->HasMoreLines()) return 0; + String line = file->ReadLineFromFile(); + if (line == "[Script Info]") return 1; + return 0; +} + + /////////////// // Constructor FormatHandlerASS::FormatHandlerASS(int version) @@ -105,10 +120,10 @@ FormatHandlerASS::~FormatHandlerASS() /////////////// // Load a file -void FormatHandlerASS::Load(IModel &model,wxInputStream &file,const String encoding) +void FormatHandlerASS::Load(IModel &model,Reader &file) { - // Make text file reader - shared_ptr reader = TextReader::GetReader(file,encoding); + // Get text file reader + shared_ptr reader = file.GetTextReader(); // Variables int version = 1; @@ -148,10 +163,10 @@ void FormatHandlerASS::Load(IModel &model,wxInputStream &file,const String encod ///////////////////// // Save file to disc -void FormatHandlerASS::Save(const IModel& model,wxOutputStream &file,const String encoding) const +void FormatHandlerASS::Save(const IModel& model,Writer &file) const { // Make text file writer - shared_ptr writer = TextWriter::GetWriter(file,encoding); + shared_ptr writer = file.GetTextWriter(); // Set up list of sections to write StringArray sections; diff --git a/athenasub/src/formats/format_ass.h b/athenasub/src/formats/format_ass.h index 374a84220..dcbc9099a 100644 --- a/athenasub/src/formats/format_ass.h +++ b/athenasub/src/formats/format_ass.h @@ -62,8 +62,8 @@ namespace Athenasub { FormatHandlerASS(int version); ~FormatHandlerASS(); - void Load(IModel &model,wxInputStream &file,const String encoding); - void Save(const IModel &model,wxOutputStream &file,const String encoding) const; + void Load(IModel &model,Reader &file); + void Save(const IModel &model,Writer &file) const; }; // Advanced Substation Alpha format base class @@ -84,9 +84,11 @@ namespace Athenasub { virtual int GetTimingPrecision() const { return 10; } virtual int GetMaxTime() const { return 35999990; } + bool IsBinary() const { return false; } Dialogue CreateDialogue() const { return Dialogue(new DialogueASS()); } Style CreateStyle() const { return Style(new StyleASS()); } + float CanReadFile(Reader &reader) const; }; // Substation Alpha diff --git a/athenasub/src/model.cpp b/athenasub/src/model.cpp index c46842c4c..8137aae9e 100644 --- a/athenasub/src/model.cpp +++ b/athenasub/src/model.cpp @@ -109,7 +109,7 @@ void CModel::ProcessActionList(CActionList &_actionList,int type) ////////////////// // Load subtitles -void CModel::Load(wxInputStream &input,const Format _format,const String encoding) +void CModel::Load(Reader &input,const Format _format) { // Autodetect format if (!_format) { @@ -127,7 +127,7 @@ void CModel::Load(wxInputStream &input,const Format _format,const String encodin Clear(); // Load - handler->Load(*this,input,encoding); + handler->Load(*this,input); // Set the format format = _format; @@ -136,7 +136,7 @@ void CModel::Load(wxInputStream &input,const Format _format,const String encodin ////////////////// // Save subtitles -void CModel::Save(wxOutputStream &output,const Format _format,const String encoding) const +void CModel::Save(Writer &output,const Format _format) const { // Use another format if (_format && _format != format) { @@ -149,7 +149,7 @@ void CModel::Save(wxOutputStream &output,const Format _format,const String encod if (!handler) THROW_ATHENA_EXCEPTION(Exception::No_Format_Handler); // Load - handler->Save(*this,output,encoding); + handler->Save(*this,output); } diff --git a/athenasub/src/model.h b/athenasub/src/model.h index ceca0ccd5..e6b264add 100644 --- a/athenasub/src/model.h +++ b/athenasub/src/model.h @@ -36,7 +36,6 @@ #pragma once #include #include -#include #include "athenasub.h" #include "actionlist.h" #include "section.h" @@ -80,7 +79,7 @@ namespace Athenasub { void DispatchNotifications(Notification notification) const; void Clear(); - void Load(wxInputStream &input,Format format=Format(),const String encoding=""); + void Load(Reader &input,Format format=Format()); Section AddSection(String name); Section GetMutableSection(String name); @@ -94,7 +93,7 @@ namespace Athenasub { Format GetFormat() const { return format; } void AddListener(View listener); - void Save(wxOutputStream &output,Format format=Format(),const String encoding="UTF-8") const; + void Save(Writer &output,Format format=Format()) const; ConstSection GetSection(String name) const; ConstSection GetSectionByIndex(size_t index) const; diff --git a/athenasub/src/reader.cpp b/athenasub/src/reader.cpp new file mode 100644 index 000000000..177799fbb --- /dev/null +++ b/athenasub/src/reader.cpp @@ -0,0 +1,57 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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 of the Aegisub Group nor the names of its contributors +// 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. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +#include "reader.h" +#include "text_reader.h" +#include +using namespace Athenasub; + + +Reader::Reader(String filename,String encoding) +{ + stream = shared_ptr(new wxFFileInputStream(filename.GetWxString())); + text = TextReader::GetReader(*stream,encoding); +} + +shared_ptr Athenasub::Reader::GetTextReader() +{ + return text; +} + +void Reader::Rewind() +{ + text->Rewind(); +} \ No newline at end of file diff --git a/athenasub/src/reader.h b/athenasub/src/reader.h new file mode 100644 index 000000000..168c8151d --- /dev/null +++ b/athenasub/src/reader.h @@ -0,0 +1,60 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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 of the Aegisub Group nor the names of its contributors +// 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. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +#pragma once + + +// Headers +#include "athenasub.h" + +class wxFFileInputStream; +namespace Athenasub { + class TextReader; + + class Reader { + private: + shared_ptr text; + String filename; + shared_ptr stream; + + public: + Reader(String filename,String encoding=""); + + shared_ptr GetTextReader(); + String GetFileName(); + void Rewind(); + }; +} diff --git a/athenasub/src/section_entry_dialogue.h b/athenasub/src/section_entry_dialogue.h index 5f4eb8bd0..e54475c61 100644 --- a/athenasub/src/section_entry_dialogue.h +++ b/athenasub/src/section_entry_dialogue.h @@ -44,8 +44,7 @@ namespace Athenasub { // Dialogue class class CDialogue : public IDialogue { private: - static const bool dodgeWarning = true; - void ThrowUnsupported() const { if (dodgeWarning) THROW_ATHENA_EXCEPTION(Exception::Unsupported_Format_Feature); } +#define ThrowUnsupported() THROW_ATHENA_EXCEPTION(Exception::Unsupported_Format_Feature) static const String& EmptyString(); public: diff --git a/athenasub/src/section_entry_style.h b/athenasub/src/section_entry_style.h index 77be9c823..10861323f 100644 --- a/athenasub/src/section_entry_style.h +++ b/athenasub/src/section_entry_style.h @@ -44,8 +44,7 @@ namespace Athenasub { // Style class class CStyle : public IStyle { private: - static const bool dodgeWarning = true; - void ThrowUnsupported() const { if (dodgeWarning) THROW_ATHENA_EXCEPTION(Exception::Unsupported_Format_Feature); } + #define ThrowUnsupported() THROW_ATHENA_EXCEPTION(Exception::Unsupported_Format_Feature) public: // Destructor diff --git a/athenasub/src/text_reader_cache.cpp b/athenasub/src/text_reader_cache.cpp index 99dc79ef5..81189f084 100644 --- a/athenasub/src/text_reader_cache.cpp +++ b/athenasub/src/text_reader_cache.cpp @@ -48,7 +48,7 @@ Athenasub::TextReaderCache::TextReaderCache(shared_ptr src) String TextReaderCache::ReadLineFromFile() { if (bufferPos == buffer.size()) { - LoadMore(1); + LoadMore(1000000); } if (bufferPos == buffer.size()) { return ""; diff --git a/athenasub/src/writer.cpp b/athenasub/src/writer.cpp new file mode 100644 index 000000000..e3261ea8a --- /dev/null +++ b/athenasub/src/writer.cpp @@ -0,0 +1,53 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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 of the Aegisub Group nor the names of its contributors +// 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. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +#include "writer.h" +#include "text_writer.h" +#include +using namespace Athenasub; + + +Writer::Writer(String filename,String encoding) +{ + stream = shared_ptr(new wxFFileOutputStream(filename.GetWxString())); + text = TextWriter::GetWriter(*stream,encoding); +} + + +shared_ptr Writer::GetTextWriter() +{ + return text; +} diff --git a/athenasub/src/writer.h b/athenasub/src/writer.h new file mode 100644 index 000000000..e54fd0eb2 --- /dev/null +++ b/athenasub/src/writer.h @@ -0,0 +1,58 @@ +// Copyright (c) 2008, Rodrigo Braz Monteiro +// 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 of the Aegisub Group nor the names of its contributors +// 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. +// +// ----------------------------------------------------------------------------- +// +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +#pragma once + + +// Headers +#include "athenasub.h" + + +class wxFFileOutputStream; +namespace Athenasub { + class TextWriter; + + class Writer { + private: + shared_ptr text; + shared_ptr stream; + + public: + Writer(String filename,String encoding=""); + + shared_ptr GetTextWriter(); + }; +} diff --git a/unit_test/unit_test.vcproj b/unit_test/unit_test.vcproj index 5a7257d88..fba87ae1e 100644 --- a/unit_test/unit_test.vcproj +++ b/unit_test/unit_test.vcproj @@ -61,6 +61,7 @@ />