Basic ASS parsing in Aegilib (should I just go ahead and rename this to libgorgon already?) almost works.
Originally committed to SVN as r1982.
This commit is contained in:
parent
48af40fa26
commit
1b7746e99f
19 changed files with 931 additions and 176 deletions
|
@ -199,6 +199,22 @@
|
||||||
RelativePath=".\include\aegilib\notification.h"
|
RelativePath=".\include\aegilib\notification.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\section.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\section_entry.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\section_entry_dialogue.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\time.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\view.h"
|
RelativePath=".\include\aegilib\view.h"
|
||||||
>
|
>
|
||||||
|
@ -268,6 +284,10 @@
|
||||||
RelativePath=".\src\prec.h"
|
RelativePath=".\src\prec.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\section.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\src\text_file_reader.cpp"
|
RelativePath=".\src\text_file_reader.cpp"
|
||||||
>
|
>
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "exception.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
@ -43,4 +44,5 @@
|
||||||
#include "format_handler.h"
|
#include "format_handler.h"
|
||||||
#include "format_manager.h"
|
#include "format_manager.h"
|
||||||
#include "manipulator.h"
|
#include "manipulator.h"
|
||||||
#include "exception.h"
|
#include "section.h"
|
||||||
|
#include "section_entry_dialogue.h"
|
||||||
|
|
|
@ -36,11 +36,13 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Aegilib {
|
namespace Aegilib {
|
||||||
|
|
||||||
// Define the string type used throughout this library
|
// Define the string type used throughout this library
|
||||||
//typedef std::basic_string<wchar_t> String;
|
//typedef std::basic_string<wchar_t> String;
|
||||||
typedef wxString String;
|
typedef wxString String;
|
||||||
|
typedef std::vector<String> StringArray;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "aegilib.h"
|
#include "aegistring.h"
|
||||||
|
|
||||||
namespace Aegilib {
|
namespace Aegilib {
|
||||||
|
|
||||||
|
@ -45,7 +45,11 @@ namespace Aegilib {
|
||||||
enum ExceptionList {
|
enum ExceptionList {
|
||||||
Unknown,
|
Unknown,
|
||||||
No_Format_Handler,
|
No_Format_Handler,
|
||||||
Invalid_Manipulator
|
Invalid_Manipulator,
|
||||||
|
Section_Already_Exists,
|
||||||
|
Unknown_Format,
|
||||||
|
Parse_Error,
|
||||||
|
Unsupported_Format_Feature
|
||||||
};
|
};
|
||||||
|
|
||||||
Exception(ExceptionList code);
|
Exception(ExceptionList code);
|
||||||
|
|
|
@ -47,8 +47,9 @@ namespace Aegilib {
|
||||||
virtual ~Format() {}
|
virtual ~Format() {}
|
||||||
|
|
||||||
virtual String GetName() const = 0;
|
virtual String GetName() const = 0;
|
||||||
virtual String GetExtension() const = 0;
|
virtual StringArray GetReadExtensions() const = 0;
|
||||||
virtual FormatHandler* GetHandler(const Model &model) const = 0;
|
virtual StringArray GetWriteExtensions() const = 0;
|
||||||
|
virtual FormatHandler* GetHandler(Model &model) const = 0;
|
||||||
|
|
||||||
virtual bool CanStoreText() const { return false; }
|
virtual bool CanStoreText() const { return false; }
|
||||||
virtual bool CanStoreImages() const { return false; }
|
virtual bool CanStoreImages() const { return false; }
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace Aegilib {
|
||||||
|
|
||||||
static int GetFormatCount();
|
static int GetFormatCount();
|
||||||
static const Format* GetFormatByIndex(const int index);
|
static const Format* GetFormatByIndex(const int index);
|
||||||
static const Format* GetFormatFromFilename(const String &filename);
|
static const Format* GetFormatFromFilename(const String &filename,bool read);
|
||||||
static const Format* GetFormatFromName(const String &name);
|
static const Format* GetFormatFromName(const String &name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,10 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <wx/stream.h>
|
#include <wx/stream.h>
|
||||||
#include "manipulator.h"
|
#include "manipulator.h"
|
||||||
|
#include "section.h"
|
||||||
|
|
||||||
namespace Aegilib {
|
namespace Aegilib {
|
||||||
|
|
||||||
// Prototypes
|
// Prototypes
|
||||||
class View;
|
class View;
|
||||||
class Notification;
|
class Notification;
|
||||||
|
@ -52,6 +54,7 @@ namespace Aegilib {
|
||||||
typedef std::list<const Manipulator> ActionStack;
|
typedef std::list<const Manipulator> ActionStack;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::list<Section*> sections;
|
||||||
ActionStack undoStack;
|
ActionStack undoStack;
|
||||||
ActionStack redoStack;
|
ActionStack redoStack;
|
||||||
ViewList listeners;
|
ViewList listeners;
|
||||||
|
@ -68,6 +71,9 @@ namespace Aegilib {
|
||||||
void LoadFile(wxInputStream &input,const Format *format=NULL,const String encoding=L"");
|
void LoadFile(wxInputStream &input,const Format *format=NULL,const String encoding=L"");
|
||||||
void SaveFile(wxOutputStream &output,const Format *format=NULL,const String encoding=L"UTF-8");
|
void SaveFile(wxOutputStream &output,const Format *format=NULL,const String encoding=L"UTF-8");
|
||||||
|
|
||||||
|
Section* GetSection(String name) const;
|
||||||
|
void AddSection(String name);
|
||||||
|
|
||||||
bool CanUndo(const String owner=L"") const;
|
bool CanUndo(const String owner=L"") const;
|
||||||
bool CanRedo(const String owner=L"") const;
|
bool CanRedo(const String owner=L"") const;
|
||||||
bool Undo(const String owner=L"");
|
bool Undo(const String owner=L"");
|
||||||
|
|
59
aegilib/include/aegilib/section.h
Normal file
59
aegilib/include/aegilib/section.h
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
// 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/AEGILIB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "aegistring.h"
|
||||||
|
#include "section_entry.h"
|
||||||
|
#include <list>
|
||||||
|
|
||||||
|
namespace Aegilib {
|
||||||
|
|
||||||
|
// Section class
|
||||||
|
class Section {
|
||||||
|
private:
|
||||||
|
std::list<SectionEntry*> entries;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Section(String name);
|
||||||
|
~Section();
|
||||||
|
|
||||||
|
String GetName() const { return name; }
|
||||||
|
String SetName(String newName) { name = newName; }
|
||||||
|
|
||||||
|
void AddEntry(SectionEntry *entry);
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
71
aegilib/include/aegilib/section_entry.h
Normal file
71
aegilib/include/aegilib/section_entry.h
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
// 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/AEGILIB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Aegilib {
|
||||||
|
|
||||||
|
// Types
|
||||||
|
enum SectionEntryType {
|
||||||
|
SECTION_ENTRY_PLAIN,
|
||||||
|
SECTION_ENTRY_DIALOGUE,
|
||||||
|
SECTION_ENTRY_STYLE,
|
||||||
|
SECTION_ENTRY_FILE,
|
||||||
|
SECTION_ENTRY_RAW
|
||||||
|
};
|
||||||
|
|
||||||
|
// Prototypes
|
||||||
|
class SectionEntryPlain;
|
||||||
|
class SectionEntryDialogue;
|
||||||
|
class SectionEntryStyle;
|
||||||
|
class SectionEntryFile;
|
||||||
|
class SectionEntryRaw;
|
||||||
|
|
||||||
|
// Section entry class
|
||||||
|
class SectionEntry {
|
||||||
|
private:
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~SectionEntry() {}
|
||||||
|
|
||||||
|
virtual SectionEntryType GetType() const =0;
|
||||||
|
virtual SectionEntryPlain *GetAsPlain() { return NULL; }
|
||||||
|
virtual SectionEntryDialogue *GetAsDialogue() { return NULL; }
|
||||||
|
virtual SectionEntryStyle *GetAsStyle() { return NULL; }
|
||||||
|
virtual SectionEntryFile *GetAsFile() { return NULL; }
|
||||||
|
virtual SectionEntryRaw *GetAsRaw() { return NULL; }
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
81
aegilib/include/aegilib/section_entry_dialogue.h
Normal file
81
aegilib/include/aegilib/section_entry_dialogue.h
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
// 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/AEGILIB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "exception.h"
|
||||||
|
#include "section_entry.h"
|
||||||
|
#include "time.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Aegilib {
|
||||||
|
|
||||||
|
// Dialogue class
|
||||||
|
class SectionEntryDialogue : public SectionEntry {
|
||||||
|
private:
|
||||||
|
void ThrowUnsupported() const { throw Exception(Exception::Unsupported_Format_Feature); }
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Destructor
|
||||||
|
virtual ~SectionEntryDialogue() {}
|
||||||
|
|
||||||
|
// Type
|
||||||
|
SectionEntryType GetType() const { return SECTION_ENTRY_DIALOGUE; }
|
||||||
|
SectionEntryDialogue *GetAsDialogue() { return this; }
|
||||||
|
|
||||||
|
// Capabilities
|
||||||
|
virtual bool HasText() const { return false; }
|
||||||
|
virtual bool HasImage() const { return false; }
|
||||||
|
virtual bool HasTime() const { return false; }
|
||||||
|
virtual bool HasFrame() const { return false; }
|
||||||
|
virtual bool HasStyle() const { return false; }
|
||||||
|
virtual bool HasMargins() const { return false; }
|
||||||
|
|
||||||
|
// Read accessors
|
||||||
|
virtual String GetText() const { ThrowUnsupported(); return L""; }
|
||||||
|
virtual Time GetStartTime() const { ThrowUnsupported(); return 0; }
|
||||||
|
virtual Time GetEndTime() const { ThrowUnsupported(); return 0; }
|
||||||
|
virtual int GetStartFrame() const { ThrowUnsupported(); return 0; }
|
||||||
|
virtual int GetEndFrame() const { ThrowUnsupported(); return 0; }
|
||||||
|
|
||||||
|
// Write acessors
|
||||||
|
virtual void SetText(String text) { (void) text; ThrowUnsupported(); }
|
||||||
|
virtual void SetStartTime(Time start) { (void) start; ThrowUnsupported(); }
|
||||||
|
virtual void SetEndTime(Time end) { (void) end; ThrowUnsupported(); }
|
||||||
|
virtual void SetStartFrame(int start) { (void) start; ThrowUnsupported(); }
|
||||||
|
virtual void SetEndFrame(int end) { (void) end; ThrowUnsupported(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
50
aegilib/include/aegilib/time.h
Normal file
50
aegilib/include/aegilib/time.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// 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/AEGILIB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Aegilib {
|
||||||
|
|
||||||
|
// Time class
|
||||||
|
class Time {
|
||||||
|
private:
|
||||||
|
int ms;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Time() { ms = 0; }
|
||||||
|
Time(int ms) { (void)ms; }
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
|
@ -53,6 +53,10 @@ String Exception::GetMessage()
|
||||||
case Unknown: return L"Unknown.";
|
case Unknown: return L"Unknown.";
|
||||||
case No_Format_Handler: return L"Could not find a suitable format handler.";
|
case No_Format_Handler: return L"Could not find a suitable format handler.";
|
||||||
case Invalid_Manipulator: return L"Invalid manipulator.";
|
case Invalid_Manipulator: return L"Invalid manipulator.";
|
||||||
|
case Section_Already_Exists: return L"The specified section already exists in this model.";
|
||||||
|
case Unknown_Format: return L"The specified file format is unknown.";
|
||||||
|
case Parse_Error: return L"Parse error.";
|
||||||
|
case Unsupported_Format_Feature: return L"This feature is not supported by this format.";
|
||||||
}
|
}
|
||||||
return L"Invalid code.";
|
return L"Invalid code.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,11 +91,17 @@ const Format* FormatManager::GetFormatByIndex(const int index)
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// By filename
|
// By filename
|
||||||
const Format* FormatManager::GetFormatFromFilename(const String &filename)
|
const Format* FormatManager::GetFormatFromFilename(const String &filename,bool read)
|
||||||
{
|
{
|
||||||
size_t len = formats.size();
|
size_t len = formats.size();
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
if (filename.EndsWith(formats[i]->GetExtension())) return formats[i];
|
StringArray exts;
|
||||||
|
if (read) exts = formats[i]->GetReadExtensions();
|
||||||
|
else exts = formats[i]->GetWriteExtensions();
|
||||||
|
size_t extn = exts.size();
|
||||||
|
for (size_t j=0;j<extn;j++) {
|
||||||
|
if (filename.EndsWith(exts[j])) return formats[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,14 +37,30 @@
|
||||||
#include "format_ass.h"
|
#include "format_ass.h"
|
||||||
#include "../text_file_reader.h"
|
#include "../text_file_reader.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <wx/tokenzr.h>
|
||||||
using namespace Aegilib;
|
using namespace Aegilib;
|
||||||
|
|
||||||
|
|
||||||
|
//////////////
|
||||||
|
// Extensions
|
||||||
|
StringArray FormatASS::GetReadExtensions() const
|
||||||
|
{
|
||||||
|
StringArray final;
|
||||||
|
final.push_back(L".ass");
|
||||||
|
final.push_back(L".ssa");
|
||||||
|
return final;
|
||||||
|
}
|
||||||
|
StringArray FormatASS::GetWriteExtensions() const
|
||||||
|
{
|
||||||
|
return GetReadExtensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
FormatHandlerASS::FormatHandlerASS(const Model &model)
|
FormatHandlerASS::FormatHandlerASS(Model &_model)
|
||||||
|
: model(_model)
|
||||||
{
|
{
|
||||||
(void) model;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,10 +78,287 @@ void FormatHandlerASS::Load(wxInputStream &file,const String encoding)
|
||||||
// Make text file reader
|
// Make text file reader
|
||||||
TextFileReader reader(file,encoding);
|
TextFileReader reader(file,encoding);
|
||||||
|
|
||||||
|
// Debug
|
||||||
using namespace std;
|
using namespace std;
|
||||||
cout << endl << "Dumping file:" << endl;
|
cout << endl << "Dumping file:" << endl;
|
||||||
|
|
||||||
|
// Variables
|
||||||
|
int version = 1;
|
||||||
|
wxString curGroup = L"-";
|
||||||
|
wxString prevGroup = L"-";
|
||||||
|
Section *section = NULL;
|
||||||
|
|
||||||
|
// Read file
|
||||||
while (reader.HasMoreLines()) {
|
while (reader.HasMoreLines()) {
|
||||||
|
// Read a line
|
||||||
wxString cur = reader.ReadLineFromFile();
|
wxString cur = reader.ReadLineFromFile();
|
||||||
cout << cur.mb_str(wxConvUTF8) << endl;
|
|
||||||
|
// Process group
|
||||||
|
prevGroup = curGroup;
|
||||||
|
ProcessGroup(cur,curGroup,version);
|
||||||
|
|
||||||
|
// Insert group if it doesn't already exist
|
||||||
|
if (prevGroup != curGroup) section = model.GetSection(curGroup);
|
||||||
|
if (!section) {
|
||||||
|
model.AddSection(curGroup);
|
||||||
|
section = model.GetSection(curGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip [] lines
|
||||||
|
if (cur[0] == L'[') continue;
|
||||||
|
|
||||||
|
// Create and insert line
|
||||||
|
SectionEntry *entry = MakeEntry(cur,curGroup,version);
|
||||||
|
//if (!entry) throw Exception(Exception::Parse_Error);
|
||||||
|
section->AddEntry(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debug
|
||||||
|
cout << "\nFinished reading file with version=" << version << ".\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////
|
||||||
|
// Create line
|
||||||
|
SectionEntry *FormatHandlerASS::MakeEntry(String data,String group,int version)
|
||||||
|
{
|
||||||
|
// Variables
|
||||||
|
SectionEntry *final = NULL;
|
||||||
|
|
||||||
|
// Attachments
|
||||||
|
if (group == _T("Fonts") || group == _T("Graphics")) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// Events
|
||||||
|
else if (group == _T("Events")) {
|
||||||
|
// Dialogue lines
|
||||||
|
if ((data.Left(9) == _T("Dialogue:") || data.Left(8) == _T("Comment:"))) {
|
||||||
|
DialogueASS *diag = new DialogueASS(data,version);
|
||||||
|
final = diag;
|
||||||
|
|
||||||
|
// Debug
|
||||||
|
std::cout << "[" << group.mb_str(wxConvUTF8) << "] " << diag->GetText().mb_str(wxConvUTF8) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format lines
|
||||||
|
else if (data.Left(7) == _T("Format:")) {
|
||||||
|
// TODO
|
||||||
|
//entry = new AssEntry(_T("Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Garbage
|
||||||
|
else {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Styles
|
||||||
|
else if (group == _T("V4+ Styles")) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// Script info
|
||||||
|
else if (group == _T("Script Info")) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return entry
|
||||||
|
return final;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
// Process group data
|
||||||
|
void FormatHandlerASS::ProcessGroup(String cur,String &curGroup,int &version) {
|
||||||
|
// Style conversion
|
||||||
|
if (!cur.IsEmpty() && cur[0] == '[') {
|
||||||
|
wxString low = cur.Lower();
|
||||||
|
bool changed = true;
|
||||||
|
|
||||||
|
// SSA file
|
||||||
|
if (low == _T("[v4 styles]")) {
|
||||||
|
cur = _T("[V4+ Styles]");
|
||||||
|
curGroup = cur;
|
||||||
|
version = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ASS file
|
||||||
|
else if (low == _T("[v4+ styles]")) {
|
||||||
|
curGroup = cur;
|
||||||
|
version = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ASS2 file
|
||||||
|
else if (low == _T("[v4++ styles]")) {
|
||||||
|
cur = _T("[V4+ Styles]");
|
||||||
|
curGroup = cur;
|
||||||
|
version = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Other groups
|
||||||
|
else {
|
||||||
|
wxString temp = cur;
|
||||||
|
temp.Trim(true).Trim(false);
|
||||||
|
if (temp[temp.Length()-1] == ']') curGroup = cur;
|
||||||
|
else changed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize group name
|
||||||
|
if (changed) {
|
||||||
|
// Get rid of []
|
||||||
|
curGroup = curGroup.Mid(1,curGroup.Length()-2);
|
||||||
|
|
||||||
|
// Normalize case
|
||||||
|
curGroup.MakeLower();
|
||||||
|
wxString upper = curGroup.Upper();
|
||||||
|
bool raise = true;
|
||||||
|
size_t len = curGroup.Length();
|
||||||
|
for (size_t i=0;i<len;i++) {
|
||||||
|
if (raise) {
|
||||||
|
curGroup[i] = upper[i];
|
||||||
|
raise = false;
|
||||||
|
}
|
||||||
|
if (curGroup[i] == L' ') raise = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update version with version line
|
||||||
|
if (curGroup == _T("Script Info")) {
|
||||||
|
if (cur.Left(11).Lower() == _T("scripttype:")) {
|
||||||
|
wxString versionString = cur.Mid(11);
|
||||||
|
versionString.Trim(true);
|
||||||
|
versionString.Trim(false);
|
||||||
|
versionString.MakeLower();
|
||||||
|
int trueVersion;
|
||||||
|
if (versionString == _T("v4.00")) trueVersion = 0;
|
||||||
|
else if (versionString == _T("v4.00+")) trueVersion = 1;
|
||||||
|
else if (versionString == _T("v4.00++")) trueVersion = 2;
|
||||||
|
else throw Exception(Exception::Unknown_Format);
|
||||||
|
if (trueVersion != version) {
|
||||||
|
// TODO: issue warning?
|
||||||
|
version = trueVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////
|
||||||
|
// ASS dialogue constructor
|
||||||
|
DialogueASS::DialogueASS(String data,int version)
|
||||||
|
{
|
||||||
|
// Try parsing with all different versions
|
||||||
|
bool valid = false;
|
||||||
|
for (int count=0;!valid && count < 3;count++) {
|
||||||
|
valid = Parse(data,version);
|
||||||
|
version++;
|
||||||
|
if (version > 2) version = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////
|
||||||
|
// Parse ASS Data
|
||||||
|
bool DialogueASS::Parse(wxString rawData, int version)
|
||||||
|
{
|
||||||
|
size_t pos = 0;
|
||||||
|
wxString temp;
|
||||||
|
|
||||||
|
// Get type
|
||||||
|
if (rawData.StartsWith(_T("Dialogue:"))) {
|
||||||
|
comment = false;
|
||||||
|
pos = 10;
|
||||||
|
}
|
||||||
|
else if (rawData.StartsWith(_T("Comment:"))) {
|
||||||
|
comment = true;
|
||||||
|
pos = 9;
|
||||||
|
}
|
||||||
|
else return false;
|
||||||
|
|
||||||
|
wxStringTokenizer tkn(rawData.Mid(pos),_T(","),wxTOKEN_RET_EMPTY_ALL);
|
||||||
|
if (!tkn.HasMoreTokens()) return false;
|
||||||
|
|
||||||
|
// Get first token and see if it has "Marked=" in it
|
||||||
|
temp = tkn.GetNextToken().Trim(false).Trim(true);
|
||||||
|
if (temp.Lower().StartsWith(_T("marked="))) version = 0;
|
||||||
|
else if (version == 0) version = 1;
|
||||||
|
|
||||||
|
// Get layer number
|
||||||
|
if (version == 0) layer = 0;
|
||||||
|
else {
|
||||||
|
long templ;
|
||||||
|
temp.ToLong(&templ);
|
||||||
|
layer = templ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get start time
|
||||||
|
if (!tkn.HasMoreTokens()) return false;
|
||||||
|
start = ParseTime(tkn.GetNextToken());
|
||||||
|
|
||||||
|
// Get end time
|
||||||
|
if (!tkn.HasMoreTokens()) return false;
|
||||||
|
end = ParseTime(tkn.GetNextToken());
|
||||||
|
|
||||||
|
// Get style
|
||||||
|
if (!tkn.HasMoreTokens()) return false;
|
||||||
|
style = tkn.GetNextToken();
|
||||||
|
style.Trim(true);
|
||||||
|
style.Trim(false);
|
||||||
|
|
||||||
|
// Get actor
|
||||||
|
if (!tkn.HasMoreTokens()) return false;
|
||||||
|
actor = tkn.GetNextToken();
|
||||||
|
actor.Trim(true);
|
||||||
|
actor.Trim(false);
|
||||||
|
|
||||||
|
// Get margins
|
||||||
|
for (int i=0;i<3;i++) {
|
||||||
|
if (!tkn.HasMoreTokens()) return false;
|
||||||
|
long templ;
|
||||||
|
tkn.GetNextToken().Trim(false).Trim(true).ToLong(&templ);
|
||||||
|
margin[i] = templ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get bottom margin
|
||||||
|
if (version == 1) margin[3] = margin[2];
|
||||||
|
bool rollBack = false;
|
||||||
|
if (version == 2) {
|
||||||
|
if (!tkn.HasMoreTokens()) return false;
|
||||||
|
wxString oldTemp = temp;
|
||||||
|
temp = tkn.GetNextToken().Trim(false).Trim(true);
|
||||||
|
if (!temp.IsNumber()) {
|
||||||
|
version = 1;
|
||||||
|
rollBack = true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
long templ;
|
||||||
|
temp.ToLong(&templ);
|
||||||
|
margin[3] = templ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get effect
|
||||||
|
if (!rollBack) {
|
||||||
|
if (!tkn.HasMoreTokens()) return false;
|
||||||
|
temp = tkn.GetNextToken();
|
||||||
|
}
|
||||||
|
effect = temp;
|
||||||
|
effect.Trim(true);
|
||||||
|
effect.Trim(false);
|
||||||
|
|
||||||
|
// Get text
|
||||||
|
text = rawData.Mid(pos+tkn.GetPosition());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////
|
||||||
|
// Parse time string
|
||||||
|
Time DialogueASS::ParseTime(String time)
|
||||||
|
{
|
||||||
|
(void) time;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
#include "format_handler.h"
|
#include "format_handler.h"
|
||||||
|
#include "section.h"
|
||||||
|
#include "section_entry_dialogue.h"
|
||||||
|
|
||||||
namespace Aegilib {
|
namespace Aegilib {
|
||||||
|
|
||||||
|
@ -44,8 +46,13 @@ namespace Aegilib {
|
||||||
|
|
||||||
// Advanced Substation Alpha format handler
|
// Advanced Substation Alpha format handler
|
||||||
class FormatHandlerASS : public FormatHandler {
|
class FormatHandlerASS : public FormatHandler {
|
||||||
|
private:
|
||||||
|
SectionEntry *MakeEntry(String data,String group,int version);
|
||||||
|
void ProcessGroup(String cur,String &curGroup,int &version);
|
||||||
|
Model &model;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FormatHandlerASS(const Model &model);
|
FormatHandlerASS(Model &model);
|
||||||
~FormatHandlerASS();
|
~FormatHandlerASS();
|
||||||
|
|
||||||
void Load(wxInputStream &file,const String encoding);
|
void Load(wxInputStream &file,const String encoding);
|
||||||
|
@ -55,8 +62,9 @@ namespace Aegilib {
|
||||||
class FormatASS : public Format {
|
class FormatASS : public Format {
|
||||||
public:
|
public:
|
||||||
String GetName() const { return L"Advanced Substation Alpha"; }
|
String GetName() const { return L"Advanced Substation Alpha"; }
|
||||||
String GetExtension() const { return L".ass"; }
|
StringArray GetReadExtensions() const;
|
||||||
FormatHandler* GetHandler(const Model &model) const { return new FormatHandlerASS(model); }
|
StringArray GetWriteExtensions() const;
|
||||||
|
FormatHandler* GetHandler(Model &model) const { return new FormatHandlerASS(model); }
|
||||||
|
|
||||||
bool CanStoreText() const { return true; }
|
bool CanStoreText() const { return true; }
|
||||||
bool CanUseTime() const { return true; }
|
bool CanUseTime() const { return true; }
|
||||||
|
@ -66,4 +74,41 @@ namespace Aegilib {
|
||||||
bool HasActors() const { return true; }
|
bool HasActors() const { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Dialogue
|
||||||
|
class DialogueASS : public SectionEntryDialogue {
|
||||||
|
private:
|
||||||
|
String text;
|
||||||
|
String style;
|
||||||
|
String effect;
|
||||||
|
String actor;
|
||||||
|
Time start,end;
|
||||||
|
int margin[4];
|
||||||
|
int layer;
|
||||||
|
bool comment;
|
||||||
|
|
||||||
|
bool Parse(String data,int version);
|
||||||
|
Time ParseTime(String data);
|
||||||
|
|
||||||
|
public:
|
||||||
|
// Constructors
|
||||||
|
DialogueASS() {}
|
||||||
|
DialogueASS(String data,int version);
|
||||||
|
|
||||||
|
// Capabilities
|
||||||
|
bool HasText() const { return true; }
|
||||||
|
bool HasTime() const { return true; }
|
||||||
|
bool HasStyle() const { return true; }
|
||||||
|
bool HasMargins() const { return true; }
|
||||||
|
|
||||||
|
// Read accessors
|
||||||
|
String GetText() const { return text; }
|
||||||
|
Time GetStartTime() const { return start; }
|
||||||
|
Time GetEndTime() const { return end; }
|
||||||
|
|
||||||
|
// Write acessors
|
||||||
|
void SetText(String setText) { text = setText; }
|
||||||
|
void SetStartTime(Time setStart) { start = setStart; }
|
||||||
|
void SetEndTime(Time setEnd) { end = setEnd; }
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -117,3 +117,25 @@ void Model::SaveFile(wxOutputStream &output,const Format *format,const String en
|
||||||
(void) encoding;
|
(void) encoding;
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////
|
||||||
|
// Gets a section
|
||||||
|
Section* Model::GetSection(String name) const
|
||||||
|
{
|
||||||
|
std::list<Section*>::const_iterator cur;
|
||||||
|
for (cur=sections.begin();cur!=sections.end();cur++) {
|
||||||
|
if ((*cur)->GetName() == name) return *cur;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////
|
||||||
|
// Inserts a new section
|
||||||
|
void Model::AddSection(String name)
|
||||||
|
{
|
||||||
|
Section *prev = GetSection(name);
|
||||||
|
if (prev) throw Exception(Exception::Section_Already_Exists);
|
||||||
|
sections.push_back(new Section(name));
|
||||||
|
}
|
||||||
|
|
61
aegilib/src/section.cpp
Normal file
61
aegilib/src/section.cpp
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// 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/AEGILIB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#include "section.h"
|
||||||
|
using namespace Aegilib;
|
||||||
|
|
||||||
|
|
||||||
|
///////////////
|
||||||
|
// Constructor
|
||||||
|
Section::Section(String _name)
|
||||||
|
{
|
||||||
|
name = _name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////
|
||||||
|
// Destructor
|
||||||
|
Section::~Section()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////
|
||||||
|
// Append an entry
|
||||||
|
void Section::AddEntry(SectionEntry *entry)
|
||||||
|
{
|
||||||
|
entries.push_back(entry);
|
||||||
|
}
|
|
@ -55,8 +55,8 @@ int main () {
|
||||||
// Load subtitles
|
// Load subtitles
|
||||||
cout << "Loading file... ";
|
cout << "Loading file... ";
|
||||||
String filename = L"subs_in.ass";
|
String filename = L"subs_in.ass";
|
||||||
const Format *handler = FormatManager::GetFormatFromFilename(filename);
|
const Format *handler = FormatManager::GetFormatFromFilename(filename,true);
|
||||||
subs.LoadFile(wxFileInputStream(filename),handler);
|
subs.LoadFile(wxFileInputStream(filename),handler,L"UTF-8");
|
||||||
cout << "Done.\n";
|
cout << "Done.\n";
|
||||||
|
|
||||||
// Modify subtitles
|
// Modify subtitles
|
||||||
|
@ -66,7 +66,7 @@ int main () {
|
||||||
// Save subtitles
|
// Save subtitles
|
||||||
cout << "Saving file... ";
|
cout << "Saving file... ";
|
||||||
filename = L"subs_out.ass";
|
filename = L"subs_out.ass";
|
||||||
handler = FormatManager::GetFormatFromFilename(filename);
|
handler = FormatManager::GetFormatFromFilename(filename,false);
|
||||||
subs.SaveFile(wxFileOutputStream(filename),handler);
|
subs.SaveFile(wxFileOutputStream(filename),handler);
|
||||||
cout << "Done.\n";
|
cout << "Done.\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -488,53 +488,16 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\audio_player.cpp"
|
RelativePath="..\..\aegisub\audio_spectrum.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\audio_player_alsa.cpp"
|
RelativePath="..\..\aegisub\audio_spectrum.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<Filter
|
||||||
RelativePath="..\..\aegisub\audio_player_alsa.h"
|
Name="Providers"
|
||||||
>
|
>
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_dsound.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_dsound.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_manager.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_openal.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_openal.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_portaudio.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_portaudio.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_pulse.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\audio_player_pulse.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\audio_provider.cpp"
|
RelativePath="..\..\aegisub\audio_provider.cpp"
|
||||||
>
|
>
|
||||||
|
@ -603,14 +566,59 @@
|
||||||
RelativePath="..\..\aegisub\audio_provider_stream.h"
|
RelativePath="..\..\aegisub\audio_provider_stream.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Players"
|
||||||
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\audio_spectrum.cpp"
|
RelativePath="..\..\aegisub\audio_player.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\audio_spectrum.h"
|
RelativePath="..\..\aegisub\audio_player_alsa.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_alsa.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_dsound.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_dsound.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_manager.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_openal.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_openal.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_portaudio.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_portaudio.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_pulse.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\audio_player_pulse.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Automation"
|
Name="Automation"
|
||||||
|
@ -1604,13 +1612,24 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\video_provider.h"
|
RelativePath="..\..\aegisub\video_slider.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\video_slider.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<Filter
|
||||||
|
Name="Providers"
|
||||||
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\video_provider_avs.cpp"
|
RelativePath="..\..\aegisub\video_provider_avs.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\video_provider_avs.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\video_provider_cache.cpp"
|
RelativePath="..\..\aegisub\video_provider_cache.cpp"
|
||||||
>
|
>
|
||||||
|
@ -1635,19 +1654,20 @@
|
||||||
RelativePath="..\..\aegisub\video_provider_lavc.cpp"
|
RelativePath="..\..\aegisub\video_provider_lavc.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\video_provider_lavc.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\video_provider_manager.cpp"
|
RelativePath="..\..\aegisub\video_provider_manager.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\video_slider.cpp"
|
RelativePath="..\..\aegisub\video_provider_manager.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\video_slider.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Spellchecking"
|
Name="Spellchecking"
|
||||||
>
|
>
|
||||||
|
@ -1656,11 +1676,11 @@
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\spellchecker.h"
|
RelativePath="..\..\aegisub\spellchecker_hunspell.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\spellchecker_hunspell.cpp"
|
RelativePath="..\..\aegisub\spellchecker_hunspell.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
@ -1771,18 +1791,26 @@
|
||||||
RelativePath="..\..\aegisub\subtitles_provider.cpp"
|
RelativePath="..\..\aegisub\subtitles_provider.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath="..\..\aegisub\subtitles_provider.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\subtitles_provider_csri.cpp"
|
RelativePath="..\..\aegisub\subtitles_provider_csri.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\subtitles_provider_csri.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\aegisub\subtitles_provider_libass.cpp"
|
RelativePath="..\..\aegisub\subtitles_provider_libass.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\subtitles_provider_libass.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\aegisub\subtitles_provider_manager.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="Visual Tools"
|
Name="Visual Tools"
|
||||||
|
|
Loading…
Reference in a new issue