ライブラリのヘルプの変更
この例では、C++ ライブラリに対する MATLAB® インターフェイスについて生成されたヘルプを変更する方法を説明します。
この例では、Apache® Xerces-C++ XML パーサー ライブラリ内の XMLPlatformUtils.Initialize
メソッドのヘルプを示します。この内容の出典は Apache Xerces プロジェクト (https://xerces.apache.org) であり、Apache 2.0 ライセンス (https://www.apache.org/licenses/LICENSE-2.0) によりライセンスが許諾されています。
このライブラリに対する MATLAB インターフェイスをビルドするには、ヘッダー ファイルとコンパイル済みライブラリ ファイルが必要です。この例では、ビルド プロセスについて説明し、そのようなライブラリをビルドするときの出力を示します。ただし、Xerces ファイルにアクセスできない場合、この例に示すコードを実行することはできません。
設定
環境の設定の詳細については、C++ ライブラリに対するインターフェイスをビルドするための要件を参照してください。
コンパイラを確認します。この例では、ライブラリ ファイルが Microsoft® Visual C++® 2017 コンパイラでビルドされたと仮定しています。
mex -setup cpp
使用する
.hpp
ファイルおよびコンパイル済みライブラリ ファイルへのパスmyPath
を特定します。この例では、ライブラリ ファイルxerces-c_3.lib
を使用します。includePath = "myPath\include"; libFile = "myPath\lib\xerces-c_3.lib";
使用するインターフェイスに必要なヘッダー ファイルを識別します。この例では、
PlatformUtils.hpp
ファイルのXMLPlatformUtils.Initialize
メソッドを使用します。headers = includePath+"\xercesc\util\PlatformUtils.hpp";
MATLAB インターフェイスの定義
インターフェイスの定義の詳細については、C++ ライブラリに対する MATLAB インターフェイスの定義を参照してください。
ライブラリ定義ファイル
defineMyXercesLibrary.m
を生成します。clibgen.generateLibraryDefinition(headers, ... "IncludePath",includePath, ... 'Libraries',libFile, ... "Verbose",true, ... "InterfaceName","MyXercesLibrary")
defineMyXercesLibrary.m
ファイルを編集します。この例では、Initialize
メソッドについてのみ、未定義の機能を解決します。次を検索します。C++ Signature: static void xercesc_3_1::XMLPlatformUtils::Initialize
<MLTYPE>
を"string"
に、また<SHAPE>
を"nullTerminated"
に置き換えることにより、locale
およびnlsHome
のdefineArgument
ステートメントを null で終了する string に更新します。コードの更新の詳細については、Define Missing SHAPE Parameterを参照してください。defineArgument(InitializeDefinition, "locale", "string", "input", "nullTerminated", ... "Description", "locale The locale to use for messages."); % '<MLTYPE>' can be clib.array.xerces.Char,int8,string, or char defineArgument(InitializeDefinition, "nlsHome", "string", "input", "nullTerminated", ... "Description", "nlsHome User specified location where MsgLoader retrieves error message files." + newline + ...
同じメソッド内で、
<SHAPE>
を1
に置き換えることにより、引数panicHandler
およびmemoryManager
をスカラーとして定義します。defineArgument(InitializeDefinition, "panicHandler", ... "clib.MyXercesLibrary.xercesc_3_1.PanicHandler", "input", 1, ... "Description", "panicHandler Application's panic handler, application owns this handler." + newline + ... defineArgument(InitializeDefinition, "memoryManager", ... "clib.MyXercesLibrary.xercesc_3_1.MemoryManager", "input", 1, ... "Description", "memoryManager Plugged-in memory manager which is owned by the" + newline + ...
ライブラリ定義ファイルを検証し、すべてのエラーを解決します。
libDef = defineMyXercesLibrary
生成されたヘルプ テキストの更新
自動生成されたヘルプ テキストを確認します。
className = "xercesc_3_1::XMLPlatformUtils"; methodName = "Initialize"; for i = 1:numel(libDef.Classes) if (matches(libDef.Classes(i).CPPName,className)) classID = i; for j = 1:numel(libDef.Classes(i).Methods) if (startsWith(libDef.Classes(i).Methods(j).MATLABSignature,methodName)) methodID = j; end end end end Description = libDef.Classes(classID).Methods(methodID).Description DetailedDescription = libDef.Classes(classID).Methods(methodID).DetailedDescription
Description = "clib.MyXercesLibrary.xercesc_3_1.XMLPlatformUtils.Initialize Method of C++ class xercesc_3_1::XMLPlatformUtils. Perform per-process parser initialization" DetailedDescription = "This content is from the external library documentation. Initialization <b>must</b> be called first in any client code."
テキスト
This content is from the external library documentation
を変更して、Apache Xerces プロジェクトに関する情報を表示します。ライブラリ定義ファイルを開きます。edit defineMyXercesLibrary
xercesc_3_1::XMLPlatformUtils::Initialize
メソッドを検索します。C++ Signature: static void xercesc_3_1::XMLPlatformUtils::Initialize
引数
DetailedDescription
内のThis content is from the external library documentation
を新しい内容に置き換えます。その行は次のようになります。"DetailedDescription", "This content comes from the Apache Xerces project, https://xerces.apache.org, and is licensed under the " + newline + ... "Apache 2.0 license, https://www.apache.org/licenses/LICENSE-2.0." + newline + ...
ファイルを保存します。
更新後のヘルプ テキストを確認します。
libDef = defineMyXercesLibrary; libDef.Classes(classID).Methods(methodID).DetailedDescription
ans = "This content comes from the Apache Xerces project, https://xerces.apache.org, and is licensed under the Apache 2.0 license, https://www.apache.org/licenses/LICENSE-2.0. Initialization <b>must</b> be called first in any client code."
ライブラリのビルドおよびヘルプの表示
build(defineMyXercesLibrary)
使用しているパスにライブラリを追加します。メッセージ内のリンクをクリックするか、次のように入力します。
addPath(MyXercesLibrary)
システム パスを更新し、ライブラリ ファイルの場所
myPath
を特定します。dllPath = "myPath\lib"; syspath = getenv("PATH"); setenv("PATH",dllPath+";"+syspath)
内容を確認します。
summary(defineMyXercesLibrary)
Initialize
メソッドのヘルプを表示します。help clib.MyXercesLibrary.xercesc_3_1.XMLPlatformUtils.Initialize
clib.MyXercesLibrary.xercesc_3_1.XMLPlatformUtils.Initialize Method of C++ class xercesc_3_1::XMLPlatformUtils. Perform per-process parser initialization This content comes from the Apache Xerces project, https://xerces.apache.org, and is licensed under the Apache 2.0 license, https://www.apache.org/licenses/LICENSE-2.0. Initialization <b>must</b> be called first in any client code. Inputs locale read-only string locale The locale to use for messages. nlsHome read-only string nlsHome User specified location where MsgLoader retrieves error message files. the discussion above with regard to locale, applies to nlsHome as well. panicHandler clib.MyXercesLibrary.xercesc_3_1.PanicHandler panicHandler Application's panic handler, application owns this handler. Application shall make sure that the plugged panic handler persists through the call to XMLPlatformUtils::Terminate(). memoryManager clib.MyXercesLibrary.xercesc_3_1.MemoryManager memoryManager Plugged-in memory manager which is owned by the application. Applications must make sure that the plugged-in memory manager persist through the call to XMLPlatformUtils::Terminate()