WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
AutoDoc.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX INC 2025. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX INC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX INC.
15******************************************************************************/
16#ifndef AUTO_DOC_H
17#define AUTO_DOC_H
18
19#include <vector>
20#include <string>
21#include <stdio.h>
22
23// Return codes for success/failure
24#define AUTODOC_SUCCESS 0
25#define AUTODOC_FAILURE 1
26
27namespace warptwin {
28
29 // String constants for asciidoc
30 const std::string TITLE = "= ";
31
32 const std::string AUTHOR_EMAIL_START = " <";
33 const std::string AUTHOR_EMAIL_END = "> ";
34
35 const std::string HEADER_ONE = "== ";
36
37 const std::string HEADER_TWO = "=== ";
38
39 const std::string CODE_LITERAL = "```";
40
41 const std::string TABLE_HEADER_START = "[\%header,cols=";
42 const std::string TABLE_HEADER_END = "*]\n";
43 const std::string TABLE_MARKER = "|===\n";
44 const std::string TABLE_LINE_START = "|";
45
46 const std::string IMAGE_START = "image::";
47 const std::string ALIAS_START = "[";
48 const std::string ALIAS_END = "]";
49
50 const std::string LINK_START = "link:++";
51 const std::string LINK_END = "++";
52
53 const std::string DOC_REF_START = "xref:";
54
80 class AutoDoc {
81 public:
85 AutoDoc(unsigned int string_alloc=4096);
86
89
96 int file(const std::string &filename);
97 std::string file() {return _filename;}
98
104 int title(const std::string &str);
105
112 int author(const std::string &name, const std::string &email="");
113
117 int addPrimaryHeader(const std::string &str);
118
122 int addSecondaryHeader(const std::string &str);
123
127 int addText(const std::string &str);
128
133 int addImage(const std::string &file, const std::string &alias="");
134
150 int addTable(const std::vector<std::vector<std::string>> &data,
151 const std::vector<std::string> &col_headers={},
152 const std::vector<std::string> &row_headers={},
153 bool write_method=true);
169 int addTable(const std::vector<std::vector<long int>> &data,
170 const std::vector<std::string> &col_headers={},
171 const std::vector<std::string> &row_headers={},
172 bool write_method=true);
188 int addTable(const std::vector<std::vector<double>> &data,
189 const std::vector<std::string> &col_headers={},
190 const std::vector<std::string> &row_headers={},
191 bool write_method=true);
192
196 int addCodeBlock(const std::string &str);
197
202 int addLink(const std::string &link, const std::string &alias="");
203
208 int addDocReference(const std::string &name, const std::string &alias="");
209
211 void closeFile();
212 private:
217 template <typename T>
218 int _addTable(const std::vector<std::vector<T>> &data,
219 const std::vector<std::string> &col_headers,
220 const std::vector<std::string> &row_headers,
221 bool write_method);
222
226 void _write(const std::string &str);
227
231 void _write(long int val);
232
236 void _write(double val);
237
241 FILE* _fp = nullptr;
242
244 std::string _filename;
245
249 std::string _internal_str = "";
250
251 // These lock variables indicate when a key parameter, like a file
252 // or the title, have been locked and can no longer be written
253 // (For things that can only be written in a particular location)
254 bool _file_lock = false;
255 bool _title_lock = false;
256 bool _author_lock = false;
257 };
258
259}
260
261#endif
int addText(const std::string &str)
Function to add an exact string to a document.
Definition AutoDoc.cpp:114
void closeFile()
Function to close the file held internally by AutoDoc.
Definition AutoDoc.cpp:213
int addLink(const std::string &link, const std::string &alias="")
Function to add an external link to the document.
Definition AutoDoc.cpp:178
int addCodeBlock(const std::string &str)
Function to add a code block to a document.
Definition AutoDoc.cpp:164
std::string file()
Definition AutoDoc.h:97
~AutoDoc()
Destructor – just closes our file.
Definition AutoDoc.h:88
AutoDoc(unsigned int string_alloc=4096)
Default constructor for the AutoDoc class.
Definition AutoDoc.cpp:22
int addDocReference(const std::string &name, const std::string &alias="")
Function to add a link to another asciidoc document.
Definition AutoDoc.cpp:196
int addTable(const std::vector< std::vector< std::string > > &data, const std::vector< std::string > &col_headers={}, const std::vector< std::string > &row_headers={}, bool write_method=true)
Function to write a table to our document.
Definition AutoDoc.cpp:143
int addPrimaryHeader(const std::string &str)
Function to add a primary header to document.
Definition AutoDoc.cpp:88
int addSecondaryHeader(const std::string &str)
Function to add a secondary header to document.
Definition AutoDoc.cpp:101
int title(const std::string &str)
Function to write a title to the document.
Definition AutoDoc.cpp:51
int addImage(const std::string &file, const std::string &alias="")
Function to add an image to the document.
Definition AutoDoc.cpp:127
int author(const std::string &name, const std::string &email="")
Function to write author name and email to document.
Definition AutoDoc.cpp:68
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
const std::string TABLE_LINE_START
Definition AutoDoc.h:44
const std::string ALIAS_END
Definition AutoDoc.h:48
const std::string DOC_REF_START
Definition AutoDoc.h:53
const std::string TITLE
Definition AutoDoc.h:30
const std::string HEADER_TWO
Definition AutoDoc.h:37
const std::string TABLE_HEADER_START
Definition AutoDoc.h:41
const std::string TABLE_MARKER
Definition AutoDoc.h:43
const std::string AUTHOR_EMAIL_END
Definition AutoDoc.h:33
const std::string LINK_START
Definition AutoDoc.h:50
const std::string TABLE_HEADER_END
Definition AutoDoc.h:42
const std::string AUTHOR_EMAIL_START
Definition AutoDoc.h:32
const std::string ALIAS_START
Definition AutoDoc.h:47
const std::string LINK_END
Definition AutoDoc.h:51
const std::string CODE_LITERAL
Definition AutoDoc.h:39
const std::string HEADER_ONE
Definition AutoDoc.h:35
const std::string IMAGE_START
Definition AutoDoc.h:46