2008-03-08 04:08:50 +01:00
|
|
|
// 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
|
|
|
|
//
|
|
|
|
|
2008-03-13 22:28:22 +01:00
|
|
|
#include <aegilib/gorgonsub.h>
|
2008-03-08 08:14:14 +01:00
|
|
|
#include <wx/wfstream.h>
|
2008-03-08 04:08:50 +01:00
|
|
|
#include <iostream>
|
2008-03-14 07:10:54 +01:00
|
|
|
#include <wx/stopwatch.h>
|
2008-03-08 04:08:50 +01:00
|
|
|
#include "text_file_reader.h"
|
|
|
|
#include "text_file_writer.h"
|
|
|
|
|
2008-03-16 01:32:42 +01:00
|
|
|
int main()
|
|
|
|
{
|
2008-03-08 04:08:50 +01:00
|
|
|
using namespace std;
|
2008-03-13 22:28:22 +01:00
|
|
|
using namespace Gorgonsub;
|
2008-03-08 04:08:50 +01:00
|
|
|
|
2008-03-13 22:28:22 +01:00
|
|
|
cout << "Gorgonsub test program by amz.\n\n";
|
2008-03-08 04:08:50 +01:00
|
|
|
|
2008-03-08 08:14:14 +01:00
|
|
|
try {
|
|
|
|
// Set up the lib
|
|
|
|
FormatManager::InitializeFormats();
|
2008-03-13 22:28:22 +01:00
|
|
|
Gorgonsub::SetHostApplicationName(L"Aegilib test program");
|
2008-03-08 04:08:50 +01:00
|
|
|
|
2008-03-08 08:14:14 +01:00
|
|
|
// Subtitles model
|
|
|
|
Model subs;
|
2008-03-14 03:02:48 +01:00
|
|
|
Controller control(subs);
|
2008-03-14 07:10:54 +01:00
|
|
|
wxStopWatch timer;
|
2008-03-08 04:08:50 +01:00
|
|
|
|
2008-03-08 08:14:14 +01:00
|
|
|
// Load subtitles
|
|
|
|
cout << "Loading file... ";
|
2008-03-14 07:10:54 +01:00
|
|
|
timer.Start();
|
2008-03-16 01:32:42 +01:00
|
|
|
control.LoadFile(L"subs_in.ass",L"UTF-8");
|
2008-03-14 07:10:54 +01:00
|
|
|
timer.Pause();
|
2008-03-15 09:36:52 +01:00
|
|
|
cout << "Done in " << timer.Time() << " ms.\n";
|
|
|
|
//system("pause");
|
|
|
|
|
|
|
|
// Save subtitles
|
|
|
|
cout << "Saving file... ";
|
|
|
|
timer.Start();
|
|
|
|
control.SaveFile(L"subs_out.ass",L"UTF-8");
|
|
|
|
timer.Pause();
|
|
|
|
cout << "Done in " << timer.Time() << " ms.\n";
|
2008-03-08 04:08:50 +01:00
|
|
|
|
2008-03-14 03:02:48 +01:00
|
|
|
// Create line to be inserted
|
|
|
|
cout << "Creating data... ";
|
|
|
|
SectionEntryDialoguePtr line = control.CreateDialogue();
|
|
|
|
line->SetText(L"Hi, testing insertion of lines!");
|
|
|
|
cout << "Done.\n";
|
|
|
|
|
|
|
|
// Create action list
|
|
|
|
cout << "Processing actions... ";
|
2008-03-14 07:10:54 +01:00
|
|
|
timer.Start();
|
2008-03-14 03:02:48 +01:00
|
|
|
ActionListPtr actions = control.CreateActionList(L"Insert line");
|
2008-03-16 19:09:25 +01:00
|
|
|
//actions->InsertLine(line,2);
|
|
|
|
//actions->RemoveLine(3,L"Events");
|
2008-03-16 03:20:34 +01:00
|
|
|
SectionEntryDialoguePtr diag = dynamic_pointer_cast<SectionEntryDialogue> (actions->ModifyLine(10,L"Events"));
|
|
|
|
diag->SetText(L"Hay guise sup");
|
2008-03-14 03:02:48 +01:00
|
|
|
actions->Finish();
|
2008-03-14 07:10:54 +01:00
|
|
|
timer.Pause();
|
2008-03-15 09:36:52 +01:00
|
|
|
cout << "Done in " << timer.Time() << " ms.\n";
|
2008-03-14 04:33:27 +01:00
|
|
|
|
|
|
|
// Undo
|
2008-03-15 09:36:52 +01:00
|
|
|
cout << "Undoing and redoing 1000 times... ";
|
2008-03-14 07:10:54 +01:00
|
|
|
timer.Start();
|
2008-03-15 09:36:52 +01:00
|
|
|
for (size_t i=0;i<1000;i++) {
|
|
|
|
control.Undo();
|
|
|
|
control.Redo();
|
|
|
|
}
|
2008-03-14 07:10:54 +01:00
|
|
|
timer.Pause();
|
2008-03-15 09:36:52 +01:00
|
|
|
cout << "Done in " << timer.Time() << " ms.\n";
|
2008-03-15 23:02:16 +01:00
|
|
|
control.SaveFile(L"subs_out2.ass",L"UTF-8");
|
2008-03-16 03:20:34 +01:00
|
|
|
control.Undo();
|
|
|
|
control.SaveFile(L"subs_out3.ass",L"UTF-8");
|
2008-03-08 08:14:14 +01:00
|
|
|
}
|
|
|
|
|
2008-03-13 08:28:30 +01:00
|
|
|
catch (std::exception &e) {
|
|
|
|
cout << "\n\nException: " << e.what() << endl << endl;
|
2008-03-08 08:14:14 +01:00
|
|
|
}
|
2008-03-15 01:29:17 +01:00
|
|
|
|
|
|
|
return true;
|
2008-03-08 04:08:50 +01:00
|
|
|
}
|