<p> テスト文書<br /> <input type="text" name="name" value="" /><br /> <a href="hogehoge.html">ほげ</a><br /> <img src="hoge.png" /> </p>
<data> <item id="1">テスト1</item> <item id="2">テスト2</item> <item id="3">テスト3</item> <item id="4">テスト4</item> </data>
<data> <item id="1" /> </data>
<data> <item id="1"></item> </data>
<?xml version="1.0" encoding="utf-8" ?> <data> <item id="1">テスト1</item> <item id="2">テスト2</item> <item id="3">テスト3</item> <item id="4">テスト4</item> </data>
<?xml version="1.0" encoding="Shift-JIS" ?> <data> <item id="1">テスト1</item> <item id="2">テスト2</item> <item id="3">テスト3</item> <item id="4">テスト4</item> </data>
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<?xml version="1.0" encoding="utf-8" ?> <GameStage> <GameObjects> <TilingFixedBox> <Scale>50,1,50</Scale> <Rot>0,0,0</Rot> <Pos>0,-0.5,0</Pos> <Tex>SKY_TX</Tex> </TilingFixedBox> <TilingFixedBox> <Scale>40,1,1</Scale> <Rot>0,0,0</Rot> <Pos>0,0.5,19.5</Pos> <Tex>WALL_TX</Tex> </TilingFixedBox> <TilingFixedBox> <Scale>40,1,1</Scale> <Rot>0,0,0</Rot> <Pos>0,0.5,-19.5</Pos> <Tex>WALL_TX</Tex> </TilingFixedBox> <TilingFixedBox> <Scale>40,1,1</Scale> <Rot>0,XM_PIDIV2,0</Rot> <Pos>19.5,0.5,0</Pos> <Tex>WALL_TX</Tex> </TilingFixedBox> <TilingFixedBox> <Scale>40,1,1</Scale> <Rot>0,XM_PIDIV2,0</Rot> <Pos>-19.5,0.5,0</Pos> <Tex>WALL_TX</Tex> </TilingFixedBox> </GameObjects> <CellMap>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 0,0,0,0,0,0,0,0,0,0,0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Reader; //以下略 };
void GameStage::OnCreate() {
try {
wstring DataDir;
App::GetApp()->GetDataDirectory(DataDir);
//XMLの読み込み
m_XmlDocReader.reset(new XmlDocReader(DataDir + L"GameStage.xml"));
//中略
}
catch (...) {
throw;
}
}
//XMLのオブジェクトの作成 void GameStage::CreateXmlObjects() { //オブジェクトのグループを作成する auto group = CreateSharedObjectGroup(L"SeekGroup"); //セルマップのノードを取得 auto CellmapNode = m_XmlDocReader->GetSelectSingleNode(L"GameStage/CellMap"); if (!CellmapNode) { throw BaseException( L"GameStage/CellMapが見つかりません", L"if (!CellmapNode)", L"GameStage::CreateEnemy()" ); } //内容の文字列を取得 wstring MapStr = XmlDocReader::GetText(CellmapNode); vector<wstring> LineVec; //最初に改行をデリミタとした文字列の配列にする Util::WStrToTokenVector(LineVec, MapStr, L'\n'); for (size_t i = 0; i < LineVec.size(); i++) { //トークン(カラム)の配列 vector<wstring> Tokens; //トークン(カラム)単位で文字列を抽出(L','をデリミタとして区分け) Util::WStrToTokenVector(Tokens, LineVec[i], L','); for (size_t j = 0; j < Tokens.size(); j++) { //XとZの位置を計算 float XPos = (float)((int)j - 19); float ZPos = (float)(19 - (int)i); if (Tokens[j] == L"1") { AddGameObject<SeekObject>(Vec3(XPos, 0.125f, ZPos)); } else if (Tokens[j] == L"2") { AddGameObject<MoveBox>( Vec3(1.0f, 1.0f, 1.0f), Vec3(0.0f, 0.0f, 0.0f), Vec3(XPos, 0.5f, ZPos)); } } } }
//セルマップのノードを取得
auto CellmapNode = m_XmlDocReader->GetSelectSingleNode(L"GameStage/CellMap");
//内容の文字列を取得
wstring MapStr = XmlDocReader::GetText(CellmapNode);
vector<wstring> LineVec; //最初に改行をデリミタとした文字列の配列にする Util::WStrToTokenVector(LineVec, MapStr, L'\n');
//ボックスの作成 void GameStage::CreateFixedBox() { auto BoxNodes = m_XmlDocReader->GetSelectNodes(L"GameStage/GameObjects/TilingFixedBox"); if (!BoxNodes) { throw BaseException( L"GameStage/GameObjects/TilingFixedBoxが見つかりません", L"if (!BoxNodes)", L"GameStage::CreateFixedBox()" ); } long CountNode = XmlDocReader::GetLength(BoxNodes); for (long i = 0; i < CountNode; i++) { auto Node = XmlDocReader::GetItem(BoxNodes, i); auto ScaleNode = XmlDocReader::GetSelectSingleNode(Node, L"Scale"); auto RotNode = XmlDocReader::GetSelectSingleNode(Node, L"Rot"); auto PosNode = XmlDocReader::GetSelectSingleNode(Node, L"Pos"); auto TexNode = XmlDocReader::GetSelectSingleNode(Node, L"Tex"); wstring ScaleStr = XmlDocReader::GetText(ScaleNode); wstring RotStr = XmlDocReader::GetText(RotNode); wstring PosStr = XmlDocReader::GetText(PosNode); wstring TexStr = XmlDocReader::GetText(TexNode); //トークン(カラム)の配列 vector<wstring> Tokens; //トークン(カラム)単位で文字列を抽出(L','をデリミタとして区分け) Util::WStrToTokenVector(Tokens, ScaleStr, L','); //各トークン(カラム)をスケール、回転、位置に読み込む Vec3 Scale( (float)_wtof(Tokens[0].c_str()), (float)_wtof(Tokens[1].c_str()), (float)_wtof(Tokens[2].c_str()) ); Tokens.clear(); Util::WStrToTokenVector(Tokens, RotStr, L','); Vec3 Rot; //回転はXM_PIDIV2の文字列になっている場合がある Rot.x = (Tokens[0] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[0].c_str()); Rot.y = (Tokens[1] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[1].c_str()); Rot.z = (Tokens[2] == L"XM_PIDIV2") ? XM_PIDIV2 : (float)_wtof(Tokens[2].c_str()); Tokens.clear(); Util::WStrToTokenVector(Tokens, PosStr, L','); Vec3 Pos( (float)_wtof(Tokens[0].c_str()), (float)_wtof(Tokens[1].c_str()), (float)_wtof(Tokens[2].c_str()) ); //各値がそろったのでオブジェクト作成 AddGameObject<TilingFixedBox>(Scale, Rot, Pos, 1.0f, 1.0f, TexStr); } }
auto BoxNodes = m_XmlDocReader->GetSelectNodes(L"GameStage/GameObjects/TilingFixedBox");
long CountNode = XmlDocReader::GetLength(BoxNodes); for (long i = 0; i < CountNode; i++) {
for (long i = 0; i < CountNode; i++) {
auto Node = XmlDocReader::GetItem(BoxNodes, i);
auto ScaleNode = XmlDocReader::GetSelectSingleNode(Node, L"Scale");
auto RotNode = XmlDocReader::GetSelectSingleNode(Node, L"Rot");
auto PosNode = XmlDocReader::GetSelectSingleNode(Node, L"Pos");
auto TexNode = XmlDocReader::GetSelectSingleNode(Node, L"Tex");
wstring ScaleStr = XmlDocReader::GetText(ScaleNode);
wstring RotStr = XmlDocReader::GetText(RotNode);
wstring PosStr = XmlDocReader::GetText(PosNode);
wstring TexStr = XmlDocReader::GetText(TexNode);
Tokens.clear();
Util::WStrToTokenVector(Tokens, RotStr, L',');