mirror of
https://github.com/rvtr/TwlToolsRED.git
synced 2025-10-31 06:41:18 -04:00
出力ファイルチェックツール:エラー処理を返り値ベースから例外ベースに変更。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@163 7061adef-622a-194b-ae81-725974e89856
This commit is contained in:
parent
284c4ae675
commit
b2386ea646
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,22 +7,21 @@ using namespace System;
|
|||||||
|
|
||||||
int main(array<System::String ^> ^args)
|
int main(array<System::String ^> ^args)
|
||||||
{
|
{
|
||||||
FilenameItem ^fItem = gcnew FilenameItem;
|
try
|
||||||
fItem->parseFilename( args[0] );
|
|
||||||
|
|
||||||
SheetItem ^sItem = gcnew SheetItem;
|
|
||||||
sItem->readSheet( args[0] );
|
|
||||||
|
|
||||||
System::String^ errmsg = checkSheet( fItem, sItem );
|
|
||||||
if( errmsg != nullptr )
|
|
||||||
{
|
{
|
||||||
Console::WriteLine( "NG " + errmsg );
|
FilenameItem ^fItem = gcnew FilenameItem;
|
||||||
}
|
fItem->parseFilename( args[0] );
|
||||||
else
|
|
||||||
{
|
|
||||||
Console::WriteLine( "OK" );
|
|
||||||
}
|
|
||||||
|
|
||||||
Console::WriteLine(L"Hello World");
|
SheetItem ^sItem = gcnew SheetItem;
|
||||||
|
sItem->readSheet( args[0] );
|
||||||
|
|
||||||
|
checkSheet( fItem, sItem );
|
||||||
|
}
|
||||||
|
catch( System::Exception ^ex )
|
||||||
|
{
|
||||||
|
Console::WriteLine( "NG - " + ex->Message);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Console::WriteLine( "OK" );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using namespace System;
|
|||||||
// ファイル名の解析
|
// ファイル名の解析
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
System::Boolean FilenameItem::parseFilename( System::String ^filepath )
|
System::Void FilenameItem::parseFilename( System::String ^filepath )
|
||||||
{
|
{
|
||||||
System::String ^filename = System::IO::Path::GetFileNameWithoutExtension(filepath);
|
System::String ^filename = System::IO::Path::GetFileNameWithoutExtension(filepath);
|
||||||
|
|
||||||
@ -22,6 +22,5 @@ System::Boolean FilenameItem::parseFilename( System::String ^filepath )
|
|||||||
Console::WriteLine( "Ogn: " + this->ogn );
|
Console::WriteLine( "Ogn: " + this->ogn );
|
||||||
Console::WriteLine( "Rating: " + this->rating );
|
Console::WriteLine( "Rating: " + this->rating );
|
||||||
Console::WriteLine( "Lang: " + this->lang );
|
Console::WriteLine( "Lang: " + this->lang );
|
||||||
|
return;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ public:
|
|||||||
public:
|
public:
|
||||||
FilenameItem(){}
|
FilenameItem(){}
|
||||||
public:
|
public:
|
||||||
System::Boolean parseFilename( System::String ^filepath );
|
System::Void parseFilename( System::String ^filepath );
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -34,7 +34,8 @@ public:
|
|||||||
public:
|
public:
|
||||||
SheetItem(){}
|
SheetItem(){}
|
||||||
public:
|
public:
|
||||||
System::Boolean readSheet( System::String ^sheetfile );
|
System::Void readSheet( System::String ^sheetfile );
|
||||||
};
|
};
|
||||||
|
|
||||||
System::String^ checkSheet( FilenameItem ^fItem, SheetItem ^sItem );
|
// 提出確認書の文字列と真値を比較
|
||||||
|
System::Void checkSheet( FilenameItem ^fItem, SheetItem ^sItem );
|
||||||
|
|||||||
@ -13,41 +13,24 @@ using namespace System;
|
|||||||
// 提出確認書の読み込み
|
// 提出確認書の読み込み
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
System::Boolean SheetItem::readSheet( System::String ^sheetfile )
|
System::Void SheetItem::readSheet( System::String ^sheetfile )
|
||||||
{
|
{
|
||||||
// XSLによってXML変換
|
// XSLによってXML変換
|
||||||
System::String ^tmpfile = ".\\temp" + System::DateTime::Now.ToString("yyyyMMddHHmmss") + ".xml";
|
System::String ^tmpfile = ".\\temp" + System::DateTime::Now.ToString("yyyyMMddHHmmss") + ".xml";
|
||||||
System::Xml::Xsl::XslCompiledTransform ^xslt = gcnew System::Xml::Xsl::XslCompiledTransform;
|
System::Xml::Xsl::XslCompiledTransform ^xslt = gcnew System::Xml::Xsl::XslCompiledTransform;
|
||||||
System::String ^xslpath = System::IO::Path::GetDirectoryName( System::Reflection::Assembly::GetEntryAssembly()->Location )
|
System::String ^xslpath = System::IO::Path::GetDirectoryName( System::Reflection::Assembly::GetEntryAssembly()->Location )
|
||||||
+ "\\extract_sheet.xsl";
|
+ "\\extract_sheet.xsl";
|
||||||
try
|
|
||||||
{
|
//Console::WriteLine( "xslpath: " + xslpath );
|
||||||
//Console::WriteLine( "xslpath: " + xslpath );
|
xslt->Load( xslpath );
|
||||||
xslt->Load( xslpath );
|
xslt->Transform( sheetfile, tmpfile );
|
||||||
xslt->Transform( sheetfile, tmpfile );
|
|
||||||
}
|
|
||||||
catch( System::Exception ^ex )
|
|
||||||
{
|
|
||||||
(void)ex;
|
|
||||||
//Console::WriteLine( "XSLT Error" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 変換したXMLを読み込み
|
// 変換したXMLを読み込み
|
||||||
System::Xml::XmlDocument ^doc = gcnew System::Xml::XmlDocument;
|
System::Xml::XmlDocument ^doc = gcnew System::Xml::XmlDocument;
|
||||||
try
|
doc->Load( tmpfile );
|
||||||
{
|
|
||||||
doc->Load( tmpfile );
|
|
||||||
}
|
|
||||||
catch( System::Exception ^ex )
|
|
||||||
{
|
|
||||||
(void)ex;
|
|
||||||
//Console::WriteLine( "Load error" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XMLからデータを抽出
|
// XMLからデータを抽出
|
||||||
System::Xml::XmlElement ^root = doc->DocumentElement;
|
System::Xml::XmlElement ^root = doc->DocumentElement;
|
||||||
try
|
|
||||||
{
|
{
|
||||||
this->region = MasterEditorTWL::getXPathText( root, "/Sheet/Region" );
|
this->region = MasterEditorTWL::getXPathText( root, "/Sheet/Region" );
|
||||||
this->CERO = MasterEditorTWL::getXPathText( root, "/Sheet/RatingCERO" );
|
this->CERO = MasterEditorTWL::getXPathText( root, "/Sheet/RatingCERO" );
|
||||||
@ -79,19 +62,12 @@ System::Boolean SheetItem::readSheet( System::String ^sheetfile )
|
|||||||
Console::WriteLine( "OFLC: " + this->OFLC );
|
Console::WriteLine( "OFLC: " + this->OFLC );
|
||||||
Console::WriteLine( "Unnecessary: " + this->IsUnnecessaryRating.ToString() );
|
Console::WriteLine( "Unnecessary: " + this->IsUnnecessaryRating.ToString() );
|
||||||
}
|
}
|
||||||
catch( System::Exception ^ex )
|
|
||||||
{
|
|
||||||
//(void)ex;
|
|
||||||
Console::WriteLine( ex->Message );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 中間ファイルを削除
|
// 中間ファイルを削除
|
||||||
if( System::IO::File::Exists( tmpfile ) )
|
if( System::IO::File::Exists( tmpfile ) )
|
||||||
{
|
{
|
||||||
System::IO::File::Delete( tmpfile );
|
System::IO::File::Delete( tmpfile );
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -101,23 +77,13 @@ System::Boolean SheetItem::readSheet( System::String ^sheetfile )
|
|||||||
|
|
||||||
// @arg [in] ファイル情報
|
// @arg [in] ファイル情報
|
||||||
// @arg [in] 提出確認書の情報
|
// @arg [in] 提出確認書の情報
|
||||||
//
|
System::Void checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
|
||||||
// @ret エラーメッセージ (エラーなしのときnullptr)
|
|
||||||
System::String^ checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
|
|
||||||
{
|
{
|
||||||
System::Xml::XmlDocument ^doc = gcnew System::Xml::XmlDocument;
|
System::Xml::XmlDocument ^doc = gcnew System::Xml::XmlDocument;
|
||||||
try
|
System::String ^cfgfile = System::IO::Path::GetDirectoryName( System::Reflection::Assembly::GetEntryAssembly()->Location )
|
||||||
{
|
+ "\\config.xml";
|
||||||
System::String ^cfgfile = System::IO::Path::GetDirectoryName( System::Reflection::Assembly::GetEntryAssembly()->Location )
|
doc->Load( cfgfile );
|
||||||
+ "\\config.xml";
|
|
||||||
doc->Load( cfgfile );
|
|
||||||
}
|
|
||||||
catch( System::Exception ^ex )
|
|
||||||
{
|
|
||||||
(void)ex;
|
|
||||||
//Console::WriteLine( "Load error" );
|
|
||||||
return (gcnew System::String("Failed to load XML"));
|
|
||||||
}
|
|
||||||
// XMLからデータを抽出
|
// XMLからデータを抽出
|
||||||
System::Xml::XmlElement ^root = doc->DocumentElement;
|
System::Xml::XmlElement ^root = doc->DocumentElement;
|
||||||
|
|
||||||
@ -134,7 +100,7 @@ System::String^ checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
|
|||||||
// リージョンの文字列をチェック
|
// リージョンの文字列をチェック
|
||||||
if( sItem->region != region )
|
if( sItem->region != region )
|
||||||
{
|
{
|
||||||
return (gcnew System::String("In Sheet, region is illegal string."));
|
throw (gcnew System::Exception("In Sheet, region is illegal string."));
|
||||||
}
|
}
|
||||||
// レーティングの文字列をチェック
|
// レーティングの文字列をチェック
|
||||||
if( fItem->region == "JP" )
|
if( fItem->region == "JP" )
|
||||||
@ -240,8 +206,7 @@ System::String^ checkSheet( FilenameItem ^fItem, SheetItem ^sItem )
|
|||||||
}
|
}
|
||||||
if( errmsg != nullptr )
|
if( errmsg != nullptr )
|
||||||
{
|
{
|
||||||
return errmsg;
|
throw (gcnew System::Exception(errmsg));
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user