[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 888bed1 1/2: Regularize layout
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 888bed1 1/2: Regularize layout |
Date: |
Wed, 31 Jan 2018 15:31:11 -0500 (EST) |
branch: master
commit 888bed139aec39f8ac9aa0afe3e5c3ef1c1095f6
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Regularize layout
Brought comments into conformance with general rules lmi uses elsewhere:
- Comment blocks that explain the purpose of an entity just prior to
a declaration are prefixed '///' and separated from the declaration
by a blank line. Rationale: these are the comments that ought to be
extracted by a tool such as doxygen, which recommended exactly this
formatting style (at least when lmi adopted this convention).
- Other comments generally use the ordinary C++ '//' comment prefix
rather than the distinctive doxygen style, and are not necessarily
followed by blank lines.
---
html.hpp | 15 +++++++++++++--
interpolate_string.hpp | 1 +
ledger_evaluator.hpp | 1 +
output_mode.hpp | 1 +
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/html.hpp b/html.hpp
index 5ce1306..1daac80 100644
--- a/html.hpp
+++ b/html.hpp
@@ -41,6 +41,7 @@
/// for structured HTML generation, which guarantees that the result is
/// well-formed. By using predefined constants in html::tag and html::attr
/// namespaces, typos in the element names can also be automatically avoided.
+
namespace html
{
@@ -53,6 +54,7 @@ namespace html
///
/// As it still needs to be converted to a string sooner or later to be really
/// used, it does provide a conversion -- but it can be used only once.
+
class text
{
public:
@@ -67,6 +69,7 @@ class text
/// appears correctly inside HTML element contents. Notice that we don't
/// need to escape quotes here as we never use the result of this function
/// inside an HTML attribute, only inside HTML elements.
+
static text from(std::string const& s)
{
std::string z;
@@ -87,12 +90,14 @@ class text
/// Use the given string with HTML inside it directly. No escaping is done
/// by this ctor.
+
static text from_html(std::string s)
{
return text{std::move(s)};
}
/// Just a symbolic name for a non breaking space HTML entiry.
+
static text nbsp()
{
return text::from_html(" ");
@@ -102,6 +107,7 @@ class text
///
/// This method allows chained invocation for appending more than one
/// fragment at once.
+
text& operator+=(text const& t)
{
m_html += t.m_html;
@@ -130,6 +136,7 @@ class text
};
/// Represents a single attribute of an HTML element.
+
class attribute
{
public:
@@ -162,7 +169,7 @@ namespace detail
class LMI_SO any_element
{
public:
- /// Ctor should only be used with literal strings as argument.
+ // Ctor should only be used with literal strings as argument.
explicit any_element(char const* name)
:name_(name)
{
@@ -200,7 +207,7 @@ class LMI_SO any_element
class LMI_SO element : private detail::any_element
{
public:
- /// Ctor should only be used with literal strings as argument.
+ // Ctor should only be used with literal strings as argument.
explicit element(char const* name)
:detail::any_element(name)
{
@@ -210,6 +217,7 @@ class LMI_SO element : private detail::any_element
element(element&&) = default;
/// Add an attribute.
+
element operator[](attribute const& attr) const&
{
element e{*this};
@@ -224,6 +232,7 @@ class LMI_SO element : private detail::any_element
}
/// Add inner contents.
+
element operator()(text contents) const&
{
element e{*this};
@@ -245,6 +254,7 @@ class LMI_SO element : private detail::any_element
/// text in our own operator() and also use operator+() defined below to
/// concatenate HTML elements without having to convert them to text
/// beforehand.
+
operator text() const;
private:
@@ -254,6 +264,7 @@ class LMI_SO element : private detail::any_element
};
/// Represents a void HTML element which can't have anything inside it.
+
class void_element : private detail::any_element
{
public:
diff --git a/interpolate_string.hpp b/interpolate_string.hpp
index 344657a..2b6914a 100644
--- a/interpolate_string.hpp
+++ b/interpolate_string.hpp
@@ -61,6 +61,7 @@ using lookup_function
/// built-in way to escape them.
///
/// Throw if the lookup function throws or if the string uses invalid syntax.
+
std::string LMI_SO interpolate_string
(char const* s
,lookup_function const& lookup
diff --git a/ledger_evaluator.hpp b/ledger_evaluator.hpp
index 23bc7cc..2d9ea82 100644
--- a/ledger_evaluator.hpp
+++ b/ledger_evaluator.hpp
@@ -33,6 +33,7 @@
/// Class allowing to retrieve the string representation of any scalar or
/// vector stored in a ledger.
+
class LMI_SO ledger_evaluator
{
public:
diff --git a/output_mode.hpp b/output_mode.hpp
index c074280..9b7a05c 100644
--- a/output_mode.hpp
+++ b/output_mode.hpp
@@ -27,6 +27,7 @@
/// Convenient enum used with functions that can either actually render
/// something or just pretend doing it in order to compute the space that would
/// be taken by it, in the layout phase.
+
enum enum_output_mode
{e_output_normal
,e_output_measure_only