Skip to content

ファイル入力

Kasugaccho edited this page Mar 8, 2019 · 6 revisions

ファイル入力

csvファイルを読み込む

bool dtl::file::read::stl::csv<variable>(matrix, read_file_name);

#include <array>
#include "DTL.hpp"

int main() {

	using dungeon_t = bool;
	std::array<std::array<dungeon_t, 10>, 8> matrix{ {} };
	dtl::generator::common::stl::createBorder(matrix);
	dtl::file::write::stl::csv(matrix, "read_test.csv");

	dtl::file::read::stl::csv<dungeon_t>(matrix, "read_test.csv");

	dtl::console::output::stl::stringBool(matrix, "##", "  ");

	return 0;
}

読み込んだcsvデータ(read_test.csv)

1,1,1,1,1,1,1,1,1,1
1,0,0,0,0,0,0,0,0,1
1,0,0,0,0,0,0,0,0,1
1,0,0,0,0,0,0,0,0,1
1,0,0,0,0,0,0,0,0,1
1,0,0,0,0,0,0,0,0,1
1,0,0,0,0,0,0,0,0,1
1,1,1,1,1,1,1,1,1,1

出力例

####################
##                ##
##                ##
##                ##
##                ##
##                ##
##                ##
####################

dtlmファイルを読み込む(独自拡張子)

bool dtl::file::read::stl::dtlm(matrix, read_file_name);

#include <array>
#include "DTL.hpp"

int main() {

	using dungeon_t = bool;
	std::array<std::array<dungeon_t, 10>, 8> matrix{ {} };
	dtl::generator::common::stl::createBorder(matrix);
	dtl::file::write::stl::dtlm(matrix, "read_test.dtlm");

	dtl::file::read::stl::dtlm(matrix, "read_test.dtlm");

	dtl::console::output::stl::stringBool(matrix, "##", "  ");

	return 0;
}

読み込んだdtlmデータ(read_test.dtlm)※バイナリデータ

0a 00 00 00 00 00 00 00 08 00 00 00 00 00 00 00 
01 01 01 01 01 01 01 01 01 01 01 00 00 00 00 00 
00 00 00 01 01 00 00 00 00 00 00 00 00 01 01 00 
00 00 00 00 00 00 00 01 01 00 00 00 00 00 00 00 
00 01 01 00 00 00 00 00 00 00 00 01 01 00 00 00 
00 00 00 00 00 01 01 01 01 01 01 01 01 01 01 01

出力例

####################
##                ##
##                ##
##                ##
##                ##
##                ##
##                ##
####################

当記事のライセンス

CC0

Clone this wiki locally