NDEVR
API Documentation
BoilerMaker.h
1#pragma once
2#include <NDEVR/File.h>
3#include <NDEVR/ApplicationResource.h>
4#include <NDEVR/InfoPipe.h>
5#include <NDEVR/Scanner.h>
6namespace NDEVR
7{
11 {
12 public:
13 File boiler_file = File("$(NDEVR_SOURCE_DIR)\\VS\\BoilerplateMaker\\Boiler.h");
19 String boiler(const File& file, LogPtr log) const
20 {
21 if (boiler_data.size() == 0)
22 {
24 boiler.expandEnvironmentalVars();
25 if (!boiler.exists())
26 {
27 log.addMessage("Warning Boiler: "+ boiler +" does not exist");
28 boiler_data = "\n";
29 return boiler_data;
30 }
31 log.addMessage("Reading Boiler:");
32 Scanner scan(boiler);
33 while (scan.nextLine())
34 {
35 String line = scan.currentLine();
36 log.addMessage(" " + line);
37 line.replace("[included_in_api]", "True");
38 line.replace("[authors]", ApplicationResource::username.get());
39 boiler_data += line + "\n";
40 }
41 }
42 String new_boiler = boiler_data;
43 new_boiler.replace("[file_name]", file.getPath(File::e_file_name));
44 new_boiler.replace("[library]", file.getParentDirectory().getParentDirectory().getFolderName());
45 return new_boiler;
46 }
47 };
48}
static Resource< String > username
The logged-in user's username.
Reads a boilerplate copyright/license header template and applies file-specific substitutions,...
Definition BoilerMaker.h:11
String boiler_data
Cached template data (loaded on first use).
Definition BoilerMaker.h:14
File boiler_file
Path to the boilerplate template file.
Definition BoilerMaker.h:13
String boiler(const File &file, LogPtr log) const
Generates the boilerplate header text for the given file.
Definition BoilerMaker.h:19
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
@ e_file_name
The file name without extension.
Definition File.h:77
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
Contains methods for easily reading objects in an ascii stream using set deliminators and line logic.
Definition Scanner.h:47
const String & currentLine() const
Returns a const reference to the current line being parsed.
Definition Scanner.h:108
virtual bool nextLine()
Advances the scanner to the next line in the stream.
The core String class for the NDEVR API.
Definition String.h:95
String & replace(const StringView &sub_string, const StringView &replace_sub_string, bool ignore_case=false, uint04 start_index=0)
Replaces ALL instances of a given substring with the provided replacement.
The primary namespace for the NDEVR SDK.
@ file
The source file path associated with this object.