diff --git a/aegilib/aegilib_2008.vcproj b/aegilib/aegilib_2008.vcproj
index a6ea3b97c..5d2dac68f 100644
--- a/aegilib/aegilib_2008.vcproj
+++ b/aegilib/aegilib_2008.vcproj
@@ -182,6 +182,10 @@
RelativePath=".\include\athenasub\athenawin.h"
>
+
+
diff --git a/aegilib/include/athenasub/athenastring.h b/aegilib/include/athenasub/athenastring.h
index 48081532f..cc5d693de 100644
--- a/aegilib/include/athenasub/athenastring.h
+++ b/aegilib/include/athenasub/athenastring.h
@@ -36,9 +36,10 @@
#pragma once
#include "api.h"
-#include
#include
+class wxString;
+
namespace Athenasub {
typedef char Character;
@@ -83,13 +84,18 @@ namespace Athenasub {
void WriteChar(const Character &src,size_t &pos);
void WriteNumber(Character *temp,int number,int pad,size_t &pos);
- bool AsciiCompareNoCase(const Character *src) const;
bool IsNumber() const;
- String Lower() const;
- String Upper() const;
- void MakeUpper();
- void MakeLower();
+ //String Lower() const;
+ //String Upper() const;
+ //void MakeUpper();
+ //void MakeLower();
+
+ String AsciiLower() const;
+ String AsciiUpper() const;
+ void AsciiMakeUpper();
+ void AsciiMakeLower();
+ bool AsciiCompareNoCase(const Character *src) const;
// Convert a string to an integer
int ToInteger() const;
diff --git a/aegilib/include/athenasub/exception.h b/aegilib/include/athenasub/exception.h
index ee999dbc1..09b5af8c8 100644
--- a/aegilib/include/athenasub/exception.h
+++ b/aegilib/include/athenasub/exception.h
@@ -59,43 +59,15 @@ namespace Athenasub {
TODO
};
- Exception(ExceptionList _code) : std::exception(GetMessageChar(_code)) { code = _code; }
- Exception(ExceptionList _code,const char* file,const long line) : std::exception(GetMessageFile(_code,file,line)) { code = _code; }
+ Exception(ExceptionList _code);
+ Exception(ExceptionList _code,const char* file,const long line);
//String GetMessageString() const { return String(what(),wxConvLocal); }
int GetCode() { return code; }
private:
- static const char* 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.";
- }
-
-
- static const char* 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();
- }
-
+ static const char* GetMessageChar(int code);
+ static const char* GetMessageFile(int code,const char *file,long line);
ExceptionList code;
};
diff --git a/aegilib/src/athenastring.cpp b/aegilib/src/athenastring.cpp
index ea10f8763..dff420fba 100644
--- a/aegilib/src/athenastring.cpp
+++ b/aegilib/src/athenastring.cpp
@@ -34,6 +34,8 @@
//
#include "athenastring.h"
+#include "exception.h"
+#include
using namespace Athenasub;
@@ -155,8 +157,7 @@ size_t String::Length() const
size_t String::UTF8Length() const
{
- // TODO
- return size();
+ THROW_ATHENA_EXCEPTION(Exception::TODO);
}
@@ -197,8 +198,7 @@ bool String::StartsWith(const String& string,bool caseSensitive) const
String tmp = substr(0,string.size());
return compare(0,string.size(),string) == 0;
} else {
- // TODO
- return false;
+ return AsciiLower().StartsWith(string.AsciiLower(),true);
}
}
@@ -209,8 +209,7 @@ bool String::EndsWith(const String& string,bool caseSensitive) const
size_t strSize = string.size();
return compare(size() - strSize,strSize,string) == 0;
} else {
- // TODO
- return false;
+ return AsciiLower().EndsWith(string.AsciiLower(),true);
}
}
@@ -287,7 +286,15 @@ bool String::AsciiCompareNoCase(const Character *src) const
bool String::IsNumber() const
{
- return false; // TODO
+ for (const char *chr = c_str();*chr;chr++) {
+ char cur = *chr;
+ if (cur < '0' || cur > '9') {
+ if (cur != '.' && cur != ',' && cur != '+' && cur != '-') {
+ return false;
+ }
+ }
+ }
+ return true;
}
@@ -334,6 +341,7 @@ const Character* String::StringTrim(String &str,size_t startPos)
return StringPtrTrim(chr,str.Length(),startPos);
}
+/*
String String::Lower() const
{
String tmp(*this);
@@ -349,12 +357,44 @@ String String::Upper() const {
void String::MakeUpper()
{
- // TODO
+ THROW_ATHENA_EXCEPTION(Exception::TODO);
}
void String::MakeLower()
{
- // TODO
+ THROW_ATHENA_EXCEPTION(Exception::TODO);
+}
+*/
+
+String String::AsciiLower() const
+{
+ String tmp(*this);
+ tmp.AsciiMakeLower();
+ return tmp;
+}
+
+String String::AsciiUpper() const {
+ String tmp(*this);
+ tmp.AsciiMakeUpper();
+ return tmp;
+}
+
+void String::AsciiMakeUpper()
+{
+ char* str = GetCharPointer(0);
+ for (int i=0; str[i]; str++) {
+ char cur = str[i];
+ if (cur >= 'a' && cur <= 'z') str[i] -= 32;
+ }
+}
+
+void String::AsciiMakeLower()
+{
+ char* str = GetCharPointer(0);
+ for (int i=0; str[i]; str++) {
+ char cur = str[i];
+ if (cur >= 'A' && cur <= 'Z') str[i] += 32;
+ }
}
diff --git a/aegilib/src/exception.cpp b/aegilib/src/exception.cpp
index 4f73f0dcb..49c43dc65 100644
--- a/aegilib/src/exception.cpp
+++ b/aegilib/src/exception.cpp
@@ -37,3 +37,51 @@
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.";
+}
+
+
+///////////////////////////////////////////
+// Get the message string for the filename
+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();
+}
diff --git a/aegilib/src/formats/format_ass.cpp b/aegilib/src/formats/format_ass.cpp
index ebce6743a..b499c9beb 100644
--- a/aegilib/src/formats/format_ass.cpp
+++ b/aegilib/src/formats/format_ass.cpp
@@ -258,7 +258,7 @@ Entry FormatHandlerASS::MakeEntry(const String &data,Section section,int version
void FormatHandlerASS::ProcessGroup(String cur,String &curGroup,int &version) {
// Style conversion
if (!cur.IsEmpty() && cur[0] == '[') {
- String low = cur.Lower();
+ String low = cur.AsciiLower();
bool changed = true;
// SSA file
@@ -295,8 +295,8 @@ void FormatHandlerASS::ProcessGroup(String cur,String &curGroup,int &version) {
curGroup = curGroup.Mid(1,curGroup.Length()-2);
// Normalize case
- curGroup.MakeLower();
- String upper = curGroup.Upper();
+ curGroup.AsciiMakeLower();
+ String upper = curGroup.AsciiUpper();
bool raise = true;
size_t len = curGroup.Length();
for (size_t i=0;i 0 && stringBuffer[0] == 0xFEFF) startPos = 1;
+ if (stringBuffer.Length() > 0 && stringBuffer[0] == 0xFEFF) startPos = 3;
// Trim
String str = String(stringBuffer);
diff --git a/aegilib/test/test_2008.vcproj b/aegilib/test/test_2008.vcproj
index 655b7ee09..39f1d6c7d 100644
--- a/aegilib/test/test_2008.vcproj
+++ b/aegilib/test/test_2008.vcproj
@@ -121,6 +121,7 @@
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
+ WholeProgramOptimization="false"
AdditionalIncludeDirectories="../include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
@@ -149,7 +150,7 @@
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
- LinkTimeCodeGeneration="1"
+ LinkTimeCodeGeneration="0"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"