### Generate Ordered and Unordered Lists in C++ Source: https://context7.com/srombauts/htmlbuilder/llms.txt Provides examples of creating ordered and unordered lists using HtmlBuilder. It demonstrates how to add list items, create nested lists, and apply CSS classes to lists and list items. The code shows both default unordered lists and explicitly ordered lists. ```cpp HTML::Document document("Lists Demo"); // Unordered list (default) document << (HTML::List() << HTML::ListItem("First item") << HTML::ListItem("Second item") << HTML::ListItem("Third item")); // Ordered list document << (HTML::List(true) // true = ordered << HTML::ListItem("Step 1") << HTML::ListItem("Step 2") << HTML::ListItem("Step 3")); // Nested lists with links document << (HTML::List() << HTML::ListItem("Simple text item") << (HTML::ListItem() << HTML::Link("Link item", "https://example.com")) << (HTML::ListItem() << (HTML::List() << HTML::ListItem("Nested item 1") << HTML::ListItem("Nested item 2")))); // List with CSS class HTML::List navList(false, "nav-items"); navList << (HTML::ListItem().cls("active") << HTML::Link("Home", "/")); navList << (HTML::ListItem() << HTML::Link("About", "/about")); document << std::move(navList); ``` -------------------------------- ### Enable Testing for HTMLBuilder Project Source: https://github.com/srombauts/htmlbuilder/blob/master/CMakeLists.txt This snippet enables the testing infrastructure for the HTMLBuilder project. It uses `enable_testing()` to activate CTest and then defines a specific test case named 'ExampleRun' that executes the 'HtmlBuilder_example' target, presumably to verify its successful completion. ```cmake # add a "test" target: enable_testing() # does the example1 runs successfully? add_test(ExampleRun HtmlBuilder_example) ``` -------------------------------- ### Generic CMake Build Configuration Source: https://github.com/srombauts/htmlbuilder/blob/master/README.md This bash script outlines the steps for configuring a generic build using CMake. It involves creating a build directory, navigating into it, and running the CMake command to generate build files. This is typically followed by a build command like 'make'. ```bash mkdir build cd buildcmake .. # cmake .. -G "Visual Studio 10" # for Visual Studio 2010cmake --build . # make ``` -------------------------------- ### Initialize and Update Git Submodules Source: https://github.com/srombauts/htmlbuilder/blob/master/README.md This bash command sequence is used to initialize and update Git submodules, which is a prerequisite for building the project if it relies on external dependencies managed as submodules. ```bash git submodule init git submodule update ``` -------------------------------- ### Create and Output HTML Document in C++ Source: https://context7.com/srombauts/htmlbuilder/llms.txt Demonstrates creating a basic HTML document with a title, meta tags, stylesheets, and content using the HtmlBuilder library. It shows how to add elements to the head and body and output the generated HTML to standard output or a string. ```cpp #include #include // Create document with title HTML::Document document("My Page Title"); document.addAttribute("lang", "en"); // Access head and body sections document.head() << HTML::Meta("utf-8") << HTML::Meta("viewport", "width=device-width, initial-scale=1"); document.head() << HTML::Rel("stylesheet", "https://example.com/style.css"); document.head() << HTML::Style("body { margin: 0; }"); document.body().cls("main-content"); // Add elements to body (shorthand via document <<) document << HTML::Header1("Welcome"); document << HTML::Paragraph("Hello World"); // Output as string or to stream std::cout << document; // Or: std::string html = document.toString(); ``` -------------------------------- ### Configure HtmlBuilder Output (C++) Source: https://context7.com/srombauts/htmlbuilder/llms.txt Shows how to configure HtmlBuilder for different output formats, including minified HTML and pretty-printed HTML with indentation and newlines. Configuration is done using preprocessor macros before including the library header. ```cpp // Configure BEFORE including headers (compile-time) #define HTML_INDENTATION 0 // No indentation (minified) #define HTML_ENDLINE "" // No newlines (minified) #include // Or use defaults for pretty-printed output #define HTML_INDENTATION 2 // 2-space indent (default) #define HTML_ENDLINE "\n" // Newlines (default) #include HTML::Document document("Output Demo"); document << HTML::Paragraph("Hello"); // Output to stream std::cout << document; // Output to string std::string html = document.toString(); // Implicit string conversion std::string html2 = document; // Output to file std::ofstream file("output.html"); file << document; ``` -------------------------------- ### Release Build Configuration with CMake Source: https://github.com/srombauts/htmlbuilder/blob/master/README.md This bash script shows how to configure a release build using CMake. It sets the build type to 'Release' and uses the 'Unix Makefiles' generator. The final CMake --build command compiles the project in release mode. ```bash mkdir Release cd Releasecmake .. -DCMAKE_BUILD_TYPE=Release # -G "Unix Makefiles"cmake --build . # make ``` -------------------------------- ### Create Links and Images in C++ with HtmlBuilder Source: https://context7.com/srombauts/htmlbuilder/llms.txt Shows how to generate hyperlink and image elements using HtmlBuilder. It covers creating simple links, links with various attributes (class, id, title, target), and image elements with source, alt text, and dimensions. It also demonstrates nesting elements within links. ```cpp HTML::Document document("Links Demo"); // Simple link document << HTML::Link("Google", "https://google.com"); // Link with attributes document << HTML::Link("External Site", "https://example.com") .cls("external-link") .id("main-link") .title("Visit Example") .target("_blank"); // Image element document << HTML::Image("logo.png", "Company Logo", 200, 100); // src, alt, width, height // Link wrapping other elements document << (HTML::Link() .addAttribute("href", "https://example.com") << HTML::Image("banner.png", "Click here")); ``` -------------------------------- ### Configure Doxygen for HTMLBuilder Project Source: https://github.com/srombauts/htmlbuilder/blob/master/CMakeLists.txt This snippet enables the Doxygen tool for generating C++ documentation within the HTMLBuilder project. It checks for Doxygen's availability. If found, it creates a custom target named 'doxygen' that executes the Doxygen command using a 'Doxyfile' and redirects its output to `/dev/null`, running from the project's source directory. ```cmake option(RUN_DOXYGEN "Run Doxygen C++ documentation tool." ON) if (RUN_DOXYGEN) find_package(Doxygen) if (DOXYGEN_FOUND) # add a Doxygen target to the "all" target add_custom_target(doxygen ALL COMMAND doxygen Doxyfile > ${DEV_NULL} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) endif (DOXYGEN_FOUND) else (RUN_DOXYGEN) message(STATUS "RUN_DOXYGEN OFF") endif (RUN_DOXYGEN) ``` -------------------------------- ### Create Div and Span Containers with C++ using HTMLBuilder Source: https://context7.com/srombauts/htmlbuilder/llms.txt Demonstrates the use of generic `div` and `span` container elements for grouping content and applying styles. It shows nesting, custom attributes like class, id, and inline styles. ```cpp HTML::Document document("Containers Demo"); // Div containers with nesting document << (HTML::Div("container") << (HTML::Div("row") << (HTML::Div("col-6") << HTML::Header2("Left Column") << HTML::Paragraph("Content here")) << (HTML::Div("col-6") << HTML::Header2("Right Column") << HTML::Paragraph("More content")))); // Div with custom attributes document << (HTML::Div() .cls("card") .id("main-card") .style("padding: 20px;") << HTML::Header3("Card Title") << HTML::Paragraph("Card body text.")); // Span for inline styling document << (HTML::Paragraph("Text with ") << HTML::Span("highlighted").style("color: red;") << HTML::Text(" words inside.")); ``` -------------------------------- ### Debug Build Configuration with CMake Source: https://github.com/srombauts/htmlbuilder/blob/master/README.md This bash script demonstrates how to configure a debug build using CMake. It specifies the build type as 'Debug' and uses the 'Unix Makefiles' generator. The subsequent CMake --build command compiles the project. ```bash mkdir Debug cd Debugcmake .. -DCMAKE_BUILD_TYPE=Debug # -G "Unix Makefiles"cmake --build . # make ``` -------------------------------- ### Configure Cppcheck for HTMLBuilder Project Source: https://github.com/srombauts/htmlbuilder/blob/master/CMakeLists.txt This snippet sets up `cppcheck`, a C++ static analysis tool, for the HTMLBuilder project. It searches for the `cppcheck` executable. If found, it defines a custom target named 'cppcheck' that runs `cppcheck` with specific configurations, including parallel execution and enabling style checks on the source directory. ```cmake option(RUN_CPPCHECK "Run cppcheck C++ static analysis tool." ON) if (RUN_CPPCHECK) find_program(CPPCHECK_EXECUTABLE NAMES cppcheck) if (CPPCHECK_EXECUTABLE) # add a cppcheck target to the "all" target add_custom_target(cppcheck ALL COMMAND cppcheck -j 4 --enable=style --quiet ${CPPCHECK_ARG_TEMPLATE} ${PROJECT_SOURCE_DIR}/src ) else (CPPCHECK_EXECUTABLE) message(STATUS "Could NOT find cppcheck") endif (CPPCHECK_EXECUTABLE) else (RUN_CPPCHECK) message(STATUS "RUN_CPPCHECK OFF") endif (RUN_CPPCHECK) ``` -------------------------------- ### Create Progress and Meter Elements (C++) Source: https://context7.com/srombauts/htmlbuilder/llms.txt Illustrates the creation of HTML progress bars and meter gauges using the HtmlBuilder library. The `Progress` element is suitable for tracking task completion, while the `Meter` element is used for representing values within a known range. ```cpp HTML::Document document("Gauges Demo"); // Progress bar (for tasks) document << HTML::Progress(75, 100); // value, max // Meter gauge (for measurements) document << HTML::Meter(6, 0, 10); // value, min, max ``` -------------------------------- ### Configure Cpplint for HTMLBuilder Project Source: https://github.com/srombauts/htmlbuilder/blob/master/CMakeLists.txt This snippet configures the `cpplint` tool for the HTMLBuilder project. It requires Python and checks for its availability. If found, it adds a custom target named 'cpplint' to the build process, which executes the `cpplint.py` script with specified arguments and source files. ```cmake option(RUN_CPPLINT "Run cpplint.py tool for Google C++ StyleGuide." ON) if (RUN_CPPLINT) find_package(PythonInterp) if (PYTHONINTERP_FOUND) # add a cpplint target to the "all" target add_custom_target(cpplint ALL COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/cpplint/cpplint.py ${CPPLINT_ARG_OUTPUT} ${CPPLINT_ARG_LINELENGTH} ${CPPLINT_ARG_VERBOSE} ${headers_files} ) else (PYTHONINTERP_FOUND) message(STATUS "Could NOT find Python") endif (PYTHONINTERP_FOUND) else (RUN_CPPLINT) message(STATUS "RUN_CPPLINT OFF") endif (RUN_CPPLINT) ``` -------------------------------- ### Add Head Elements to HTML Document (C++) Source: https://context7.com/srombauts/htmlbuilder/llms.txt Demonstrates how to add various head elements like meta tags, stylesheets, inline styles, and scripts to an HTML document using the HtmlBuilder library. It shows how to include external resources with integrity checks and place scripts at the end of the body. ```cpp HTML::Document document("Head Demo"); // Meta tags document.head() << HTML::Meta("utf-8"); document.head() << HTML::Meta("viewport", "width=device-width, initial-scale=1"); document.head() << HTML::Meta("description", "Page description for SEO"); document.head() << HTML::Meta("author", "Developer Name"); // External stylesheet with integrity document.head() << HTML::Rel("stylesheet", "https://cdn.example.com/style.css") .integrity("sha384-abc123...") .crossorigin("anonymous"); // Inline style document.head() << HTML::Style("body { font-family: Arial; } .highlight { color: blue; }"); // External script in head document.head() << HTML::Script("https://cdn.example.com/library.js") .integrity("sha384-xyz789...") .crossorigin("anonymous"); // Scripts at end of body (recommended) document << HTML::Script("https://code.jquery.com/jquery-3.6.0.min.js"); document << HTML::Script(nullptr, "console.log('Inline script');"); ``` -------------------------------- ### Generate HTML Document using C++ HtmlBuilder Source: https://github.com/srombauts/htmlbuilder/blob/master/README.md This C++ code snippet demonstrates how to use the HtmlBuilder library to create an HTML document. It showcases adding various elements like headers, paragraphs, links, lists, and tables, along with attributes and classes. ```cpp HTML::Document document("Welcome to HTML"); document.addAttribute("lang", "en"); document << HTML::Header2("Generated HTML") << HTML::Break() << HTML::Break(); document.body() << "Which results in the following HTML page (truncated to fit in this README): "; document << HTML::Text("Text directly in the body. ") << HTML::Text("Text directly in the body.") << HTML::Break() << HTML::Text("Text directly in the body."); document << HTML::Paragraph("This is the way to go for a big text in a multi-line paragraph."); document << HTML::Link("Google", "http://google.com").cls("my_style"); document << (HTML::Paragraph("A paragraph. ").addAttribute("style", "font-family:arial") << HTML::Text("Text child.") << HTML::Break() << HTML::Text("And more text.")); document << (HTML::List() << (HTML::ListItem("Text item")) << (HTML::ListItem() << HTML::Link("Github Link", "http://srombauts.github.io").title("SRombaut's Github home page")) << (HTML::ListItem() << (HTML::List() << HTML::ListItem("val1") << HTML::ListItem("val2")))); document << (HTML::Table() << (HTML::Row() << HTML::ColHeader("A") << HTML::ColHeader("B")) << (HTML::Row() << HTML::Col("Cell_11") << HTML::Col("Cell_12")) << (HTML::Row() << HTML::Col("Cell_21") << HTML::Col("Cell_22")) << (HTML::Row() << HTML::Col("") << HTML::Col("Cell_32"))); ``` -------------------------------- ### Generate Text and Formatting Elements in C++ Source: https://context7.com/srombauts/htmlbuilder/llms.txt Illustrates the use of HtmlBuilder to create various text and formatting elements within an HTML document. This includes headers (h1-h3), paragraphs with nested bold and italic text, raw text nodes, line breaks, and semantic elements like strong, small, mark, and preformatted text. ```cpp HTML::Document document("Text Demo"); // Headers (h1, h2, h3) document << HTML::Header1("Main Title"); document << HTML::Header2("Section Title"); document << HTML::Header3("Subsection"); // Paragraphs with nested content document << HTML::Paragraph("Simple paragraph text."); document << (HTML::Paragraph("Paragraph with ") << HTML::Bold("bold") << HTML::Text(" and ") << HTML::Italic("italic") << HTML::Text(" text.")); // Raw text nodes and line breaks document << HTML::Text("Text directly in body. "); document << HTML::Text("More text.") << HTML::Break(); // Semantic text elements document << HTML::Strong("Important text"); document << HTML::Small("Fine print text"); document << HTML::Mark("Highlighted text"); document << HTML::Pre("Preformatted\n code\n block"); ``` -------------------------------- ### Create HTML Semantic Elements with C++ using HTMLBuilder Source: https://context7.com/srombauts/htmlbuilder/llms.txt Builds HTML5 semantic elements for document structure, including header, nav, main, article, aside, footer, details, summary, and time. This facilitates better SEO and accessibility. ```cpp HTML::Document document("Semantic Demo"); // Page structure document << (HTML::Header() << HTML::Nav("main-nav") << HTML::Header1("Site Title")); document << (HTML::Main() << (HTML::Article() << HTML::Header2("Article Title") << HTML::Paragraph("Article content...") << (HTML::Figure() << HTML::Image("chart.png", "Data visualization") << HTML::FigCaption("Figure 1: Quarterly results"))) << (HTML::Aside() << HTML::Header3("Related Links") << (HTML::List() << HTML::ListItem("Link 1") << HTML::ListItem("Link 2")))); document << (HTML::Footer() << HTML::Small("Copyright 2024")); // Details/Summary expandable section document << (HTML::Details() << HTML::Summary("Click to expand") << HTML::Paragraph("Hidden content revealed when expanded.")); // Time element document << HTML::Time("January 1, 2024", "2024-01-01"); ``` -------------------------------- ### Create HTML Tables with C++ using HTMLBuilder Source: https://context7.com/srombauts/htmlbuilder/llms.txt Generates HTML tables including headers, rows, columns, captions, and cell spanning. It utilizes the HTML::Table, HTML::Row, HTML::Col, HTML::ColHeader, HTML::Caption, and styling methods. ```cpp HTML::Document document("Tables Demo"); // Basic table document << (HTML::Table() << (HTML::Row() << HTML::ColHeader("Name") << HTML::ColHeader("Age")) << (HTML::Row() << HTML::Col("Alice") << HTML::Col(30)) << (HTML::Row() << HTML::Col("Bob") << HTML::Col(25))); // Table with caption and styling document << (HTML::Table().cls("data-table") << HTML::Caption("User Information") << (HTML::Row() << HTML::ColHeader("ID") << HTML::ColHeader("Name") << HTML::ColHeader("Status")) << (HTML::Row() << HTML::Col(1) << HTML::Col("Alice") << HTML::Col("Active")) << (HTML::Row().style("background-color:#f0f0f0") << HTML::Col(2) << HTML::Col("Bob") << HTML::Col("Inactive"))); // Cell spanning document << (HTML::Table() << (HTML::Row() << HTML::ColHeader("Header").colSpan(2)) << (HTML::Row() << HTML::Col("Left") << HTML::Col("Right")) << (HTML::Row() << HTML::Col("Tall cell").rowSpan(2) << HTML::Col("Top")) << (HTML::Row() << HTML::Col("Bottom"))); // Cells with nested elements document << (HTML::Table() << (HTML::Row() << HTML::ColHeader("Link Column") << HTML::ColHeader("Value")) << (HTML::Row() << (HTML::Col() << HTML::Link("Click", "https://example.com")) << HTML::Col(3.14159))); ``` -------------------------------- ### Create HTML Forms and Inputs with C++ using HTMLBuilder Source: https://context7.com/srombauts/htmlbuilder/llms.txt Constructs HTML forms with various input types like text, password, email, number, date, checkboxes, radio buttons, selects, text areas, hidden fields, submit, and reset buttons. It also demonstrates creating datalists and standalone buttons. ```cpp HTML::Document document("Forms Demo"); // Complete form with various inputs document << (HTML::Form("/submit", "POST") << HTML::InputText("username").placeholder("Enter username").maxlength(50).required() << HTML::Break() << HTML::InputPassword("password") << HTML::Break() << HTML::InputEmail("email").placeholder("user@example.com") << HTML::Break() << HTML::InputNumber("age").min(0).max(120) << HTML::Break() << HTML::InputDate("birthdate") << HTML::Break() << HTML::InputCheckbox("newsletter", "yes", " Subscribe to newsletter").checked() << HTML::Break() << HTML::InputRadio("plan", "basic", " Basic") << HTML::InputRadio("plan", "premium", " Premium").checked() << HTML::Break() << HTML::TextArea("comments", 40, 5).maxlength(500) << HTML::Break() << HTML::InputHidden("csrf_token", "abc123") << HTML::InputSubmit("Submit Form") << HTML::InputReset("Clear")); // Select dropdown document << (HTML::Select("country") << HTML::Option("us", "United States").selected() << HTML::Option("uk", "United Kingdom") << HTML::Option("ca", "Canada")); // Datalist with autocomplete document << HTML::InputList("browser", "browsers"); document << (HTML::DataList("browsers") << HTML::Option("Chrome") << HTML::Option("Firefox") << HTML::Option("Safari")); // Standalone button document << HTML::Button("Click Me", "button").cls("btn btn-primary"); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.