Originally committed to SVN as r2298.
This commit is contained in:
parent
5b38a17529
commit
b828b4a6ae
21 changed files with 143 additions and 150 deletions
|
@ -89,7 +89,7 @@
|
||||||
Name="Release|Win32"
|
Name="Release|Win32"
|
||||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||||
IntermediateDirectory="$(ConfigurationName)"
|
IntermediateDirectory="$(ConfigurationName)"
|
||||||
ConfigurationType="4"
|
ConfigurationType="2"
|
||||||
CharacterSet="1"
|
CharacterSet="1"
|
||||||
WholeProgramOptimization="1"
|
WholeProgramOptimization="1"
|
||||||
>
|
>
|
||||||
|
@ -139,12 +139,15 @@
|
||||||
Name="VCPreLinkEventTool"
|
Name="VCPreLinkEventTool"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLibrarianTool"
|
Name="VCLinkerTool"
|
||||||
LinkLibraryDependencies="false"
|
OutputFile="../bin/aegilib.dll"
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCALinkTool"
|
Name="VCALinkTool"
|
||||||
/>
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManifestTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCXDCMakeTool"
|
Name="VCXDCMakeTool"
|
||||||
/>
|
/>
|
||||||
|
@ -154,6 +157,9 @@
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCFxCopTool"
|
Name="VCFxCopTool"
|
||||||
/>
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAppVerifierTool"
|
||||||
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCPostBuildEventTool"
|
Name="VCPostBuildEventTool"
|
||||||
/>
|
/>
|
||||||
|
@ -323,7 +329,7 @@
|
||||||
Name="Formats"
|
Name="Formats"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\include\aegilib\format_handler.h"
|
RelativePath=".\src\format_handler.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
|
|
|
@ -37,12 +37,14 @@
|
||||||
|
|
||||||
#include "athenasub.h"
|
#include "athenasub.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
typedef Athenasub::ILibAthenaSub* (__stdcall *CreateLibAthenasubPtr)(const char*);
|
typedef Athenasub::ILibAthenaSub* (__stdcall *CreateLibAthenasubPtr)(const char*);
|
||||||
|
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
inline LibAthenaSub Create(HMODULE module,const char* hostName) {
|
inline LibAthenaSub Create(HMODULE module,const char* hostName) {
|
||||||
CreateLibAthenasubPtr CreateLib = (CreateLibAthenasubPtr)GetProcAddress(module,"CreateLibAthenaSub");
|
CreateLibAthenasubPtr CreateLib = (CreateLibAthenasubPtr)GetProcAddress(module,"CreateLibAthenasub");
|
||||||
|
printf("Pointer at %x.\n",CreateLib);
|
||||||
return LibAthenaSub(CreateLib(hostName));
|
return LibAthenaSub(CreateLib(hostName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ namespace Athenasub {
|
||||||
virtual size_t GetSectionCount() const = 0;
|
virtual size_t GetSectionCount() const = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~IModel();
|
virtual ~IModel() {}
|
||||||
|
|
||||||
virtual Controller CreateController()=0;
|
virtual Controller CreateController()=0;
|
||||||
virtual Format GetFormat() const=0;
|
virtual Format GetFormat() const=0;
|
||||||
|
@ -338,7 +338,7 @@ namespace Athenasub {
|
||||||
virtual String GetName() const = 0;
|
virtual String GetName() const = 0;
|
||||||
virtual StringArray GetReadExtensions() const = 0;
|
virtual StringArray GetReadExtensions() const = 0;
|
||||||
virtual StringArray GetWriteExtensions() const = 0;
|
virtual StringArray GetWriteExtensions() const = 0;
|
||||||
//virtual FormatHandler GetHandler(Model &model) const = 0;
|
virtual FormatHandler GetHandler(IModel &model) const = 0;
|
||||||
|
|
||||||
virtual bool CanStoreText() const = 0;
|
virtual bool CanStoreText() const = 0;
|
||||||
virtual bool CanStoreImages() const = 0;
|
virtual bool CanStoreImages() const = 0;
|
||||||
|
@ -363,6 +363,9 @@ namespace Athenasub {
|
||||||
class IFormatHandler {
|
class IFormatHandler {
|
||||||
public:
|
public:
|
||||||
virtual ~IFormatHandler() {}
|
virtual ~IFormatHandler() {}
|
||||||
|
|
||||||
|
virtual void Load(wxInputStream &file,const String encoding) = 0;
|
||||||
|
virtual void Save(wxOutputStream &file,const String encoding) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -372,10 +375,10 @@ namespace Athenasub {
|
||||||
class IAction {
|
class IAction {
|
||||||
public:
|
public:
|
||||||
virtual ~IAction() {}
|
virtual ~IAction() {}
|
||||||
virtual Action GetAntiAction(ConstModel model) const = 0;
|
virtual Action GetAntiAction(const IModel& model) const = 0;
|
||||||
virtual void Execute(Model model) = 0;
|
virtual void Execute(IModel& model) = 0;
|
||||||
|
|
||||||
Section GetSection(Model model,const String &name) const { return model->GetSection(name); }
|
Section GetSection(const IModel& model,const String &name) const { return model.GetSection(name); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -387,7 +390,7 @@ namespace Athenasub {
|
||||||
virtual String GetName() const = 0;
|
virtual String GetName() const = 0;
|
||||||
virtual String GetOwner() const = 0;
|
virtual String GetOwner() const = 0;
|
||||||
|
|
||||||
virtual void AddAction(const Action action) = 0;
|
virtual void AddAction(Action action) = 0;
|
||||||
virtual void Finish() = 0;
|
virtual void Finish() = 0;
|
||||||
|
|
||||||
virtual void InsertLine(Entry line,int position=-1,const String section=L"") = 0;
|
virtual void InsertLine(Entry line,int position=-1,const String section=L"") = 0;
|
||||||
|
@ -422,7 +425,7 @@ namespace Athenasub {
|
||||||
virtual void RemoveEntryByIndex(size_t index) = 0;
|
virtual void RemoveEntryByIndex(size_t index) = 0;
|
||||||
virtual void RemoveEntry(Entry entry) = 0;
|
virtual void RemoveEntry(Entry entry) = 0;
|
||||||
virtual Entry GetEntry(size_t index) const = 0;
|
virtual Entry GetEntry(size_t index) const = 0;
|
||||||
virtual Entry& GetEntryRef(size_t index) const = 0;
|
virtual Entry& GetEntryRef(size_t index) = 0;
|
||||||
virtual size_t GetEntryCount() const = 0;
|
virtual size_t GetEntryCount() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -448,8 +451,8 @@ namespace Athenasub {
|
||||||
|
|
||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
Time operator+(const ITime& p1,int p2) { Time res = p1.Clone(); res->SetMS(res->GetMS()+p2); return res; }
|
inline Time operator+(const ITime& p1,int p2) { Time res = p1.Clone(); res->SetMS(res->GetMS()+p2); return res; }
|
||||||
Time operator-(const ITime& p1,int p2) { Time res = p1.Clone(); res->SetMS(res->GetMS()-p2); return res; }
|
inline Time operator-(const ITime& p1,int p2) { Time res = p1.Clone(); res->SetMS(res->GetMS()-p2); return res; }
|
||||||
bool operator==(const ITime& p1,const ITime& p2) { return p1.GetMS() == p2.GetMS(); }
|
inline bool operator==(const ITime& p1,const ITime& p2) { return p1.GetMS() == p2.GetMS(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ ActionInsert::ActionInsert(Entry data,int line,const String &sName)
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Create anti-action for insert
|
// Create anti-action for insert
|
||||||
Action ActionInsert::GetAntiAction(ConstModel model) const
|
Action ActionInsert::GetAntiAction(const IModel& model) const
|
||||||
{
|
{
|
||||||
(void) model;
|
(void) model;
|
||||||
String sect = section;
|
String sect = section;
|
||||||
|
@ -59,7 +59,7 @@ Action ActionInsert::GetAntiAction(ConstModel model) const
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Execute insertion
|
// Execute insertion
|
||||||
void ActionInsert::Execute(Model model)
|
void ActionInsert::Execute(IModel& model)
|
||||||
{
|
{
|
||||||
// Find the section to insert it on
|
// Find the section to insert it on
|
||||||
String sectionName = section;
|
String sectionName = section;
|
||||||
|
@ -83,9 +83,9 @@ ActionRemove::ActionRemove(int line,const String &sName)
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Create anti-action for remove
|
// Create anti-action for remove
|
||||||
Action ActionRemove::GetAntiAction(ConstModel model) const
|
Action ActionRemove::GetAntiAction(const IModel& model) const
|
||||||
{
|
{
|
||||||
SectionPtr sect = GetSection(model,section);
|
Section sect = GetSection(model,section);
|
||||||
Entry entry = sect->GetEntry(lineNumber);
|
Entry entry = sect->GetEntry(lineNumber);
|
||||||
return Action(new ActionInsert(entry,lineNumber,section));
|
return Action(new ActionInsert(entry,lineNumber,section));
|
||||||
}
|
}
|
||||||
|
@ -93,12 +93,12 @@ Action ActionRemove::GetAntiAction(ConstModel model) const
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
// Execute removal
|
// Execute removal
|
||||||
void ActionRemove::Execute(Model model)
|
void ActionRemove::Execute(IModel& model)
|
||||||
{
|
{
|
||||||
// Find the section to remote it from
|
// Find the section to remote it from
|
||||||
String sect = section;
|
String sect = section;
|
||||||
if (sect.IsEmpty()) THROW_ATHENA_EXCEPTION(Exception::TODO); // TODO
|
if (sect.IsEmpty()) THROW_ATHENA_EXCEPTION(Exception::TODO); // TODO
|
||||||
SectionPtr section = GetSection(model,sect);
|
Section section = GetSection(model,sect);
|
||||||
|
|
||||||
// Remove the line
|
// Remove the line
|
||||||
section->RemoveEntryByIndex(lineNumber);
|
section->RemoveEntryByIndex(lineNumber);
|
||||||
|
@ -118,7 +118,7 @@ ActionModify::ActionModify(shared_ptr<void> _delta,int line,const String &sName)
|
||||||
|
|
||||||
/////////////////////////////////
|
/////////////////////////////////
|
||||||
// Create anti-action for insert
|
// Create anti-action for insert
|
||||||
Action ActionModify::GetAntiAction(ConstModel model) const
|
Action ActionModify::GetAntiAction(const IModel& model) const
|
||||||
{
|
{
|
||||||
// Get section and original line
|
// Get section and original line
|
||||||
Section sect = GetSection(model,section);
|
Section sect = GetSection(model,section);
|
||||||
|
@ -142,7 +142,7 @@ Action ActionModify::GetAntiAction(ConstModel model) const
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Execute insertion
|
// Execute insertion
|
||||||
void ActionModify::Execute(Model model)
|
void ActionModify::Execute(IModel& model)
|
||||||
{
|
{
|
||||||
// Find the section to modify
|
// Find the section to modify
|
||||||
String sectionName = section;
|
String sectionName = section;
|
||||||
|
@ -163,10 +163,10 @@ void ActionModify::Execute(Model model)
|
||||||
ActionModifyBatch::ActionModifyBatch(std::vector<Entry> _entries, std::vector<shared_ptr<void> > _deltas, Selection _selection,const String &_section,bool _noTextFields)
|
ActionModifyBatch::ActionModifyBatch(std::vector<Entry> _entries, std::vector<shared_ptr<void> > _deltas, Selection _selection,const String &_section,bool _noTextFields)
|
||||||
: entries(_entries), deltas(_deltas), selection(_selection), section(_section), noTextFields(_noTextFields) {}
|
: entries(_entries), deltas(_deltas), selection(_selection), section(_section), noTextFields(_noTextFields) {}
|
||||||
|
|
||||||
Action ActionModifyBatch::GetAntiAction(ConstModel model) const
|
Action ActionModifyBatch::GetAntiAction(const IModel& model) const
|
||||||
{
|
{
|
||||||
// Get section
|
// Get section
|
||||||
SectionPtr sect = GetSection(model,section);
|
Section sect = GetSection(model,section);
|
||||||
size_t len = selection->GetCount();
|
size_t len = selection->GetCount();
|
||||||
std::vector<VoidPtr> _deltas(len);
|
std::vector<VoidPtr> _deltas(len);
|
||||||
std::vector<Entry> oldEntries(len);
|
std::vector<Entry> oldEntries(len);
|
||||||
|
@ -190,7 +190,7 @@ Action ActionModifyBatch::GetAntiAction(ConstModel model) const
|
||||||
return Action(new ActionModifyBatch(oldEntries,_deltas,selection,section,noTextFields));
|
return Action(new ActionModifyBatch(oldEntries,_deltas,selection,section,noTextFields));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionModifyBatch::Execute(Model model)
|
void ActionModifyBatch::Execute(IModel& model)
|
||||||
{
|
{
|
||||||
// Find the section to modify
|
// Find the section to modify
|
||||||
size_t len = selection->GetCount();
|
size_t len = selection->GetCount();
|
||||||
|
|
|
@ -51,8 +51,8 @@ namespace Athenasub {
|
||||||
ActionInsert(Entry entry,int line,const String §ion);
|
ActionInsert(Entry entry,int line,const String §ion);
|
||||||
~ActionInsert() {}
|
~ActionInsert() {}
|
||||||
|
|
||||||
Action GetAntiAction(ConstModel model) const;
|
Action GetAntiAction(const IModel& model) const;
|
||||||
void Execute(Model model);
|
void Execute(IModel& model);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove line
|
// Remove line
|
||||||
|
@ -65,8 +65,8 @@ namespace Athenasub {
|
||||||
ActionRemove(int line,const String §ion);
|
ActionRemove(int line,const String §ion);
|
||||||
~ActionRemove() {}
|
~ActionRemove() {}
|
||||||
|
|
||||||
Action GetAntiAction(ConstModel model) const;
|
Action GetAntiAction(const IModel& model) const;
|
||||||
void Execute(Model model);
|
void Execute(IModel& model);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Modify line
|
// Modify line
|
||||||
|
@ -83,8 +83,8 @@ namespace Athenasub {
|
||||||
ActionModify(shared_ptr<void> delta,int line,const String §ion);
|
ActionModify(shared_ptr<void> delta,int line,const String §ion);
|
||||||
~ActionModify() {}
|
~ActionModify() {}
|
||||||
|
|
||||||
Action GetAntiAction(ConstModel model) const;
|
Action GetAntiAction(const IModel& model) const;
|
||||||
void Execute(Model model);
|
void Execute(IModel& model);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Modify several lines
|
// Modify several lines
|
||||||
|
@ -100,7 +100,7 @@ namespace Athenasub {
|
||||||
ActionModifyBatch(std::vector<Entry> entries,std::vector<VoidPtr> deltas,Selection selection,const String §ion,bool noTextFields);
|
ActionModifyBatch(std::vector<Entry> entries,std::vector<VoidPtr> deltas,Selection selection,const String §ion,bool noTextFields);
|
||||||
~ActionModifyBatch() {}
|
~ActionModifyBatch() {}
|
||||||
|
|
||||||
Action GetAntiAction(ConstModel model) const;
|
Action GetAntiAction(const IModel& model) const;
|
||||||
void Execute(Model model);
|
void Execute(IModel& model);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ namespace Athenasub {
|
||||||
virtual String GetName() const { return actionName; }
|
virtual String GetName() const { return actionName; }
|
||||||
virtual String GetOwner() const { return owner; }
|
virtual String GetOwner() const { return owner; }
|
||||||
|
|
||||||
virtual void AddAction(const Action action);
|
virtual void AddAction(Action action);
|
||||||
virtual void Finish();
|
virtual void Finish();
|
||||||
|
|
||||||
virtual void InsertLine(Entry line,int position=-1,const String section=L"");
|
virtual void InsertLine(Entry line,int position=-1,const String section=L"");
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "athenasub.h"
|
#include "athenasub.h"
|
||||||
#include "actionlist.h"
|
#include "actionlist.h"
|
||||||
#include "format_manager.h"
|
#include "format_manager.h"
|
||||||
|
#include "selection.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,3 +160,10 @@ ConstEntry CController::GetEntry(size_t n,String section) const
|
||||||
if (!sect) THROW_ATHENA_EXCEPTION(Exception::Invalid_Section);
|
if (!sect) THROW_ATHENA_EXCEPTION(Exception::Invalid_Section);
|
||||||
return sect->GetEntry(n);
|
return sect->GetEntry(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////
|
||||||
|
// Create a selection
|
||||||
|
Selection CController::CreateSelection() {
|
||||||
|
return Selection(new CSelection());
|
||||||
|
}
|
||||||
|
|
|
@ -37,59 +37,3 @@
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
|
||||||
// Constructors
|
|
||||||
Exception::Exception(ExceptionList _code)
|
|
||||||
: std::exception(GetMessageChar(_code))
|
|
||||||
{
|
|
||||||
code = _code;
|
|
||||||
}
|
|
||||||
|
|
||||||
Exception::Exception(ExceptionList _code,const char *file,const long line)
|
|
||||||
: std::exception(GetMessageFile(_code,file,line))
|
|
||||||
{
|
|
||||||
code = _code;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////
|
|
||||||
// Get message string
|
|
||||||
const char* Exception::GetMessageChar(int code)
|
|
||||||
{
|
|
||||||
switch (code) {
|
|
||||||
case Unknown: return "Unknown.";
|
|
||||||
case No_Format_Handler: return "Could not find a suitable format handler.";
|
|
||||||
case Invalid_ActionList: return "Invalid manipulator.";
|
|
||||||
case Section_Already_Exists: return "The specified section already exists in this model.";
|
|
||||||
case Unknown_Format: return "The specified file format is unknown.";
|
|
||||||
case Parse_Error: return "Parse error.";
|
|
||||||
case Unsupported_Format_Feature: return "This feature is not supported by this format.";
|
|
||||||
case Invalid_Token: return "Invalid type for this token.";
|
|
||||||
case Out_Of_Range: return "Out of range.";
|
|
||||||
case Invalid_Section: return "Invalid section.";
|
|
||||||
case Internal_Error: return "Internal error.";
|
|
||||||
case TODO: return "TODO";
|
|
||||||
}
|
|
||||||
return "Invalid code.";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////
|
|
||||||
// Insert file and line on message
|
|
||||||
const char* Exception::GetMessageFile(int code,const char *file,long line)
|
|
||||||
{
|
|
||||||
static std::string str = GetMessageChar(code);
|
|
||||||
str = str + " (" + file + ":";
|
|
||||||
char buffer[16];
|
|
||||||
_itoa_s(line,buffer,10);
|
|
||||||
str = str + buffer + ")";
|
|
||||||
return str.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////
|
|
||||||
// Get code
|
|
||||||
int Exception::GetCode()
|
|
||||||
{
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
|
@ -43,20 +43,20 @@ namespace Athenasub {
|
||||||
// Format handler interface
|
// Format handler interface
|
||||||
class CFormatHandler : public IFormatHandler {
|
class CFormatHandler : public IFormatHandler {
|
||||||
private:
|
private:
|
||||||
Model model;
|
IModel& model;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~CFormatHandler() {}
|
virtual ~CFormatHandler() {}
|
||||||
|
|
||||||
Model GetModel() const { return model; }
|
IModel& GetModel() const { return model; }
|
||||||
|
|
||||||
void AddSection(String name) { model->AddSection(name); }
|
void AddSection(String name) { model.AddSection(name); }
|
||||||
Section GetSection(String name) const { return model->GetSection(name); }
|
Section GetSection(String name) const { return model.GetSection(name); }
|
||||||
Section GetSectionByIndex(size_t index) const { return model->GetSectionByIndex(index); }
|
Section GetSectionByIndex(size_t index) const { return model.GetSectionByIndex(index); }
|
||||||
size_t GetSectionCount() const { return model->GetSectionCount(); }
|
size_t GetSectionCount() const { return model.GetSectionCount(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFormatHandler(Model _model) : model(_model) {}
|
CFormatHandler(IModel& _model) : model(_model) {}
|
||||||
|
|
||||||
virtual void Load(wxInputStream &file,const String encoding) = 0;
|
virtual void Load(wxInputStream &file,const String encoding) = 0;
|
||||||
virtual void Save(wxOutputStream &file,const String encoding) = 0;
|
virtual void Save(wxOutputStream &file,const String encoding) = 0;
|
||||||
|
|
|
@ -41,24 +41,24 @@ using namespace Athenasub;
|
||||||
|
|
||||||
////////
|
////////
|
||||||
// List
|
// List
|
||||||
std::vector<const FormatPtr> FormatManager::formats;
|
std::vector<Format> FormatManager::formats;
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
// Add a format
|
// Add a format
|
||||||
void FormatManager::AddFormat(const FormatPtr format)
|
void FormatManager::AddFormat(const Format format)
|
||||||
{
|
{
|
||||||
formats.push_back(format);
|
formats.push_back(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
// Initialzie all built-in formats
|
// Initialize all built-in formats
|
||||||
void FormatManager::InitializeFormats()
|
void FormatManager::InitializeFormats()
|
||||||
{
|
{
|
||||||
formats.push_back(FormatPtr(new FormatASS));
|
formats.push_back(Format(new FormatASS()));
|
||||||
formats.push_back(FormatPtr(new FormatSSA));
|
formats.push_back(Format(new FormatSSA()));
|
||||||
formats.push_back(FormatPtr(new FormatASS2));
|
formats.push_back(Format(new FormatASS2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,20 +80,20 @@ int FormatManager::GetFormatCount()
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
// By index
|
// By index
|
||||||
const FormatPtr FormatManager::GetFormatByIndex(const int index)
|
const Format FormatManager::GetFormatByIndex(const int index)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return formats.at(index);
|
return formats.at(index);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
return FormatPtr();
|
return Format();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// By filename
|
// By filename
|
||||||
const FormatPtr FormatManager::GetFormatFromFilename(const String &filename,bool read)
|
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++) {
|
||||||
|
@ -105,18 +105,18 @@ const FormatPtr FormatManager::GetFormatFromFilename(const String &filename,bool
|
||||||
if (filename.EndsWith(exts[j])) return formats[i];
|
if (filename.EndsWith(exts[j])) return formats[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FormatPtr();
|
return Format();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// By format name
|
// By format name
|
||||||
const FormatPtr FormatManager::GetFormatFromName(const String &name)
|
const Format FormatManager::GetFormatFromName(const String &name)
|
||||||
{
|
{
|
||||||
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 (name == formats[i]->GetName()) return formats[i];
|
if (name == formats[i]->GetName()) return formats[i];
|
||||||
}
|
}
|
||||||
return FormatPtr();
|
return Format();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ void FormatHandlerASS::Load(wxInputStream &file,const String encoding)
|
||||||
int version = 1;
|
int version = 1;
|
||||||
wxString curGroup = L"-";
|
wxString curGroup = L"-";
|
||||||
wxString prevGroup = L"-";
|
wxString prevGroup = L"-";
|
||||||
SectionPtr section = SectionPtr();
|
Section section = Section();
|
||||||
|
|
||||||
// Read file
|
// Read file
|
||||||
while (reader.HasMoreLines()) {
|
while (reader.HasMoreLines()) {
|
||||||
|
@ -136,7 +136,7 @@ void FormatHandlerASS::Load(wxInputStream &file,const String encoding)
|
||||||
if (cur[0] == L'[') continue;
|
if (cur[0] == L'[') continue;
|
||||||
|
|
||||||
// Create and insert line
|
// Create and insert line
|
||||||
EntryPtr entry = MakeEntry(cur,section,version);
|
Entry entry = MakeEntry(cur,section,version);
|
||||||
if (entry) section->AddEntry(entry);
|
if (entry) section->AddEntry(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ void FormatHandlerASS::Save(wxOutputStream &file,const String encoding)
|
||||||
size_t len = sections.size();
|
size_t len = sections.size();
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
// See if it exists
|
// See if it exists
|
||||||
SectionPtr section = GetSection(sections[i]);
|
Section section = GetSection(sections[i]);
|
||||||
if (section) {
|
if (section) {
|
||||||
// Add a spacer
|
// Add a spacer
|
||||||
if (i != 0) writer.WriteLineToFile(_T(""));
|
if (i != 0) writer.WriteLineToFile(_T(""));
|
||||||
|
@ -185,11 +185,11 @@ void FormatHandlerASS::Save(wxOutputStream &file,const String encoding)
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Create line
|
// Create line
|
||||||
EntryPtr FormatHandlerASS::MakeEntry(const String &data,SectionPtr section,int version)
|
Entry FormatHandlerASS::MakeEntry(const String &data,Section section,int version)
|
||||||
{
|
{
|
||||||
// Variables
|
// Variables
|
||||||
const String group = section->GetName();
|
const String group = section->GetName();
|
||||||
EntryPtr final;
|
Entry final;
|
||||||
|
|
||||||
// Attachments
|
// Attachments
|
||||||
if (group == _T("Fonts") || group == _T("Graphics")) {
|
if (group == _T("Fonts") || group == _T("Graphics")) {
|
||||||
|
@ -229,17 +229,17 @@ EntryPtr FormatHandlerASS::MakeEntry(const String &data,SectionPtr section,int v
|
||||||
// Script info
|
// Script info
|
||||||
else if (group == _T("Script Info")) {
|
else if (group == _T("Script Info")) {
|
||||||
// Discard comments
|
// Discard comments
|
||||||
if (data.Left(1) == _T(";")) return EntryPtr();
|
if (data.Left(1) == _T(";")) return Entry();
|
||||||
|
|
||||||
// Parse property
|
// Parse property
|
||||||
size_t pos = data.Find(_T(':'));
|
size_t pos = data.Find(_T(':'));
|
||||||
if (pos == wxNOT_FOUND) return EntryPtr();
|
if (pos == wxNOT_FOUND) return Entry();
|
||||||
wxString key = data.Left(pos).Trim(true).Trim(false);
|
wxString key = data.Left(pos).Trim(true).Trim(false);
|
||||||
wxString value = data.Mid(pos+1).Trim(true).Trim(false);
|
wxString value = data.Mid(pos+1).Trim(true).Trim(false);
|
||||||
|
|
||||||
// Insert property
|
// Insert property
|
||||||
section->SetProperty(key,value);
|
section->SetProperty(key,value);
|
||||||
return EntryPtr();
|
return Entry();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown group, just leave it intact
|
// Unknown group, just leave it intact
|
||||||
|
@ -331,7 +331,7 @@ void FormatHandlerASS::ProcessGroup(String cur,String &curGroup,int &version) {
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
// Write a section to the file
|
// Write a section to the file
|
||||||
void FormatHandlerASS::WriteSection(TextFileWriter &writer,SectionPtr section)
|
void FormatHandlerASS::WriteSection(TextFileWriter &writer,Section section)
|
||||||
{
|
{
|
||||||
// Write name
|
// Write name
|
||||||
wxString name = section->GetName();
|
wxString name = section->GetName();
|
||||||
|
@ -359,7 +359,7 @@ void FormatHandlerASS::WriteSection(TextFileWriter &writer,SectionPtr section)
|
||||||
// Write contents
|
// Write contents
|
||||||
size_t entries = section->GetEntryCount();
|
size_t entries = section->GetEntryCount();
|
||||||
for (size_t i=0;i<entries;i++) {
|
for (size_t i=0;i<entries;i++) {
|
||||||
EntryConstPtr entry = section->GetEntry(i);
|
ConstEntry entry = section->GetEntry(i);
|
||||||
shared_ptr<const SerializeText> serial = dynamic_pointer_cast<const SerializeText>(entry);
|
shared_ptr<const SerializeText> serial = dynamic_pointer_cast<const SerializeText>(entry);
|
||||||
writer.WriteLineToFile(serial->ToText(formatVersion));
|
writer.WriteLineToFile(serial->ToText(formatVersion));
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ void FormatHandlerASS::MakeValid()
|
||||||
if (formatVersion != 1) THROW_ATHENA_EXCEPTION(Exception::TODO);
|
if (formatVersion != 1) THROW_ATHENA_EXCEPTION(Exception::TODO);
|
||||||
|
|
||||||
// Check for [Script Info]
|
// Check for [Script Info]
|
||||||
SectionPtr section = GetSection(L"Script Info");
|
Section section = GetSection(L"Script Info");
|
||||||
if (!section) AddSection(L"Script Info");
|
if (!section) AddSection(L"Script Info");
|
||||||
section = GetSection(L"Script Info");
|
section = GetSection(L"Script Info");
|
||||||
if (!section) THROW_ATHENA_EXCEPTION(Exception::Internal_Error);
|
if (!section) THROW_ATHENA_EXCEPTION(Exception::Internal_Error);
|
||||||
|
|
|
@ -53,9 +53,9 @@ namespace Athenasub {
|
||||||
private:
|
private:
|
||||||
int formatVersion;
|
int formatVersion;
|
||||||
|
|
||||||
Entry MakeEntry(const String &data,SectionPtr section,int version);
|
Entry MakeEntry(const String &data,Section section,int version);
|
||||||
void ProcessGroup(String cur,String &curGroup,int &version);
|
void ProcessGroup(String cur,String &curGroup,int &version);
|
||||||
void WriteSection(TextFileWriter &writer,SectionPtr section);
|
void WriteSection(TextFileWriter &writer,Section section);
|
||||||
void MakeValid();
|
void MakeValid();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -67,16 +67,23 @@ namespace Athenasub {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Advanced Substation Alpha format base class
|
// Advanced Substation Alpha format base class
|
||||||
class FormatASSFamily : public Format {
|
class FormatASSFamily : public IFormat {
|
||||||
public:
|
public:
|
||||||
virtual ~FormatASSFamily() {}
|
virtual ~FormatASSFamily() {}
|
||||||
|
|
||||||
bool CanStoreText() const { return true; }
|
bool CanStoreText() const { return true; }
|
||||||
|
bool CanStoreImages() const { return false; }
|
||||||
|
bool CanUseFrames() const { return false; }
|
||||||
bool CanUseTime() const { return true; }
|
bool CanUseTime() const { return true; }
|
||||||
|
|
||||||
bool HasStyles() const { return true; }
|
bool HasStyles() const { return true; }
|
||||||
bool HasMargins() const { return true; }
|
bool HasMargins() const { return true; }
|
||||||
bool HasActors() const { return true; }
|
bool HasActors() const { return true; }
|
||||||
|
virtual bool HasUserField() const { return false; }
|
||||||
|
virtual String GetUserFieldName() const { return _T(""); }
|
||||||
|
|
||||||
|
virtual int GetTimingPrecision() const { return 10; }
|
||||||
|
virtual int GetMaxTime() const { return 35999990; }
|
||||||
|
|
||||||
Dialogue CreateDialogue() const { return Dialogue(new DialogueASS()); }
|
Dialogue CreateDialogue() const { return Dialogue(new DialogueASS()); }
|
||||||
Style CreateStyle() const { return Style(new StyleASS()); }
|
Style CreateStyle() const { return Style(new StyleASS()); }
|
||||||
|
@ -85,7 +92,7 @@ namespace Athenasub {
|
||||||
// Substation Alpha
|
// Substation Alpha
|
||||||
class FormatSSA : public FormatASSFamily {
|
class FormatSSA : public FormatASSFamily {
|
||||||
public:
|
public:
|
||||||
FormatHandler GetHandler(CModel &model) const { return FormatHandler(new FormatHandlerASS(model,0)); }
|
FormatHandler GetHandler(IModel &model) const { return FormatHandler(new FormatHandlerASS((CModel&)model,0)); }
|
||||||
String GetName() const { return L"Substation Alpha"; }
|
String GetName() const { return L"Substation Alpha"; }
|
||||||
StringArray GetReadExtensions() const;
|
StringArray GetReadExtensions() const;
|
||||||
StringArray GetWriteExtensions() const;
|
StringArray GetWriteExtensions() const;
|
||||||
|
@ -94,7 +101,7 @@ namespace Athenasub {
|
||||||
// Advanced Substation Alpha
|
// Advanced Substation Alpha
|
||||||
class FormatASS : public FormatASSFamily {
|
class FormatASS : public FormatASSFamily {
|
||||||
public:
|
public:
|
||||||
FormatHandler GetHandler(CModel &model) const { return FormatHandler(new FormatHandlerASS(model,1)); }
|
FormatHandler GetHandler(IModel &model) const { return FormatHandler(new FormatHandlerASS((CModel&)model,1)); }
|
||||||
String GetName() const { return L"Advanced Substation Alpha"; }
|
String GetName() const { return L"Advanced Substation Alpha"; }
|
||||||
StringArray GetReadExtensions() const;
|
StringArray GetReadExtensions() const;
|
||||||
StringArray GetWriteExtensions() const;
|
StringArray GetWriteExtensions() const;
|
||||||
|
@ -103,7 +110,7 @@ namespace Athenasub {
|
||||||
// Advanced Substation Alpha 2
|
// Advanced Substation Alpha 2
|
||||||
class FormatASS2 : public FormatASSFamily {
|
class FormatASS2 : public FormatASSFamily {
|
||||||
public:
|
public:
|
||||||
FormatHandler GetHandler(CModel &model) const { return FormatHandler(new FormatHandlerASS(model,2)); }
|
FormatHandler GetHandler(IModel &model) const { return FormatHandler(new FormatHandlerASS((CModel&)model,2)); }
|
||||||
String GetName() const { return L"Advanced Substation Alpha 2"; }
|
String GetName() const { return L"Advanced Substation Alpha 2"; }
|
||||||
StringArray GetReadExtensions() const;
|
StringArray GetReadExtensions() const;
|
||||||
StringArray GetWriteExtensions() const;
|
StringArray GetWriteExtensions() const;
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
namespace Athenasub {
|
namespace Athenasub {
|
||||||
|
|
||||||
// Raw line
|
// Raw line
|
||||||
class PlainASS : public PlainText, public SerializeText {
|
class PlainASS : public CPlainText, public SerializeText {
|
||||||
private:
|
private:
|
||||||
String data;
|
String data;
|
||||||
String ToText(int param) const { (void)param; return data; }
|
String ToText(int param) const { (void)param; return data; }
|
||||||
|
@ -51,7 +51,7 @@ namespace Athenasub {
|
||||||
|
|
||||||
// Basic features
|
// Basic features
|
||||||
String GetDefaultGroup() const { return L"Events"; }
|
String GetDefaultGroup() const { return L"Events"; }
|
||||||
EntryPtr Clone() const { return EntryPtr(new PlainASS(*this)); }
|
Entry Clone() const { return Entry(new PlainASS(*this)); }
|
||||||
|
|
||||||
String GetText() const { return data; }
|
String GetText() const { return data; }
|
||||||
void SetText(const String &_data) { data = _data; }
|
void SetText(const String &_data) { data = _data; }
|
||||||
|
|
|
@ -52,5 +52,7 @@ CLibAthenaSub::CLibAthenaSub(const char* hostName) {
|
||||||
|
|
||||||
|
|
||||||
Model CLibAthenaSub::CreateModel() {
|
Model CLibAthenaSub::CreateModel() {
|
||||||
return Model(new CModel());
|
shared_ptr<CModel> model(new CModel());
|
||||||
|
model->SetWeakPtr(model);
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include "Athenasub.h"
|
#include "Athenasub.h"
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
#include "controller.h"
|
||||||
using namespace Athenasub;
|
using namespace Athenasub;
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,10 +63,10 @@ void CModel::DispatchNotifications(Notification notification) const
|
||||||
void CModel::ProcessActionList(ActionList _actionList,int type)
|
void CModel::ProcessActionList(ActionList _actionList,int type)
|
||||||
{
|
{
|
||||||
// Copy the list
|
// Copy the list
|
||||||
ActionList actions = ActionList(new CActionList(_actionList));
|
shared_ptr<CActionList> actions = shared_ptr<CActionList>(new CActionList(*static_pointer_cast<CActionList>(_actionList)));
|
||||||
|
|
||||||
// Setup undo
|
// Setup undo
|
||||||
ActionList undo = ActionList(new CActionList(actions->model,actions->actionName,actions->owner,actions->undoAble));
|
shared_ptr<CActionList> undo = shared_ptr<CActionList>(new CActionList(actions->model,actions->actionName,actions->owner,actions->undoAble));
|
||||||
ActionStack *stack;
|
ActionStack *stack;
|
||||||
if (type == 1) stack = &redoStack;
|
if (type == 1) stack = &redoStack;
|
||||||
else stack = &undoStack;
|
else stack = &undoStack;
|
||||||
|
@ -93,7 +94,7 @@ void CModel::ProcessActionList(ActionList _actionList,int type)
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Load subtitles
|
// Load subtitles
|
||||||
void CModel::Load(wxInputStream &input,const FormatPtr _format,const String encoding)
|
void CModel::Load(wxInputStream &input,const Format _format,const String encoding)
|
||||||
{
|
{
|
||||||
// Autodetect format
|
// Autodetect format
|
||||||
if (!_format) {
|
if (!_format) {
|
||||||
|
@ -104,7 +105,7 @@ void CModel::Load(wxInputStream &input,const FormatPtr _format,const String enco
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get handler
|
// Get handler
|
||||||
FormatHandlerPtr handler = _format->GetHandler(*this);
|
FormatHandler handler = _format->GetHandler(*this);
|
||||||
if (!handler) THROW_ATHENA_EXCEPTION(Exception::No_Format_Handler);
|
if (!handler) THROW_ATHENA_EXCEPTION(Exception::No_Format_Handler);
|
||||||
|
|
||||||
// Clear the model first
|
// Clear the model first
|
||||||
|
@ -120,7 +121,7 @@ void CModel::Load(wxInputStream &input,const FormatPtr _format,const String enco
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Save subtitles
|
// Save subtitles
|
||||||
void CModel::Save(wxOutputStream &output,const FormatPtr _format,const String encoding)
|
void CModel::Save(wxOutputStream &output,const Format _format,const String encoding)
|
||||||
{
|
{
|
||||||
// Use another format
|
// Use another format
|
||||||
if (_format && _format != format) {
|
if (_format && _format != format) {
|
||||||
|
@ -129,7 +130,7 @@ void CModel::Save(wxOutputStream &output,const FormatPtr _format,const String en
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get handler
|
// Get handler
|
||||||
FormatHandlerPtr handler = format->GetHandler(*this);
|
FormatHandler handler = format->GetHandler(*this);
|
||||||
if (!handler) THROW_ATHENA_EXCEPTION(Exception::No_Format_Handler);
|
if (!handler) THROW_ATHENA_EXCEPTION(Exception::No_Format_Handler);
|
||||||
|
|
||||||
// Load
|
// Load
|
||||||
|
@ -141,15 +142,15 @@ void CModel::Save(wxOutputStream &output,const FormatPtr _format,const String en
|
||||||
// Inserts a new section
|
// Inserts a new section
|
||||||
void CModel::AddSection(String name)
|
void CModel::AddSection(String name)
|
||||||
{
|
{
|
||||||
SectionPtr prev = GetSection(name);
|
Section prev = GetSection(name);
|
||||||
if (prev) THROW_ATHENA_EXCEPTION(Exception::Section_Already_Exists);
|
if (prev) THROW_ATHENA_EXCEPTION(Exception::Section_Already_Exists);
|
||||||
sections.push_back(SectionPtr(new CSection(name)));
|
sections.push_back(Section(new CSection(name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Gets a section
|
// Gets a section
|
||||||
SectionPtr CModel::GetSection(String name) const
|
Section CModel::GetSection(String name) const
|
||||||
{
|
{
|
||||||
size_t len = sections.size();
|
size_t len = sections.size();
|
||||||
for (size_t i=0;i<len;i++) {
|
for (size_t i=0;i<len;i++) {
|
||||||
|
@ -161,7 +162,7 @@ SectionPtr CModel::GetSection(String name) const
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
// Get section by index
|
// Get section by index
|
||||||
SectionPtr CModel::GetSectionByIndex(size_t index) const
|
Section CModel::GetSectionByIndex(size_t index) const
|
||||||
{
|
{
|
||||||
return sections.at(index);
|
return sections.at(index);
|
||||||
}
|
}
|
||||||
|
@ -217,13 +218,13 @@ void CModel::Redo(const String owner)
|
||||||
|
|
||||||
/////////////////////
|
/////////////////////
|
||||||
// Perform undo/redo
|
// Perform undo/redo
|
||||||
void CModel::ActivateStack(ActionStack &stack,bool isUndo,const String &owner)
|
void CModel::ActivateStack(ActionStack stack,bool isUndo,const String &owner)
|
||||||
{
|
{
|
||||||
// TODO: do something with this
|
// TODO: do something with this
|
||||||
(void) owner;
|
(void) owner;
|
||||||
|
|
||||||
// Process list
|
// Process list
|
||||||
ProcessActionList(*stack.back(),isUndo?1:2);
|
ProcessActionList(stack.back(),isUndo?1:2);
|
||||||
|
|
||||||
// Pop original
|
// Pop original
|
||||||
stack.pop_back();
|
stack.pop_back();
|
||||||
|
@ -246,9 +247,8 @@ String CModel::GetRedoMessage(const String owner) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////
|
/////////////////////
|
||||||
// Create a controller for this model
|
// Create controller
|
||||||
ControllerPtr Athenasub::CModel::CreateController()
|
Controller CModel::CreateController() {
|
||||||
{
|
return Controller(new CController(Model(weakThis)));
|
||||||
return ControllerPtr(new CController(*this));
|
|
||||||
}
|
}
|
|
@ -53,7 +53,9 @@ namespace Athenasub {
|
||||||
friend class CAction;
|
friend class CAction;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<CSection> sections;
|
weak_ptr<IModel> weakThis;
|
||||||
|
|
||||||
|
std::vector<Section> sections;
|
||||||
ActionStack undoStack;
|
ActionStack undoStack;
|
||||||
ActionStack redoStack;
|
ActionStack redoStack;
|
||||||
ViewList listeners;
|
ViewList listeners;
|
||||||
|
@ -86,6 +88,8 @@ namespace Athenasub {
|
||||||
Controller CreateController();
|
Controller CreateController();
|
||||||
Format GetFormat() const { return format; }
|
Format GetFormat() const { return format; }
|
||||||
void AddListener(View listener);
|
void AddListener(View listener);
|
||||||
|
|
||||||
|
void SetWeakPtr(weak_ptr<IModel> ptr) { weakThis = ptr; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef shared_ptr<CModel> ModelPtr;
|
typedef shared_ptr<CModel> ModelPtr;
|
||||||
|
|
|
@ -97,6 +97,14 @@ Entry CSection::GetEntry(size_t i) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////
|
||||||
|
// Retrieves entry reference by index
|
||||||
|
Entry& CSection::GetEntryRef(size_t i)
|
||||||
|
{
|
||||||
|
return entries[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// Get number of entries
|
// Get number of entries
|
||||||
size_t CSection::GetEntryCount() const
|
size_t CSection::GetEntryCount() const
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace Athenasub {
|
||||||
void RemoveEntryByIndex(size_t index);
|
void RemoveEntryByIndex(size_t index);
|
||||||
void RemoveEntry(Entry entry);
|
void RemoveEntry(Entry entry);
|
||||||
Entry GetEntry(size_t index) const;
|
Entry GetEntry(size_t index) const;
|
||||||
Entry& GetEntryRef(size_t index) const;
|
Entry& GetEntryRef(size_t index);
|
||||||
size_t GetEntryCount() const;
|
size_t GetEntryCount() const;
|
||||||
};
|
};
|
||||||
typedef shared_ptr<CSection> SectionPtr;
|
typedef shared_ptr<CSection> SectionPtr;
|
||||||
|
|
|
@ -41,6 +41,8 @@ namespace Athenasub {
|
||||||
|
|
||||||
// Selection class
|
// Selection class
|
||||||
class CSelection : public ISelection {
|
class CSelection : public ISelection {
|
||||||
|
friend class CController;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Range> ranges;
|
std::vector<Range> ranges;
|
||||||
size_t count;
|
size_t count;
|
||||||
|
|
|
@ -50,15 +50,21 @@ int main()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Set up the lib
|
// Set up the lib
|
||||||
|
cout << "Loading library... ";
|
||||||
HMODULE module = LoadLibrary(_T("athenasub.dll"));
|
HMODULE module = LoadLibrary(_T("athenasub.dll"));
|
||||||
if (!module) {
|
if (!module) {
|
||||||
cout << "Failed to load library, aborting.\n";
|
cout << "Failed to load library, aborting.\n";
|
||||||
|
system("pause");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
cout << "Done.\nCreating library...";
|
||||||
LibAthenaSub lib = Athenasub::Create(module,"Aegilib test program");
|
LibAthenaSub lib = Athenasub::Create(module,"Aegilib test program");
|
||||||
|
cout << "Done.\n";
|
||||||
|
|
||||||
// Subtitles model
|
// Subtitles model
|
||||||
|
cout << "Creating model... ";
|
||||||
Model subs = lib->CreateModel();
|
Model subs = lib->CreateModel();
|
||||||
|
cout << "Creating controller...\n";
|
||||||
Controller control = subs->CreateController();
|
Controller control = subs->CreateController();
|
||||||
wxStopWatch timer;
|
wxStopWatch timer;
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,7 @@
|
||||||
/>
|
/>
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCLinkerTool"
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="../../bin/aegilibtest.exe"
|
||||||
LinkIncremental="1"
|
LinkIncremental="1"
|
||||||
GenerateDebugInformation="true"
|
GenerateDebugInformation="true"
|
||||||
SubSystem="1"
|
SubSystem="1"
|
||||||
|
|
Loading…
Reference in a new issue