mirror of https://github.com/odrling/Aegisub
Changed Athenasub's API (WIP) and updated projects.
Originally committed to SVN as r2291.
This commit is contained in:
parent
15369e7545
commit
e019c333d9
|
@ -121,7 +121,7 @@
|
||||||
EnableFiberSafeOptimizations="false"
|
EnableFiberSafeOptimizations="false"
|
||||||
WholeProgramOptimization="true"
|
WholeProgramOptimization="true"
|
||||||
AdditionalIncludeDirectories="include/aegilib"
|
AdditionalIncludeDirectories="include/aegilib"
|
||||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_WINDOWS"
|
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_WINDOWS;ATHENA_DLL;ATHENA_EXPORTS"
|
||||||
RuntimeLibrary="2"
|
RuntimeLibrary="2"
|
||||||
OpenMP="false"
|
OpenMP="false"
|
||||||
UsePrecompiledHeader="2"
|
UsePrecompiledHeader="2"
|
||||||
|
@ -180,6 +180,10 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="Include"
|
Name="Include"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\api.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\athenastring.h"
|
RelativePath=".\include\aegilib\athenastring.h"
|
||||||
>
|
>
|
||||||
|
|
|
@ -163,16 +163,28 @@
|
||||||
<Filter
|
<Filter
|
||||||
Name="Include"
|
Name="Include"
|
||||||
>
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\api.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\athenastring.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\athenasub.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\athenatime.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\fastbuffer.h"
|
RelativePath=".\include\aegilib\fastbuffer.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\gorgonstring.h"
|
RelativePath=".\include\aegilib\selection.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\include\aegilib\gorgonsub.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
@ -428,6 +440,26 @@
|
||||||
RelativePath=".\include\aegilib\section_entry_style.h"
|
RelativePath=".\include\aegilib\section_entry_style.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\selection.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\stdint.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Lib"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\libathenasub.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\aegilib\libathenasub.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
</Files>
|
</Files>
|
||||||
<Globals>
|
<Globals>
|
||||||
|
|
|
@ -104,7 +104,7 @@ namespace Athenasub {
|
||||||
void Execute(Model &model);
|
void Execute(Model &model);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Modify several line
|
// Modify several lines
|
||||||
class ActionModifyBatch : public Action {
|
class ActionModifyBatch : public Action {
|
||||||
private:
|
private:
|
||||||
std::vector<shared_ptr<Entry> > entries;
|
std::vector<shared_ptr<Entry> > entries;
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "athenastring.h"
|
#include "athenastring.h"
|
||||||
#include "section_entry.h"
|
#include "section_entry.h"
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
|
#include "api.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
// 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/ATHENASUB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifdef ATHENA_DLL
|
||||||
|
#ifdef ATHENA_EXPORTS
|
||||||
|
#define ATHENA_API __declspec(dllexport)
|
||||||
|
#else
|
||||||
|
#define ATHENA_API __declspec(dllimport)
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
#define ATHENA_API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma warning(disable: 4251)
|
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
#include "tr1.h"
|
#include "tr1.h"
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
|
#include "libathenasub.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
|
|
@ -1,76 +1,79 @@
|
||||||
// Copyright (c) 2008, Rodrigo Braz Monteiro
|
// Copyright (c) 2008, Rodrigo Braz Monteiro
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are met:
|
// modification, are permitted provided that the following conditions are met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright notice,
|
// * Redistributions of source code must retain the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer.
|
// this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above copyright notice,
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
||||||
// this list of conditions and the following disclaimer in the documentation
|
// this list of conditions and the following disclaimer in the documentation
|
||||||
// and/or other materials provided with the distribution.
|
// and/or other materials provided with the distribution.
|
||||||
// * Neither the name of the Aegisub Group nor the names of its contributors
|
// * 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
|
// may be used to endorse or promote products derived from this software
|
||||||
// without specific prior written permission.
|
// without specific prior written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
// 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
|
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// AEGISUB/ATHENASUB
|
// AEGISUB/ATHENASUB
|
||||||
//
|
//
|
||||||
// Website: http://www.aegisub.net
|
// Website: http://www.aegisub.net
|
||||||
// Contact: mailto:amz@aegisub.net
|
// Contact: mailto:amz@aegisub.net
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenastring.h"
|
||||||
#include "tr1.h"
|
#include "tr1.h"
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
#include "api.h"
|
||||||
namespace Athenasub {
|
|
||||||
|
namespace Athenasub {
|
||||||
// Prototypes
|
|
||||||
class Model;
|
// Prototypes
|
||||||
class ActionList;
|
class Model;
|
||||||
typedef shared_ptr<ActionList> ActionListPtr;
|
class ActionList;
|
||||||
|
typedef shared_ptr<ActionList> ActionListPtr;
|
||||||
// Controller class
|
|
||||||
class Controller {
|
// Controller class
|
||||||
private:
|
class Controller {
|
||||||
Model &model;
|
private:
|
||||||
|
Model &model;
|
||||||
public:
|
|
||||||
Controller (Model &model);
|
public:
|
||||||
ActionListPtr CreateActionList(const String title,const String owner=L"",bool undoAble=true);
|
Controller (Model &model);
|
||||||
|
ActionListPtr CreateActionList(const String title,const String owner=L"",bool undoAble=true);
|
||||||
void LoadFile(const String filename,const String encoding=L"");
|
|
||||||
void SaveFile(const String filename,const String encoding=L"UTF-8");
|
void LoadFile(const String filename,const String encoding=L"");
|
||||||
|
void SaveFile(const String filename,const String encoding=L"UTF-8");
|
||||||
bool CanUndo(const String owner=L"") const;
|
|
||||||
bool CanRedo(const String owner=L"") const;
|
bool CanUndo(const String owner=L"") const;
|
||||||
void Undo(const String owner=L"");
|
bool CanRedo(const String owner=L"") const;
|
||||||
void Redo(const String owner=L"");
|
void Undo(const String owner=L"");
|
||||||
|
void Redo(const String owner=L"");
|
||||||
DialoguePtr CreateDialogue() const;
|
|
||||||
StylePtr CreateStyle() const;
|
DialoguePtr CreateDialogue() const;
|
||||||
|
StylePtr CreateStyle() const;
|
||||||
DialogueConstPtr GetDialogue(size_t n) const;
|
|
||||||
DialogueConstPtr GetStyle(size_t n) const;
|
DialogueConstPtr GetDialogue(size_t n) const;
|
||||||
StyleConstPtr GetStyle(String name) const;
|
DialogueConstPtr GetStyle(size_t n) const;
|
||||||
EntryConstPtr GetEntry(size_t n,String section) const;
|
StyleConstPtr GetStyle(String name) const;
|
||||||
|
EntryConstPtr GetEntry(size_t n,String section) const;
|
||||||
const FormatPtr GetFormat() const;
|
|
||||||
};
|
const FormatPtr GetFormat() const;
|
||||||
|
};
|
||||||
}
|
|
||||||
|
typedef shared_ptr<Controller> ControllerPtr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
#include "api.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
// 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/ATHENASUB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "tr1.h"
|
||||||
|
|
||||||
|
namespace Athenasub {
|
||||||
|
|
||||||
|
class Model;
|
||||||
|
typedef shared_ptr<Model> ModelPtr;
|
||||||
|
|
||||||
|
class LibAthenaSub {
|
||||||
|
public:
|
||||||
|
LibAthenaSub(const char* hostName);
|
||||||
|
|
||||||
|
ModelPtr CreateModel();
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" Athenasub::LibAthenaSub* CreateLibAthenasub(const char* hostName);
|
|
@ -39,6 +39,7 @@
|
||||||
#include <wx/wfstream.h>
|
#include <wx/wfstream.h>
|
||||||
#include "actionlist.h"
|
#include "actionlist.h"
|
||||||
#include "section.h"
|
#include "section.h"
|
||||||
|
#include "api.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ namespace Athenasub {
|
||||||
typedef std::list<ViewPtr> ViewList;
|
typedef std::list<ViewPtr> ViewList;
|
||||||
typedef std::list<ActionListPtr> ActionStack;
|
typedef std::list<ActionListPtr> ActionStack;
|
||||||
typedef shared_ptr<Format> FormatPtr;
|
typedef shared_ptr<Format> FormatPtr;
|
||||||
|
typedef shared_ptr<Controller> ControllerPtr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SectionPtr> sections;
|
std::vector<SectionPtr> sections;
|
||||||
|
@ -90,8 +92,12 @@ namespace Athenasub {
|
||||||
void Save(wxOutputStream &output,const FormatPtr format=FormatPtr(),const String encoding=L"UTF-8");
|
void Save(wxOutputStream &output,const FormatPtr format=FormatPtr(),const String encoding=L"UTF-8");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
ControllerPtr CreateController();
|
||||||
|
|
||||||
const FormatPtr GetFormat() const { return format; }
|
const FormatPtr GetFormat() const { return format; }
|
||||||
void AddListener(ViewPtr listener);
|
void AddListener(ViewPtr listener);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef shared_ptr<Model> ModelPtr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "athenastring.h"
|
#include "athenastring.h"
|
||||||
#include "section_entry.h"
|
#include "section_entry.h"
|
||||||
#include "tr1.h"
|
#include "tr1.h"
|
||||||
|
#include "api.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "athenastring.h"
|
#include "athenastring.h"
|
||||||
#include "tr1.h"
|
#include "tr1.h"
|
||||||
#include "deltacoder.h"
|
#include "deltacoder.h"
|
||||||
|
#include "api.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include "api.h"
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
// Include the Technical Report 1 headers
|
// Include the Technical Report 1 headers
|
||||||
// This is necessary because some compilers put them on different places
|
// This is necessary because some compilers put them on different places
|
||||||
|
|
||||||
#include <tr1/memory>
|
#include <memory>
|
||||||
#include <tr1/array>
|
#include <array>
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
using std::tr1::shared_ptr;
|
using std::tr1::shared_ptr;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenastring.h"
|
||||||
|
#include "api.h"
|
||||||
|
|
||||||
////////////////////
|
////////////////////
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "athenastring.h"
|
#include "athenastring.h"
|
||||||
|
#include "api.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
// 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/ATHENASUB
|
||||||
|
//
|
||||||
|
// Website: http://www.aegisub.net
|
||||||
|
// Contact: mailto:amz@aegisub.net
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "athenasub.h"
|
||||||
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" LibAthenaSub* CreateLibAthenasub(const char* hostName) {
|
||||||
|
return new LibAthenaSub(hostName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LibAthenaSub::LibAthenaSub(const char* hostName) {
|
||||||
|
(void) hostName;
|
||||||
|
Athenasub::SetHostApplicationName(String(hostName,wxConvUTF8));
|
||||||
|
FormatManager::InitializeFormats();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ModelPtr LibAthenaSub::CreateModel() {
|
||||||
|
return ModelPtr(new Model());
|
||||||
|
}
|
|
@ -243,3 +243,11 @@ String Model::GetRedoMessage(const String owner) const
|
||||||
if (CanRedo()) return redoStack.back()->GetName();
|
if (CanRedo()) return redoStack.back()->GetName();
|
||||||
return L"";
|
return L"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// Create a controller for this model
|
||||||
|
ControllerPtr Athenasub::Model::CreateController()
|
||||||
|
{
|
||||||
|
return ControllerPtr(new Controller(*this));
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
// Contact: mailto:amz@aegisub.net
|
// Contact: mailto:amz@aegisub.net
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#define ATHENA_DLL
|
||||||
#include <aegilib/athenasub.h>
|
#include <aegilib/athenasub.h>
|
||||||
#include <wx/wfstream.h>
|
#include <wx/wfstream.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -49,26 +50,26 @@ int main()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Set up the lib
|
// Set up the lib
|
||||||
FormatManager::InitializeFormats();
|
//FormatManager::InitializeFormats();
|
||||||
Athenasub::SetHostApplicationName(L"Aegilib test program");
|
//Athenasub::SetHostApplicationName(L"Aegilib test program");
|
||||||
|
LibAthenaSub* lib = CreateLibAthenasub("Aegisub test program");
|
||||||
|
|
||||||
// Subtitles model
|
// Subtitles model
|
||||||
Model subs;
|
ModelPtr subs = lib->CreateModel();
|
||||||
Controller control(subs);
|
ControllerPtr control = subs->CreateController();
|
||||||
wxStopWatch timer;
|
wxStopWatch timer;
|
||||||
|
|
||||||
// Load subtitles
|
// Load subtitles
|
||||||
cout << "Loading file... ";
|
cout << "Loading file... ";
|
||||||
timer.Start();
|
timer.Start();
|
||||||
control.LoadFile(L"subs_in.ass",L"UTF-8");
|
control->LoadFile(L"subs_in.ass",L"UTF-8");
|
||||||
timer.Pause();
|
timer.Pause();
|
||||||
cout << "Done in " << timer.Time() << " ms.\n";
|
cout << "Done in " << timer.Time() << " ms.\n";
|
||||||
//system("pause");
|
|
||||||
|
|
||||||
// Save subtitles
|
// Save subtitles
|
||||||
cout << "Saving file... ";
|
cout << "Saving file... ";
|
||||||
timer.Start();
|
timer.Start();
|
||||||
control.SaveFile(L"subs_out.ass",L"UTF-8");
|
control->SaveFile(L"subs_out.ass",L"UTF-8");
|
||||||
timer.Pause();
|
timer.Pause();
|
||||||
cout << "Done in " << timer.Time() << " ms.\n";
|
cout << "Done in " << timer.Time() << " ms.\n";
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ int main()
|
||||||
cout << "Executing action " << n << " times... ";
|
cout << "Executing action " << n << " times... ";
|
||||||
timer.Start();
|
timer.Start();
|
||||||
for (size_t i=0;i<n;i++) {
|
for (size_t i=0;i<n;i++) {
|
||||||
ActionListPtr actions = control.CreateActionList(L"Test");
|
ActionListPtr actions = control->CreateActionList(L"Test");
|
||||||
Selection selection;
|
Selection selection;
|
||||||
selection.AddRange(Range(0,5000));
|
selection.AddRange(Range(0,5000));
|
||||||
selection.AddRange(Range(4500,5500));
|
selection.AddRange(Range(4500,5500));
|
||||||
|
@ -101,7 +102,7 @@ int main()
|
||||||
// Rollback
|
// Rollback
|
||||||
cout << "Undoing " << n << " times... ";
|
cout << "Undoing " << n << " times... ";
|
||||||
for (size_t i=0;i<n-1;i++) {
|
for (size_t i=0;i<n-1;i++) {
|
||||||
control.Undo();
|
control->Undo();
|
||||||
}
|
}
|
||||||
cout << "Done.\n";
|
cout << "Done.\n";
|
||||||
|
|
||||||
|
@ -109,20 +110,20 @@ int main()
|
||||||
cout << "Undoing and redoing " << n*10 << " times... ";
|
cout << "Undoing and redoing " << n*10 << " times... ";
|
||||||
timer.Start();
|
timer.Start();
|
||||||
for (size_t i=0;i<n*10;i++) {
|
for (size_t i=0;i<n*10;i++) {
|
||||||
control.Undo();
|
control->Undo();
|
||||||
control.Redo();
|
control->Redo();
|
||||||
}
|
}
|
||||||
timer.Pause();
|
timer.Pause();
|
||||||
cout << "Done in " << timer.Time() << " ms.\n";
|
cout << "Done in " << timer.Time() << " ms.\n";
|
||||||
|
|
||||||
// Get style test
|
// Get style test
|
||||||
StyleConstPtr style = control.GetStyle(L"japro1_star");
|
StyleConstPtr style = control->GetStyle(L"japro1_star");
|
||||||
cout << "Style " << style->GetName().mb_str() << " font is " << style->GetFontName().mb_str() << " " << style->GetFontSize() << ".\n";
|
cout << "Style " << style->GetName().mb_str() << " font is " << style->GetFontName().mb_str() << " " << style->GetFontSize() << ".\n";
|
||||||
|
|
||||||
// Save a few more
|
// Save a few more
|
||||||
control.SaveFile(L"subs_out2.ass",L"UTF-8");
|
control->SaveFile(L"subs_out2.ass",L"UTF-8");
|
||||||
control.Undo();
|
control->Undo();
|
||||||
control.SaveFile(L"subs_out3.ass",L"UTF-8");
|
control->SaveFile(L"subs_out3.ass",L"UTF-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (std::exception &e) {
|
catch (std::exception &e) {
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
OpenMP="false"
|
OpenMP="false"
|
||||||
UsePrecompiledHeader="0"
|
UsePrecompiledHeader="0"
|
||||||
WarningLevel="4"
|
WarningLevel="4"
|
||||||
Detect64BitPortabilityProblems="true"
|
Detect64BitPortabilityProblems="false"
|
||||||
DebugInformationFormat="3"
|
DebugInformationFormat="3"
|
||||||
DisableSpecificWarnings="4996"
|
DisableSpecificWarnings="4996"
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue