From a4c7eeab0ebf5fcdf174091213a9b4e68ca619ac Mon Sep 17 00:00:00 2001 From: nishikawa_takeshi Date: Tue, 9 Jun 2009 00:56:23 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=9E=E3=82=B9=E3=82=BF=E3=82=A8=E3=83=87?= =?UTF-8?q?=E3=82=A3=E3=82=BF:=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E5=BF=98=E3=82=8C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@287 7061adef-622a-194b-ae81-725974e89856 --- .../MasterEditorTWL/middleware_name_list.h | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 build/tools/MasterEditor/MasterEditorTWL/MasterEditorTWL/middleware_name_list.h diff --git a/build/tools/MasterEditor/MasterEditorTWL/MasterEditorTWL/middleware_name_list.h b/build/tools/MasterEditor/MasterEditorTWL/MasterEditorTWL/middleware_name_list.h new file mode 100644 index 0000000..3e391cd --- /dev/null +++ b/build/tools/MasterEditor/MasterEditorTWL/MasterEditorTWL/middleware_name_list.h @@ -0,0 +1,149 @@ +#pragma once + +// ROMデータ(SRL)クラスの関連クラスの宣言と定義 + +#include +#include + +namespace MasterEditorTWL +{ + // ------------------------------------------------------------------- + // Type : ref class + // Name : RCMiddlewareName + // + // Description : 1つのミドルウェアの名前情報 + // + // Role : バイナリに埋め込まれているミドルウェア(ライセンス情報)から + // その一般名称を返す + // ------------------------------------------------------------------- + ref class RCMiddlewareName + { + private: + System::String ^publisher; // バイナリに埋め込まれているはずの提供元 + System::String ^code; // バイナリに埋め込まれているはずの識別コード + System::String ^noteJ; // 一般名称 + System::String ^noteE; + private: + RCMiddlewareName(){} // 封じる + public: + RCMiddlewareName( System::String ^pub, System::String ^c, System::String ^nJ, System::String ^nE ) + { + this->publisher = pub; + this->code = c; + this->noteJ = nJ; + this->noteE = nE; + } + public: + // 提供元と識別コードが一致する場合に一般名称を返す + // 一致しない場合には nullptr を返す + System::String^ check(System::String ^pub, System::String ^code, System::Boolean isJapanese) + { + if( pub->Equals(this->publisher) && code->StartsWith(this->code) ) + { + if( isJapanese ) + { + return System::String::Copy(this->noteJ); + } + else + { + return System::String::Copy(this->noteE); + } + } + return nullptr; + } + }; //ref class RCMiddlewareName + + // ------------------------------------------------------------------- + // Type : ref class + // Name : RCMiddlewareName + // + // Description : ミドルウェアの名前情報のリスト + // + // Role : 設定ファイル中のミドルウェア名称リストから + // 各ミドルウェアの名称を取得し + // 名称を検索する + // ------------------------------------------------------------------- + ref class RCMiddlewareNameList + { + private: + System::Collections::Generic::List ^list; + private: + RCMiddlewareNameList(){} + public: + RCMiddlewareNameList( System::String^ filepath ) + { + this->makelist(filepath); + } + private: + // ファイルから各ミドルウェアの名称を取得しリストを作成する + void makelist( System::String^ filepath ) + { + this->list = gcnew System::Collections::Generic::List; + this->list->Clear(); + + // xmlファイルの読み込み + System::Xml::XmlDocument ^doc = gcnew System::Xml::XmlDocument(); + try + { + doc->Load( filepath ); + } + catch( System::Exception ^s ) + { + (void)s; + return; + } + System::Xml::XmlElement ^root = doc->DocumentElement; + + // ミドルウェアの名称情報のリストをファイルから取得してリストに登録する + System::Xml::XmlNodeList ^nodelist = root->SelectNodes( "/middleware-name-list/middleware" ); // 同じタグを持つ要素をすべて取得 + System::Collections::IEnumerator^ iter = nodelist->GetEnumerator(); + while( iter->MoveNext() ) + { + System::Xml::XmlNode ^node = safe_cast(iter->Current); + System::Xml::XmlNode ^n_pub = node->SelectSingleNode( "publisher" ); // 相対パス + System::Xml::XmlNode ^n_c = node->SelectSingleNode( "code" ); + System::Xml::XmlNode ^n_nJ = node->SelectSingleNode( "note-j" ); + System::Xml::XmlNode ^n_nE = node->SelectSingleNode( "note-e" ); + + // XMLノードからデータを抜き出してリストに順次登録していく + System::String ^pub = ""; // 比較に使うのでnullptrを許さない + if( n_pub && n_pub->FirstChild && n_pub->FirstChild->Value ) + { + pub = n_pub->FirstChild->Value; + } + System::String ^c = ""; + if( n_c && n_c->FirstChild && n_c->FirstChild->Value ) + { + c = n_c->FirstChild->Value; + } + System::String ^nJ = nullptr; // 比較に使用しないのでnullptr(登録されていないことを表す) + if( n_nJ && n_nJ->FirstChild && n_nJ->FirstChild->Value ) + { + nJ = n_nJ->FirstChild->Value; + } + System::String ^nE = nullptr; + if( n_nE && n_nE->FirstChild && n_nE->FirstChild->Value ) + { + nE = n_nE->FirstChild->Value; + } + this->list->Add( gcnew RCMiddlewareName(pub, c, nJ, nE ) ); // リストに登録 + } //while + } //void makelist() + public: + // リスト内を検索してミドルウェアの名称を返す + // 登録されていない場合は nullptr を返す + System::String^ search( System::String ^pub, System::String ^code, System::Boolean isJapanese ) + { + for each (RCMiddlewareName ^mid in this->list ) + { + System::String ^note = mid->check(pub, code, isJapanese); + if( note != nullptr ) + { + return note; + } + } + return nullptr; + } //System::String^ search() + }; //ref class RCMiddlewareNameList + +}; // namespace MasterEditorTWL \ No newline at end of file