Skip to content

ファイル出力

Kasuga Chiyo edited this page Feb 11, 2019 · 16 revisions

ファイル出力

csvファイルを書き込む

bool dtl::file::write::stl::csv(matrix, write_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, "write_test.csv");

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

	return 0;
}

書き込んだcsvデータ(write_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::write::stl::dtlm(matrix, write_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, "write_test.dtlm");

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

	return 0;
}

書き込んだdtlmデータ(write_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

出力例

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

bmpファイルを書き込む

bool dtl::file::write::stl::bmp(matrix, write_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::bmp(matrix, "write_test.bmp");

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

	return 0;
}

書き込んだbmpデータ(write_test.bmp)※バイナリデータ

42 4d 5e 00 00 00 00 00 00 00 3e 00 00 00 28 00 
00 00 0a 00 00 00 08 00 00 00 01 00 01 00 00 00 
00 00 20 00 00 00 0a 00 00 00 08 00 00 00 00 00 
00 00 00 00 00 00 ff ff ff 00 00 00 00 00 ff ff 
00 00 80 7f 00 00 80 60 00 00 80 60 00 00 80 60 
00 00 80 60 00 00 80 60 00 00 ff e0 00 00 

出力例

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

Clone this wiki locally