/********************************************************
 *  ██████╗  ██████╗████████╗██╗
 * ██╔════╝ ██╔════╝╚══██╔══╝██║
 * ██║  ███╗██║        ██║   ██║
 * ██║   ██║██║        ██║   ██║
 * ╚██████╔╝╚██████╗   ██║   ███████╗
 *  ╚═════╝  ╚═════╝   ╚═╝   ╚══════╝
 * Geophysical Computational Tools & Library (GCTL)
 *
 * Copyright (c) 2023  Yi Zhang (yizhang-geo@zju.edu.cn)
 *
 * GCTL is distributed under a dual licensing scheme. You can redistribute 
 * it and/or modify it under the terms of the GNU Lesser General Public 
 * License as published by the Free Software Foundation, either version 2 
 * of the License, or (at your option) any later version. You should have 
 * received a copy of the GNU Lesser General Public License along with this 
 * program. If not, see <http://www.gnu.org/licenses/>.
 * 
 * If the terms and conditions of the LGPL v.2. would prevent you from using 
 * the GCTL, please consider the option to obtain a commercial license for a 
 * fee. These licenses are offered by the GCTL's original author. As a rule, 
 * licenses are provided "as-is", unlimited in time for a one time fee. Please 
 * send corresponding requests to: yizhang-geo@zju.edu.cn. Please do not forget 
 * to include some description of your company and the realm of its activities. 
 * Also add information on how to contact you by electronic and paper mail.
 ******************************************************/

#ifndef _GCTL_TEXT_IO2_H
#define _GCTL_TEXT_IO2_H

#include "../core.h"
#include "../utility.h"

namespace gctl
{
    struct text_content
	{
        // 头信息行数
		int head_num_;
		// 注释行起始符 标记行起始符 分割符
		char att_sym_, tag_sym_, deli_sym_;
		// 注释行 标记行
		std::vector<std::string> heads_, annotates_, tags_, contents_;

		/**
		 * @brief Construct a new text content object
		 * 
		 */
		text_content();

		/**
		 * @brief Destroy the text content object
		 * 
		 */
        ~text_content();

		/**
		 * @brief Construct a new text descriptor object and load text file
		 * 
		 * @param filename 文件名
		 * @param file_exten 文件扩展名
		 */
		text_content(std::string filename, std::string file_exten = ".txt");
		
		/**
		 * @brief 设置文件对象
		 * 
		 * @param att_sym 注释行起始符
		 * @param tag_sym 标记行起始符
		 * @param deli 分割符
		 * @param h_num 头信息行数
		 */
		void set(char deli_sym = ' ', int h_num = 0, char att_sym = '#', char tag_sym = '>');

        /**
         * @brief 清理字符串向量对象
         * 
         */
		void clear();

		/**
		 * @brief 读入文本文件
		 * 
		 * @param filename 文件名
		 * @param file_exten 文件扩展名
		 */
		void load_text(std::string filename, std::string file_exten = ".txt");
		
		/**
		 * @brief 写入文件文件
		 * 
		 * @param filename 文件名
		 * @param file_exten 文件扩展名
		 */
    	void save_text(std::string filename, std::string file_exten = ".txt");
	};    
}

#endif //_GCTL_TEXT_IO2_H