ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::camp Namespace Reference

Description:

This is the reference documentation of module ALib Camp of the ALib C++ Framework.
Besides the few entities found and documented here (namely in namespace alib::camp), this module "injects" several overloaded versions of the function CampVariable into namespace alib::variables.

See also
Please also consult the Programmer's Manual of this module.

Type Index:

class  Basecamp
class  Camp
class  DevtimeResourceCompiler
struct  ResourceFileError
 Represents an error that occurred with the function LoadResourceFile. More...
struct  ResourceListEntry

Type Definition Index:

using RCErrorList = StdVectorMA<ResourceFileError>
 A list of errors that occurred with LoadResourceFile.
using ResourceList = StdVectorMA<ResourceListEntry>
 A collection of resource entries, typically loaded from an .alibrc file.

Enumeration Index:

enum class  ResourceFileErrors {
  OK , RCFileNotFoundOrAccessible , ErrIllegalResourceName , ErrNameTooLong ,
  ErrLineEndWhileInQuotes , DuplicateResourceName , CPPFileNotFoundOrAccessible , CPPFileMissingStartMarker ,
  CPPFileMissingEndMarker , CPPFileNotWritable
}
 Error values that the function LoadResourceFile may return. More...
enum class  Variables { LOCALE = 1 , WAIT_FOR_KEY_PRESS = 2 , HAS_CONSOLE_WINDOW = 3 }

Function Index:

void ListErrors (RCErrorList &errors, Paragraphs &output, const PathString &fileName)
void LoadResourceFile (Path &rcFileName, ResourceList &destination, RCErrorList &errors)
void PatchCPPFile (const Path &cppFilePath, const ResourceList &resources, RCErrorList &errors, bool dryRun=false)

Type Definition Details:

◆ RCErrorList

A list of errors that occurred with LoadResourceFile.

Definition at line 64 of file resourcecompiler.hpp.

◆ ResourceList

A collection of resource entries, typically loaded from an .alibrc file.

Definition at line 61 of file resourcecompiler.hpp.

Enumeration Details:

◆ ResourceFileErrors

enum class alib::camp::ResourceFileErrors
strong

Error values that the function LoadResourceFile may return.

Enumerator
OK 

No error.

RCFileNotFoundOrAccessible 

Error opening the resource file.

ErrIllegalResourceName 

Resource name contains illegal characters. Allowed are ASCII characters 33 and 35-127.

ErrNameTooLong 

Resource name exceeds the maximum allowed length of 511 characters.

ErrLineEndWhileInQuotes 

Line ends while inside quotes.

DuplicateResourceName 

A duplicate resource name was found.

CPPFileNotFoundOrAccessible 

Error opening the cpp file to patch.

CPPFileMissingStartMarker 

Missing start marker in the cpp file to patch.

CPPFileMissingEndMarker 

Missing end marker in the cpp file to patch.

CPPFileNotWritable 

Error writing the cpp file to patch.

Definition at line 13 of file resourcecompiler.hpp.

◆ Variables

enum class alib::camp::Variables
strong

Configuration variables of ALib.

Note
As required by module ALib Variables, this enumeration is equipped with ALib Enum Records of type Declaration and resourced with this module.
Hence, all variable categories, names, default values and such can be modified by modifying the resource data of the singleton of class Basecamp.
Enumerator
LOCALE 

See ALIB/LOCALE.

WAIT_FOR_KEY_PRESS 

See ALIB/WAIT_FOR_KEY_PRESS.

HAS_CONSOLE_WINDOW 

See ALIB/HAS_CONSOLE_WINDOW.

Definition at line 32 of file basecamp.hpp.

Function Details:

◆ ListErrors()

void alib::camp::ListErrors ( RCErrorList & errors,
Paragraphs & output,
const PathString & fileName )

Writes a given list of errors (usually generated with function LoadResourceFile) to the given output in a human-readable format.

Parameters
errorsThe error list.
outputThe output formatter.
fileNameThe name of the resource file.

◆ LoadResourceFile()

void alib::camp::LoadResourceFile ( Path & rcFileName,
ResourceList & destination,
RCErrorList & errors )

Reads an external resource file (.alibrc) and appends parsed resources to destination.

Syntax Overview

Each resource entry starts at a non-empty, non-comment line:

<Key> [=] <Value>
  • Key
    • A sequence of printable ASCII characters (code 33..127), excluding " (double quote).
    • Ends at whitespace or at = (if present).
  • Optional =
    • Whitespace may surround it:
      • Key Value
      • Key=Value
      • Key = Value
  • Comments
    • A line whose first non-whitespace characters are # or // is ignored.

Value Types

  1. Quoted: starts with '"'.
    • Supports backslash escapes (e.g. '\n', '\t', '\\', '\"'</c>, ...). - Preserves spaces and tabs inside the quotes. 2. <strong>Plain</strong>: anything else on the same line. - Everything until end-of-line becomes the value (trailing whitespace is trimmed). - Backslash escapes are processed. 3. <strong>Block scalars</strong>: start with <c>'|'</c> or <c>'>'</c> (must appear as the first non-whitespace of the value) - <tt>Key |</tt> <c>Literal block: preserves newlines. - <tt>Key \></tt> <c>Folded block</c>: converts line breaks to single spaces, except that empty lines create paragraph breaks (<c>'\n'</c>). - Block content starts on the next line and is terminated by a non-empty line whose indentation is <strong>not greater</strong> than the indentation of the key line. (Empty lines are always part of the block.) - Backslash escapes are processed in the block content. - Trailing empty lines are ignored; i.e., trailing <c>'\\n'</c> characters are stripped from the parsed value. To enforce trailing newlines, use explicit escape sequences at the end of the last content line. 4. <strong>Compact scalars</strong>: start with <c>'~'</c> - Intended for machine-parsed token streams (e.g. <tt>a,1,b,2,...</tt>) that should be human-formattable in the resource file. - Outside quoted portions, <b>all whitespace is ignored</b> (including newlines in the block form). - Quoted portions are allowed and preserve whitespace: <c>DateC ~1,now,"1.1.2026",1,,2,file,1,filename,"my file"
    • Two forms:
      • Key ~ : compact until end-of-line.
      • Key ~| : compact block (indented), lines may be wrapped/aligned freely.
    • Backslash escapes are processed (inside and outside quotes).
Parameters
rcFileNameThe path to the .alibrc input file.
destinationThe destination vector to receive parsed resource entries.
errorsA list receiving read errors.

◆ PatchCPPFile()

void alib::camp::PatchCPPFile ( const Path & cppFilePath,
const ResourceList & resources,
RCErrorList & errors,
bool dryRun = false )

Patches a C++ source file with generated resource loading code.

This function updates a designated section in a C++ source file by replacing the content between two marker comments with generated code that loads resources via ResourcePool::BootstrapBulk.

The file given with cppFilePath must contain two commented marker lines:

  • ALIB-RESOURCE-COMPILER-REPLACEMENT-START
  • ALIB-RESOURCE-COMPILER-REPLACEMENT-END

All lines between these markers are replaced with generated key/value pairs formatted as C++ string literals suitable for ResourcePool::BootstrapBulk.

The generated code includes:

  • Properly escaped string literals for both keys and values
  • Multi-line values broken into readable segments
  • Aligned formatting for better readability

For an example of the generated output, see App/sample.cpp.

See also
This method is typically called by DevtimeResourceCompiler::Do.
Parameters
cppFilePathThe path to the C++ source file to patch.
resourcesThe list of resources to generate code for.
errorsA list receiving errors that might occur.
dryRunIf given as true, the file is not written.