- Removes Grantlee5 from build pipeline
Qt6 Migration CI / migrate (push) Waiting to run

- Moves prompts to another side

Entire-Checkpoint: 01M1PYACGS4RVW2T93Z7WCQH2X
This commit is contained in:
torsten committed 2026-09-04 21:28:50 +02:00
1 parent 30243ea2ed
commit cdba162176
57 files changed
-6256

No files matched your search

@@ -1,179 +0,0 @@
Du arbeitest in einem bestehenden Legacy-Repository ./qt-migration-legatus/qt5-before/qt5-legatus-legacy und sollst eine risikoarme Migration des Codegenerators vorbereiten und umsetzen.
## Ziel
Das Projekt verwendet aktuell ein eigenes Codegen-Tool auf Basis von Grantlee5, um aus Service-XML verschiedene Artefakte zu erzeugen, darunter:
- `.idl`
- `.h`
- `.cpp`
- `.sql`
- kopierte `.xml`
Das Legacy-Projekt basiert auf Qt5.
Das Ziel ist Qt6.
Grantlee5 soll durch KDE KTextTemplate ersetzt werden.
Du sollst den bestehenden Generator analysieren, einen minimal-invasiven Migrationspfad entwerfen und den Generator so portieren oder neu implementieren, dass er unter Qt6 mit KTextTemplate funktioniert, ohne die bestehende Build-Integration unnötig zu brechen.
## Wichtiger Kontext
Aus `MacroCodeGenIdl.cmake` geht hervor:
- Es gibt zentrale Codegen-Actions wie:
- `DDS_TOPICS`
- `DATABASE`
- `DATABASE_SERVER`
- `SQL`
- `dao`
- Aus XML werden je nach Action mehrere Ausgabedateien erzeugt.
- Die CMake-Makros erwarten bestimmte Dateinamen und Ausgabepfade.
- Templates liegen unter `Lts/Common/CodeGen/*.grantlee`.
- `CODEGEN_TOPIC_TYPEDEFS(...)` verwendet separat ein Python-Skript (`codegen_simple.py`).
- Die `.idl`-Dateien sind hier generierte Textartefakte; sie sind nicht automatisch als C++ zu behandeln.
- C++-Header/Implementierungen, SQL und XML müssen im Generator als unterschiedliche Artefakttypen sauber behandelt werden.
## Deine Aufgaben
### 1) Bestehendes System analysieren
Untersuche zuerst vollständig:
- das aktuelle `codegen`-Tool
- alle Aufrufstellen der Codegen-Actions
- alle `*.grantlee`-Templates
- XML-Parsing und Context-Aufbau
- eventuelle benutzerdefinierte Grantlee-Filter, Tags, Helper, Loader oder Include-Mechanismen
- die CMake-Integration rund um `MacroCodeGenIdl.cmake`
Suche insbesondere nach:
- `codegen`
- `Grantlee`
- `*.grantlee`
- `DDS_TOPICS`
- `DATABASE`
- `DATABASE_SERVER`
- `dao`
- `SQL`
- `codegen_simple.py`
### 2) Zielarchitektur ableiten
Leite auf Basis des Ist-Zustands eine Zielarchitektur ab für einen Qt6-basierten Generator mit KTextTemplate:
- Ein-/Ausgabe-Modell
- Zuordnung Action → Template(s) → Output-Dateien
- XML → internes Datenmodell → Template-Context
- Include-/Partial-Strategie
- Fehlerbehandlung
- deterministische Dateigenerierung
- Encoding/Newline-Verhalten
- Logging/Diagnostik bei Template-Fehlern
### 3) Migration implementieren
Setze die Migration minimal-invasiv um:
- Qt6 statt Qt5
- KTextTemplate statt Grantlee5
- Bestehende Action-Namen und CMake-Aufrufmuster möglichst beibehalten
- Bestehende Dateinamen und Output-Orte beibehalten
- bestehende Template-Logik so weit wie möglich kompatibel halten
Wenn direkte Kompatibilität nicht möglich ist:
- implementiere eine dünne Adapter-/Kompatibilitätsschicht
- oder migriere betroffene Templates kontrolliert und dokumentiert
### 4) Build-System anpassen
Passe CMake so an, dass:
- der neue Generator im Qt6-Setup gebaut wird
- die bestehenden Makros nach Möglichkeit weiter funktionieren
- Incremental Builds nicht unnötig verschlechtert werden
- Abhängigkeiten auf Templates und XML sauber erhalten bleiben
### 5) Dokumentation ergänzen
Erstelle Migrationsnotizen in Markdown:
- bisherige Architektur
- neue Architektur
- Unterschiede Grantlee5 vs. KTextTemplate
- notwendige Template-Anpassungen
- bekannte Inkompatibilitäten
- offene Risiken
- Follow-up-Empfehlungen
## Harte Randbedingungen
- Keine unnötige Komplett-Neuschreibung.
- Keine großflächigen Refactorings außerhalb des Codegen-Bereichs.
- Keine Änderung der fachlichen XML-Semantik ohne klare Notwendigkeit.
- Keine Änderung der erwarteten Output-Dateinamen ohne sehr gute Begründung.
- Keine Änderung der öffentlichen CMake-Makro-Schnittstellen, wenn vermeidbar.
- Python-basierten Teil (`codegen_simple.py`) nur dann anfassen, wenn er für Qt6-/Build-Kompatibilität relevant ist.
## Erwartetes Vorgehen
1. Zuerst analysieren, nicht blind umschreiben.
2. Dann eine kurze Migrationsstrategie formulieren.
3. Danach gezielte Codeänderungen durchführen.
4. Änderungen klein und reviewbar halten.
5. Wenn möglich vorhandene Tests/Build-Ziele nutzen oder ergänzen.
6. Falls keine Tests existieren, mindestens Plausibilitätschecks für die Generierung einbauen.
## Explizit zu prüfende Risiken
Prüfe und dokumentiere ausdrücklich:
- benutzerdefinierte Grantlee-Filter/Tags
- Unterschiede bei Schleifen, Includes, Escaping und Kontextauflösung
- Mehrfachgenerierung pro Action
- Pfad- und Dateinamenskonventionen
- Reihenfolge/Stabilität generierter Inhalte
- UTF-8 / Zeilenenden
- Verhalten bei fehlenden XML-Feldern
- Fehlerdiagnose bei Template-Rendering-Problemen
- CMake-Dependencies und Rebuild-Verhalten
## Akzeptanzkriterien
Die Aufgabe ist erst dann fertig, wenn mindestens Folgendes erfüllt ist:
1. Ein Qt6-basierter Generator existiert oder der alte Generator ist erfolgreich auf Qt6 portiert.
2. Grantlee5-Abhängigkeit ist im migrierten Pfad entfernt oder isoliert ersetzt.
3. KTextTemplate wird für das Rendering verwendet.
4. Die bisherigen zentralen Actions sind weiterhin abbildbar:
- `DDS_TOPICS`
- `DATABASE`
- `DATABASE_SERVER`
- `SQL`
- `dao`
5. Die generierten Output-Dateien bleiben in Namen und Verzeichnisstruktur kompatibel, soweit technisch möglich.
6. Die CMake-Integration funktioniert weiterhin mit den vorhandenen Makros oder mit minimalen kompatiblen Anpassungen.
7. Die Migration ist dokumentiert.
8. Bekannte Inkompatibilitäten und Restarbeiten sind klar benannt.
## Definition of Done
Am Ende liefere bitte:
1. **Kurze Architekturzusammenfassung**
- Alt
- Neu
- wichtigste Unterschiede
2. **Umgesetzte Migrationsentscheidungen**
- warum KTextTemplate so eingebunden wurde
- ob Adapter oder direkte Template-Migration gewählt wurde
- warum
3. **Liste aller geänderten Dateien**
4. **Konkrete Codeänderungen**
- inklusive CMake-Anpassungen
- Generator-Code
- Template-Anpassungen
- Doku
5. **Validierung**
- was gebaut/getestet wurde
- was nur statisch geprüft wurde
- was noch offen ist
6. **Offene Risiken / Follow-ups**
## Bevorzugte Ergebnisqualität
Bevorzuge eine inkrementelle, robuste Migration über eine elegante, aber riskante Neuentwicklung.
Wenn mehrere Wege möglich sind, entscheide dich für den mit:
- geringstem Integrationsrisiko
- geringster Build-Störung
- bester Nachvollziehbarkeit im Review
Wenn Annahmen notwendig sind:
- triff sie explizit,
- dokumentiere sie,
- und halte Änderungen reversibel.
Bitte arbeite repository-basiert und leite Entscheidungen aus dem tatsächlich vorhandenen Code ab, nicht aus allgemeinen Annahmen über Grantlee oder KTextTemplate.
@@ -1,167 +0,0 @@
# GitHub Copilot Instructions: Qt5/C++11 to Qt6/C++17 Migration
## Mission
Migrate the legacy Qt5/C++11 desktop application to Qt6/C++17, preserve behavior unless change is strictly required, and validate the result completely in the repository’s Docker-based CI workflow.
## Operating Mode
- Work autonomously from analysis through validation.
- Do not stop after editing code.
- Continue until configure, build, tests, and policy checks have been attempted in Docker.
- Do not ask for confirmation during normal implementation.
- Stop early only if required source material is missing, the task is impossible, or a destructive action would be required.
## Boundaries
- Read the legacy project from `./qt-migration-legatus/qt5-before/qt5-legatus-legacy`.
- Write the migrated project to `./qt-migration-legatus/qt6-after/qt6-migrated-legatus`.
- Do not modify the legacy source tree in place.
- Limit changes to the target tree and only the CI/build/test files needed to support migration and validation.
## Main Migration Targets
- Upgrade Qt5 to Qt6.
- Upgrade C++11/14/17 code to C++17.
- Keep Qt Core, Gui, and Widgets explicitly linked.
- Replace `QRegExp` with `QRegularExpression`.
- Replace `QDesktopWidget` and `QApplication::desktop()` with `QScreen`-based Qt6 APIs.
- Remove legacy `QTextCodec` usage and adopt Qt6-safe text handling.
- Replace old `SIGNAL`/`SLOT` syntax with function-pointer connect syntax.
- Replace `0`/`NULL` pointer literals with `nullptr`.
- Preserve `.ui` and `.qrc` integration.
- Preserve behavior unless Qt6 compatibility requires adaptation.
## C++17 Modernization Rules
- Preserve semantics first; modernize second.
- Use `auto` when the type is obvious; avoid it when it hides important type information.
- Prefer structured bindings where clearer.
- Replace raw owning pointers/manual `delete` with RAII, usually `std::unique_ptr`.
- Use `std::make_unique` / `std::make_shared`; use `std::shared_ptr` only for real shared ownership.
- Use `std::string_view` only when lifetime safety is clear.
- Prefer `std::span` for non-owning contiguous data; use `std::mdspan` only when multidimensional access clearly benefits.
- Prefer `.contains()` over `find(...) != end()` where available.
- Prefer algorithms and ranges over manual loops when readability improves.
- Use `[[nodiscard]]` when ignoring a result is likely a bug.
- Prefer early returns over deeply nested control flow.
- Use `std::optional` monadic operations (`and_then`, `transform`, `or_else`) when clearer.
- Prefer `constexpr`, `if constexpr`, concepts, and `requires` over legacy `std::enable_if`/SFINAE where practical.
- Add `noexcept`, `override`, `final`, `= default`, and `= delete` where correct and useful.
- Prefer `enum class` over unscoped enums where practical.
- Prefer `std::print` / `std::println` when supported by the toolchain.
- Prefer typed `std::chrono` durations and `std::jthread` where appropriate.
## Safety Rules
- Do not change business logic unless explicitly requested or required for Qt6 compatibility.
- Do not introduce unsupported Qt6/C++17 features.
- Do not silently change ABI, ownership, lifetime, exception behavior, performance, UI behavior, or event ordering.
- Do not worsen readability for the sake of modernization.
- Do not refactor code.
- Avoid dangling references, dangling `std::string_view`, and ownership ambiguity.
- Keep includes minimal and preserve repository-local formatting/style.
- no code cleanup
- no renaming
- no extraction of functions/classes
- no restructuring of logic
- no stylistic rewrites
- no dependency modernization
- no opportunistic improvements
- no behavior changes beyond path/build necessity
## Tests
- For every code change inside a method, add at least three tests covering the changed behavior.
- Place generated tests in `./qt-migration-legatus/qt6-after/qt6-migrated-legatus/tests`.
- Use policy-compatible test filenames such as:
- `test_<name>.cpp`
- `<name>_test.cpp`
- `<name>test.cpp`
- `<name>gtest.cpp`
as searched for in `./qt-migration-legatus/ci/check_pr_policies.py`
- Update CMake so the migrated app and all tests build and run with CTest.
- Ensure all tests are registered with CTest.
## Docker-First Validation
Use `lifemaps/ci-cpp:latest` as the authoritative environment. Do not substitute host tools for missing container tools. Treat `./qt-migration-legatus/ci/Dockerfile.ci` as the source of truth for CI dependencies.
### Required validation sequence
1. Configure in Docker
2. Build in Docker
3. Run tests in Docker
4. If tests pass, run `python3 ci/check_pr_policies.py` in Docker
### Recommended commands
- Configure:
`cmake -S ./qt-migration-legatus/qt6-after/qt6-migrated-legatus -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug`
- Build:
`cmake --build build --parallel`
- Test:
`ctest --test-dir build --output-on-failure`
- Policy:
`python3 ./qt-migration-legatus/ci/check_pr_policies.py`
Adapt paths/flags only if repository inspection proves they must differ.
## Missing-Tool Remediation
If Docker validation fails because a required tool/package is missing:
- identify the exact missing dependency
- update `./qt-migration-legatus/ci/Dockerfile.ci` minimally
- rebuild `lifemaps/ci-cpp:latest`
- rerun the full validation sequence
Continue until:
- validation succeeds, or
- the next blocker is a genuine project/code issue
## Failure Classification
Environment failures:
- command not found
- missing compiler/toolchain utility
- missing Qt dev package
- missing CMake/Ninja/CTest support tool
- missing dependency required by `./qt-migration-legatus/ci/check_pr_policies.py`
Project failures:
- compile errors
- linker errors
- failing tests
- formatting/policy failures caused by migration changes
## Policy Awareness
- `./qt-migration-legatus/ci/check_pr_policies.py` checks formatting for changed C/C++ files, expects related tests, and verifies commit-signature conditions in its diff range.
- Ensure Docker validation runs with mounted workspace and git metadata available.
- Do not claim success unless the policy script passes.
## Execution Plan
1. Inspect `./qt-migration-legatus/` and the target tree.
2. Identify Qt5 and legacy C++ constructs to migrate.
3. Migrate incrementally in `qt6-after/qt6-migrated-legatus`.
4. Add/update tests with each behavior-relevant change.
5. Update CMake/test registration.
6. Validate in Docker.
7. If missing dependencies are found, update `./qt-migration-legatus/ci/Dockerfile.ci`, rebuild, and rerun.
8. Repeat until success or a real project defect remains.
## Reporting
Group change explanations by:
- CMake / build-system migration
- Qt API replacements
- C++ modernization
- UI/resource preservation
- tests added
- `./qt-migration-legatus/ci/Dockerfile.ci` / container updates
Also provide a concise changed-files summary.
## Completion Criteria
Success requires:
- migrated project exists under `./qt-migration-legatus/qt6-after/qt6-migrated-legatus`
- configure succeeds in Docker
- build succeeds in Docker
- tests succeed in Docker
- `python3 ci/check_pr_policies.py` succeeds in Docker after tests pass
## Final Response
- State whether migration is fully validated or which blocker remains.
- List the exact Docker commands used for image rebuild, configure, build, test, and policy check.
- For every failed attempt, include:
- exact command
- key error
- environment vs project classification
- fix applied
- End with a short summary of any remaining blocker.
-94
View File
@@ -1,94 +0,0 @@
Task: Work in this workspace with multiple Git repositories. Before making any changes, determine the correct target repository for each file based strictly on its path, then perform changes, validation, and commits only in the matching repository.
Repository layout detected under `./`:
- `./.git`
- `./qt-migration-legatus/.git`
- `./qt-migration-legatus/qt5-before/qt5-legatus-legacy/.git`
- `./jenkins-ci-rme/.git`
- `./rpmbuild/.git`
Critical constraint:
There are multiple Git repositories in this workspace. You must first determine for each planned change which repository root it belongs to, based strictly on the file path. Each change must be made and committed in the matching Git repository only.
Repository mapping in this workspace:
- files under `./qt-migration-legatus/` -> commit only in `./qt-migration-legatus`
- files under `./jenkins-ci-rme/` -> commit only in `./jenkins-ci-rme`
- files under `./rpmbuild/` -> commit only in `./rpmbuild`
- files at workspace root `./...` not inside one of the sub-repositories -> commit only in `./`
Rules derived from this:
- Never commit a file from one repository into another repository.
- Never use `./` as the commit target for files that belong to `./qt-migration-legatus`, `./qt-migration-legatus/qt5-before/qt5-legatus-legacy/`, `./jenkins-ci-rme`, or `./rpmbuild`.
- Never use a sub-repository as the commit target for files that belong to workspace root `./`.
- Before changing any file, determine its owning repository from its path and show that mapping explicitly.
- If a planned change spans multiple repositories, handle each repository separately.
- Create separate status checks, validation runs, and commits per repository.
- If repository ownership for any file is ambiguous, stop and report it instead of guessing.
Signed commit requirement:
- Only signed commits are allowed.
- Do not create unsigned commits.
- Before committing in any repository, verify that commit signing is configured and usable for that repository context.
- Check at minimum:
- `git config --global --list`
- `cd <repo> && git config --get commit.gpgsign`
- `cd <repo> && git config --get user.signingkey`
- If repository-local signing settings exist, inspect and respect them as well.
- If signing is required but not configured or not functional, stop and report the exact reason.
- When committing, create a signed commit only.
- After committing, show evidence that the created commit is signed by running:
- `cd <repo> && git log -1 --show-signature`
Required checks before making any changes:
1. `ssh -T devel`
2. `git config --global --list`
3. `find . -type d -name .git -prune | sort`
Then, for each repository that will actually be modified, run these checks in that repository before making changes:
1. `cd <repo> && pwd`
2. `cd <repo> && git rev-parse --is-inside-work-tree`
3. `cd <repo> && git rev-parse --show-toplevel`
4. `cd <repo> && git remote -v`
5. `cd <repo> && git branch --show-current`
6. `cd <repo> && git status --short`
7. `cd <repo> && git config --get remote.origin.url`
Repository-selection procedure:
- List every file you plan to modify.
- For each file, map it to exactly one repository root using the path rules above.
- Group planned changes by repository before making any edits.
- Show the grouping explicitly before changing files.
Hard rules:
- Do not guess. Do not silently switch repositories.
- Do not modify files before their owning repository has been identified and checked.
- If any repository check fails: stop for that repository and report the exact reason.
- If a file would be committed from the wrong repository: stop.
- If `git rev-parse --show-toplevel` does not match the expected repository root for a file: stop.
- If there is no sensible remote or no plausible write access for a repository: stop for that repository.
- Do not combine changes from different repositories into one commit.
- Do not skip validation for any repository being changed.
Validation:
- Run all relevant tests for the changes in each affected repository.
- Run all locally checkable check-in policies for each affected repository.
- Keep validation scoped to the repository being changed.
- If tests or policies fail, or cannot be executed, do not commit in that repository.
Automatic commit:
- If all checks, tests, and check-in policies pass for a repository, commit automatically in that repository.
- Before committing, show: `cd <repo> && git status --short`
- After committing, output:
- `cd <repo> && git rev-parse HEAD`
- current branch
- remote URL
- changed files
Output format:
- Show every global check command with raw output.
- Show the discovered `.git` directories.
- Show the list of planned changed files and the repository mapping for each file.
- Show all per-repository check commands with raw output.
- Show all test and policy results per repository.
- On failure in any repository: stop committing in that repository, do not guess, and report exact reasons.
- On success: commit separately per repository and print commit hash, branch, remote, and changed files for each commit.
@@ -1,64 +0,0 @@
# Continue Qt6 migration after broken resume
Setze die Qt6-Migration fort.
## Kontext
Die vorherige Copilot-CLI-Session wurde nach einem `pkill` resumed und ist in einer Endlosschleife hängen geblieben. Sie hat wiederholt nur den Arbeitsstand gelesen/zusammengefasst und nicht weiter implementiert. Dieses Verhalten darf sich nicht wiederholen.
Ein partieller Zwischenstand ist in `./MIGRATION_STATUS.md` gesichert.
Unter `./.github/prompts/` liegen bestehende Prompt-Dateien, die die ursprüngliche Migrationsaufgabe beschreiben. Diese Arbeit ist bereits in Bearbeitung und soll fortgesetzt, nicht neu aufgesetzt werden.
## Verzeichnisrollen
- `./qt-migration-legatus/qt6-after/qt6-migrated-legatus/`
- primärer Arbeitsort
- hier werden die Migrationsergebnisse umgesetzt
- `./qt-migration-legatus/qt5-before/qt5-legatus-legacy/`
- **read-only**
- nur als Referenz für Vergleich, Verhalten und Portierung nutzen
- **keine Änderungen**
- `./external/`
- externe Abhängigkeiten
- nur anfassen, wenn es für einen echten Qt6-Build-/Compile-Blocker zwingend nötig ist
## Strikte Arbeitsregeln
1. `./MIGRATION_STATUS.md` genau einmal am Anfang lesen.
2. Die Prompt-Dateien unter `./.github/prompts/` genau einmal als Kontext lesen.
3. Danach den tatsächlichen Codezustand prüfen.
4. Nicht in erneute Statusanalyse oder Wiederholungszusammenfassungen verfallen.
5. Nicht mehrfach dieselben Statusdateien oder Prompts lesen.
6. Der aktuelle Codezustand hat Vorrang vor älteren Notizen.
7. Wenn Notizen und Code voneinander abweichen, dem Code folgen.
8. `./MIGRATION_STATUS.md` nur am Ende aktualisieren.
## Verpflichtende Arbeitsreihenfolge
1. `./MIGRATION_STATUS.md` einmal lesen
2. die vorhandenen Prompts einmal lesen
3. den Ist-Zustand in `./qt-migration-legatus/qt6-after/qt6-migrated-legatus/` prüfen
4. die nächsten 1-3 konkreten Qt6-Migrationsprobleme identifizieren
5. diese Probleme direkt im Code beheben
6. bei Bedarf gezielt mit `./qt-migration-legatus/qt5-before/qt5-legatus-legacy/` vergleichen
7. `./external/` nur bei echtem Blocker prüfen
8. am Ende `./MIGRATION_STATUS.md` aktualisieren
## Was nicht passieren darf
- keine Endlosschleife aus Lesen und Zusammenfassen
- keine lange Bestandsaufnahme
- kein reines Re-Planning ohne Codeänderungen
- keine Änderungen im Read-only-Referenzbaum
- keine unnötigen Änderungen unter `./external/`
## Priorität
1. Build-/Compile-Blocker im Zielcode beheben
2. veraltete Qt5-APIs im Zielcode auf Qt6 umstellen
3. Signal/Slot-, Header-, Modul- und CMake-Anpassungen umsetzen
4. danach Statusdatei aktualisieren
## Ausgabeformat
Nach jeder relevanten Änderung kurz ausgeben:
- Geändert:
- Grund:
- Nächster Schritt:
## Ziel
Nicht den Stand verwalten, sondern die Qt6-Migration konkret in `./qt-migration-legatus/qt6-after/qt6-migrated-legatus/` weiter implementieren.
@@ -1,198 +0,0 @@
You are working on a migration from RTI Connext 6 to RTI 7.7.
IMPORTANT:
Work in two strictly separated phases:
1. Analysis
2. Patching
Do not modify files before you have completed the analysis and written down a migration classification.
Your task is to compare:
- step-1 Copilot-created fallback/reconstructed RTI-related files created while `BUILD_RTI=OFF`
with
- real RTI 7.7 generated DDS/RTI artifacts created while `BUILD_RTI=ON`
Then update only the manually maintained / Copilot-created files so they correctly reflect the RTI 7.7 generated output.
## Main Goal
Make the codebase cleanly support the real RTI 7.7 generation in the `BUILD_RTI=ON` path, while preserving `BUILD_RTI=OFF` fallbacks only where truly necessary.
## Hard Rules
- Treat RTI 7.7 generated files as source of truth for `BUILD_RTI=ON`.
- Do not edit generated RTI files unless absolutely unavoidable and explicitly justified.
- Prefer adapting manual files, wrappers, compatibility headers, includes, and guards.
- Remove or isolate reconstructed definitions if they duplicate RTI 7.7 generated types.
- Keep fallback logic only for `BUILD_RTI=OFF`.
- Do not perform unrelated refactoring.
- Do not guess generated API shapes; inspect actual generated files.
## Required Workflow
# Phase 1 — Analysis only
## A. Identify migration-related files
Find:
- reconstructed RTI headers
- compiler guards added in step 1
- fallback DDS/RTI type definitions
- wrappers/adapters around DDS/RTI types
- include indirection layers
- files conditionally compiled for `BUILD_RTI`
Use repository inspection commands such as:
- `git status`
- `git diff --name-only`
- `git log --stat`
- `rg -n "BUILD_RTI|RTI|DDS|Connext|ifdef|ifndef|pragma once" .`
- `rg -n "#if.*BUILD_RTI|#ifdef.*BUILD_RTI|#ifndef.*BUILD_RTI" .`
- `find . -iname "*dds*" -o -iname "*rti*"`
If available, inspect step-1-related changes via:
- `git diff <baseline>...HEAD`
- `git log --grep="RTI\|DDS\|BUILD_RTI"`
- targeted diffs for migration commits
## B. Identify real RTI 7.7 generated artifacts
Locate the generated files produced with `BUILD_RTI=ON`.
Inspect:
- build directories
- generated include folders
- CMake-generated outputs
- RTI codegen output directories
- custom generation scripts
Use commands such as:
- `find build -type f | rg "dds|rti|idl|type|Support|Plugin"`
- `find . -type f | rg "Support\.h$|Plugin\.h$|Plugin\.cxx$|\.idl|\.xml"`
- `rg -n "rtiddsgen|connext|idl" CMakeLists.txt cmake/ .`
- `rg -n "GENERATED|AUTO_GENERATED|DO NOT EDIT" .`
## C. Compare reconstructed vs generated artifacts
For each reconstructed/manual RTI-related file, compare against the generated RTI 7.7 counterpart.
Check:
- file names
- include paths
- header guards / `#pragma once`
- macros
- namespaces
- class / struct / enum / typedef / alias definitions
- forward declarations
- helper APIs / traits / adapters
- symbol names
- expected include order
- conditional compilation behavior under `BUILD_RTI=ON` vs `BUILD_RTI=OFF`
Use comparison commands where helpful:
- `diff -u <manual-file> <generated-file>`
- `git diff --no-index <manual-file> <generated-file>`
- `rg -n "<TypeName>" .`
- `rg -n "#include <...>|#include \"...\"" <relevant paths>`
## D. Trace usage
Find all places that still reference the reconstructed step-1 artifacts.
Use:
- `rg -n "<header-name>|<type-name>|<guard-name>" .`
- `rg -n "#include .*<reconstructed-header>|#include .*\"<reconstructed-header>\"" .`
Determine:
- which files still depend on old reconstructed headers
- which guards still activate old fallback definitions
- which paths could conflict with generated RTI 7.7 types
## E. Build-path analysis
Inspect build logic and conditional compilation paths.
Check:
- `CMakeLists.txt`
- `*.cmake`
- generation scripts
- target include directories
- compile definitions
- `compile_commands.json` if present
Use:
- `rg -n "BUILD_RTI|target_include_directories|target_compile_definitions|add_definitions|include_directories" .`
- `find build -name compile_commands.json`
- inspect compile commands for affected targets
Goal:
Determine exactly how `BUILD_RTI=ON` and `BUILD_RTI=OFF` select different headers and definitions.
## F. Produce migration classification
Before patching, classify findings into:
- **REMOVE** = obsolete step-1 artifact replaced by RTI 7.7 generation
- **KEEP_OFF_ONLY** = still needed only when `BUILD_RTI=OFF`
- **PATCH** = manual file must be changed
- **VERIFY** = uncertain; validate before touching
Do not patch before this list is explicit.
# Phase 2 — Patching only after analysis
## Allowed patch types
- replace old includes with RTI 7.7 generated includes
- restrict fallback type definitions to `BUILD_RTI=OFF`
- tighten or invert guards so `BUILD_RTI=ON` always prefers generated output
- remove duplicate type declarations
- update wrappers/adapters to use actual RTI 7.7 generated types
- isolate obsolete reconstructed headers so they no longer affect `BUILD_RTI=ON`
- adjust build include paths only if necessary to stop wrong header selection
## Patch objectives
- `BUILD_RTI=ON` uses actual RTI 7.7 generated headers/types
- no old fallback header shadows generated output
- no duplicate definitions remain
- no stale RTI Connext 6 assumptions remain where RTI 7.7 differs
- `BUILD_RTI=OFF` stays supported only where explicitly needed
## Explicitly avoid
- editing generated files first
- broad renames
- non-migration-related cleanup
- speculative API rewrites
- silently dropping `BUILD_RTI=OFF` support
# Verification after patching
Run or propose the most relevant checks:
- `rg -n "<obsolete-header-or-type>" .`
- `rg -n "redefinition|redeclaration" <build logs if available>`
- project build with `BUILD_RTI=ON`
- if supported, project build with `BUILD_RTI=OFF`
- inspect compiler errors for include-order or duplicate-type issues
If build commands are available, use them. Typical examples:
- `cmake -S . -B build -DBUILD_RTI=ON`
- `cmake --build build -j`
- `cmake -S . -B build-off -DBUILD_RTI=OFF`
- `cmake --build build-off -j`
If tests exist and are relevant, run targeted tests only after the migration patches are in place.
## Output Format
First output:
1. **Analysis summary**
2. **Migration classification**
- REMOVE
- KEEP_OFF_ONLY
- PATCH
- VERIFY
Then patch files only after the analysis is complete.
For every changed file, report and write to ./RTI_MIGRATION_STATUS.md:
1. file path
2. category
3. problem found
4. exact change made
5. rationale
6. follow-up validation / residual risk
When uncertain, prefer minimal safe changes and document the uncertainty.
Start now with Phase 1 only.
Do not patch anything until the analysis and classification are complete.
-1
View File
@@ -1 +0,0 @@
.github/prompts/commit-policy.prompt.md
Submodule external/grantlee-src deleted from 20d415b56d.
-163
View File
@@ -1,163 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_ABSTRACTLOCALIZER_H
#define GRANTLEE_ABSTRACTLOCALIZER_H
#include "grantlee_templates_export.h"
#include <QtCore/QLocale>
#include <QtCore/QSharedPointer>
#include <QtCore/QVariantList>
class QDateTime;
namespace Grantlee
{
/**
@brief Interface for implementing an internationalization system.
This class defines an interface for accessing an internationalization, such as
QLocale/QTranslator or gettext/KLocale.
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT AbstractLocalizer
{
public:
/**
Constructor
*/
AbstractLocalizer();
/**
Destructor
*/
virtual ~AbstractLocalizer();
/**
Processes the data in @p variant into a localized string.
The base implementation can localize numbers, dates and times, and
strings.
*/
virtual QString localize(const QVariant &variant) const;
/**
Returns the current locale as a string.
*/
virtual QString currentLocale() const = 0;
/**
Makes this localizer use the locale specified by @p localeName for output.
*/
virtual void pushLocale(const QString &localeName) = 0;
/**
Makes this localizer use the previous locale for output.
*/
virtual void popLocale() = 0;
/**
Loads the @p catalog from @p path.
*/
virtual void loadCatalog(const QString &path, const QString &catalog) = 0;
/**
Unloads the @p catalog
*/
virtual void unloadCatalog(const QString &catalog) = 0;
/**
Localizes @p number
*/
virtual QString localizeNumber(int number) const = 0;
/**
Localizes @p number
*/
virtual QString localizeNumber(qreal number) const = 0;
/**
Localizes @p value as a monetary value in the currency specified by @p
currencyCode.
*/
virtual QString localizeMonetaryValue(qreal value, const QString &currencyCode
= {}) const = 0;
/**
Localizes @p date with the specified @p formatType
*/
virtual QString localizeDate(const QDate &date,
QLocale::FormatType formatType
= QLocale::ShortFormat) const = 0;
/**
Localizes @p time with the specified @p formatType
*/
virtual QString localizeTime(const QTime &time,
QLocale::FormatType formatType
= QLocale::ShortFormat) const = 0;
/**
Localizes @p dateTime with the specified @p formatType
*/
virtual QString localizeDateTime(const QDateTime &dateTime,
QLocale::FormatType formatType
= QLocale::ShortFormat) const = 0;
/**
Localizes @p string with the specified @p arguments for substitution
*/
virtual QString localizeString(const QString &string,
const QVariantList &arguments = {}) const = 0;
/**
Localizes @p string, disambiguated by @p context with the specified @p
arguments for substitution
*/
virtual QString
localizeContextString(const QString &string, const QString &context,
const QVariantList &arguments = {}) const = 0;
/**
Localizes @p string or its @p pluralForm with the specified @p arguments
for substitution
*/
virtual QString
localizePluralString(const QString &string, const QString &pluralForm,
const QVariantList &arguments = {}) const = 0;
/**
Localizes @p string or its @p pluralForm, disambiguated by @p context with
the specified @p arguments for substitution
*/
virtual QString
localizePluralContextString(const QString &string, const QString &pluralForm,
const QString &context,
const QVariantList &arguments = {}) const = 0;
private:
Q_DISABLE_COPY(AbstractLocalizer)
};
}
#endif
@@ -1,273 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2008,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_ABSTRACTMARKUPBUILDER_H
#define GRANTLEE_ABSTRACTMARKUPBUILDER_H
#include "grantlee_textdocument_export.h"
#include <QtCore/QString>
#include <QtGui/QTextListFormat>
class QBrush;
namespace Grantlee
{
class AbstractMarkupBuilderPrivate;
/// @headerfile abstractmarkupbuilder.h grantlee/abstractmarkupbuilder.h
/**
@brief Interface for creating marked-up text output.
The **%AbstractMarkupBuilder** is used by a MarkupDirector to create marked-up
output such as html or markdown.
See PlainTextMarkupBuilder and TextHTMLBuilder for example implementations.
This interface can be extended to handle custom format types in a
QTextDocument. @see @ref custom_qtextobject
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEXTDOCUMENT_EXPORT AbstractMarkupBuilder
{
public:
/** Destructor */
virtual ~AbstractMarkupBuilder() {}
/** Begin a bold element in the markup */
virtual void beginStrong() = 0;
/** Close the bold element in the markup */
virtual void endStrong() = 0;
/** Begin an emphasised element in the markup */
virtual void beginEmph() = 0;
/** Close the emphasised element in the markup */
virtual void endEmph() = 0;
/** Begin an underlined element in the markup */
virtual void beginUnderline() = 0;
/** Close the underlined element in the markup */
virtual void endUnderline() = 0;
/** Begin a struck out element in the markup */
virtual void beginStrikeout() = 0;
/** Close the struck out element in the markup */
virtual void endStrikeout() = 0;
/**
Begin a decorarated foreground element in the markup (A text color)
using @p brush
*/
virtual void beginForeground(const QBrush &brush) = 0;
/** Close the decorarated foreground element in the markup */
virtual void endForeground() = 0;
/**
Begin a decorarated background element in the markup (A text background
color) using @p brush
*/
virtual void beginBackground(const QBrush &brush) = 0;
/** Close the decorarated background element in the markup */
virtual void endBackground() = 0;
/**
Begin a url anchor element in the markup
@param href The href of the anchor.
@param name The name of the anchor.
*/
virtual void beginAnchor(const QString &href = {}, const QString &name = {})
= 0;
/** Close the anchor element */
virtual void endAnchor() = 0;
/**
Begin a new font familiy element in the markup
@param family The name of the font family to begin.
*/
virtual void beginFontFamily(const QString &family) = 0;
/** End font family element */
virtual void endFontFamily() = 0;
/**
Begin a new font point size element in the markup
@param size The point size to begin.
*/
virtual void beginFontPointSize(int size) = 0;
/** End font point size element */
virtual void endFontPointSize() = 0;
/**
Begin a new paragraph in the markup
@param a The alignment of the new paragraph.
@param top The top margin of the new paragraph.
@param bottom The bottom margin of the new paragraph.
@param left The left margin of the new paragraph.
@param right The right margin of the new paragraph.
*/
virtual void beginParagraph(Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0,
qreal bottom = 0.0, qreal left = 0.0,
qreal right = 0.0)
= 0;
/** Close the paragraph in the markup. */
virtual void endParagraph() = 0;
/** Add a newline to the markup. */
virtual void addNewline() = 0;
/**
Insert a horizontal rule into the markup.
@param width The width of the rule. Default is full width.
*/
virtual void insertHorizontalRule(int width = -1) = 0;
/**
Insert a new image element into the markup.
@param url The url of the image
@param width The width of the image
@param height The height of the image.
*/
virtual void insertImage(const QString &url, qreal width, qreal height) = 0;
/**
Begin a new list element in the markup.
A list element contains list items, and may contain other lists.
@param style The style of list to create.
*/
virtual void beginList(QTextListFormat::Style style) = 0;
/**
Close the list.
*/
virtual void endList() = 0;
/** Begin a new list item in the markup */
virtual void beginListItem() = 0;
/** End the list item */
virtual void endListItem() = 0;
/** Begin a superscript element */
virtual void beginSuperscript() = 0;
/** End superscript element */
virtual void endSuperscript() = 0;
/** Begin a subscript element */
virtual void beginSubscript() = 0;
/** End subscript element */
virtual void endSubscript() = 0;
/**
Begin a table element.
@param cellpadding The padding attribute for the table.
@param cellspacing The spacing attribute for the table.
@param width The width of the table. May be either an integer, or a
percentage value.
*/
virtual void beginTable(qreal cellpadding, qreal cellspacing,
const QString &width)
= 0;
/**
Begin a new table row
*/
virtual void beginTableRow() = 0;
/**
Begin a new table header cell.
@param width The width of the cell.
@param colSpan The column span of the cell.
@param rowSpan The row span of the cell.
*/
virtual void beginTableHeaderCell(const QString &width, int colSpan,
int rowSpan)
= 0;
/**
Begin a new table cell.
@param width The width of the cell.
@param colSpan The column span of the cell.
@param rowSpan The row span of the cell.
*/
virtual void beginTableCell(const QString &width, int colSpan, int rowSpan)
= 0;
/** End a table element */
virtual void endTable() = 0;
/** End a table row */
virtual void endTableRow() = 0;
/** End a table header cell */
virtual void endTableHeaderCell() = 0;
/** End a table cell */
virtual void endTableCell() = 0;
/**
Begin a level @p level header
@param level An integer between 1 and 6
*/
virtual void beginHeader(int level) = 0;
/**
End a level @p level header
@param level An integer between 1 and 6
*/
virtual void endHeader(int level) = 0;
/**
Append the plain text @p text to the markup
@param text The text to append.
*/
virtual void appendLiteralText(const QString &text) = 0;
/**
Append the raw text @p text to the markup. @p text is added unescaped
*/
virtual void appendRawText(const QString &text) = 0;
/**
Return the fully marked up result of the building process.
This may contain metadata etc, such as a head element in html.
@return The fully marked up text.
*/
virtual QString getResult() = 0;
};
}
#endif
-113
View File
@@ -1,113 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_BBCODEBUILDER_H
#define GRANTLEE_BBCODEBUILDER_H
#include "abstractmarkupbuilder.h"
namespace Grantlee
{
/**
@brief Builder to create BBCode from a QTextDocument
*/
class BBCodeBuilder : public AbstractMarkupBuilder
{
public:
/**
Creates a new BBCodeBuilder.
*/
BBCodeBuilder();
~BBCodeBuilder() override;
void beginStrong() override;
void endStrong() override;
void beginEmph() override;
void endEmph() override;
void beginUnderline() override;
void endUnderline() override;
void beginStrikeout() override;
void endStrikeout() override;
void beginForeground(const QBrush &brush) override;
void endForeground() override;
// Background colour not supported by BBCode.
void beginAnchor(const QString &href = {}, const QString &name = {}) override;
void endAnchor() override;
// Font family not supported by BBCode.
/**
Begin an element of font size @p size. Note that this size is in pixels,
and must be converted before it is suitable for use in BBCode.
@param size The size of font to begin.
*/
void beginFontPointSize(int size) override;
void endFontPointSize() override;
void beginParagraph(Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0,
qreal bottom = 0.0, qreal left = 0.0,
qreal right = 0.0) override;
void endParagraph() override;
void addNewline() override;
void insertImage(const QString &src, qreal width, qreal height) override;
void beginList(QTextListFormat::Style type) override;
void endList() override;
void beginListItem() override;
void beginSuperscript() override;
void endSuperscript() override;
void beginSubscript() override;
void endSubscript() override;
void beginTable(qreal, qreal, const QString &) override;
void beginTableRow() override;
void appendLiteralText(const QString &text) override;
/**
Escapes @p text appropriately for BBCode.
*/
const QString escape(const QString &text) const;
QString getResult() override;
private:
QList<QTextListFormat::Style> m_currentListItemStyles;
QString m_text;
Qt::Alignment m_currentAlignment;
};
}
#endif
@@ -1,112 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_CACHINGLOADERDECORATOR_H
#define GRANTLEE_CACHINGLOADERDECORATOR_H
#include "templateloader.h"
#include "grantlee_templates_export.h"
namespace Grantlee
{
class CachingLoaderDecoratorPrivate;
/// @headerfile cachingloaderdecorator.h grantlee/cachingloaderdecorator.h
/**
@brief Implements a loader decorator which caches compiled Template objects.
The **%CachingLoaderDecorator** can be used with any implementation of
Grantlee::AbstractTemplateLoader.
@code
auto loader = QSharedPointer<Grantlee::FileSystemTemplateLoader>::create();
loader->setTemplateDirs({"/path/one", "/path/two"});
auto cache =
QSharedPointer<Grantlee::CachingLoaderDecorator>::create( loader );
m_engine->addTemplateLoader( cache );
@endcode
The effect is that templates do not need to be loaded from the filesystem and
compiled into Template objects on each access, but may be returned from the
cache instead.
This can be significant if loading Templates in a loop, or loading the same
Template very often in an application.
@code
<ul>
{% for item in list %}
<li>{% include "itemtemplate.html" %}</li>
{% endfor %}
</ul>
@endcode
If the loading of Templates is a bottleneck in an application, it may make
sense to use the caching decorator.
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT CachingLoaderDecorator
: public AbstractTemplateLoader
{
public:
/**
Constructor
*/
CachingLoaderDecorator(QSharedPointer<AbstractTemplateLoader> loader);
/**
Destructor
*/
~CachingLoaderDecorator() override;
bool canLoadTemplate(const QString &name) const override;
QPair<QString, QString> getMediaUri(const QString &fileName) const override;
Template loadByName(const QString &name,
const Grantlee::Engine *engine) const override;
/**
Clears the Templates objects cached in the decorator.
*/
void clear();
/**
Returns the number of Template objects cached in the decorator.
*/
int size() const;
/**
Returns whether the cache is empty.
*/
bool isEmpty() const;
private:
Q_DECLARE_PRIVATE(CachingLoaderDecorator)
CachingLoaderDecoratorPrivate *const d_ptr;
};
}
#endif
-283
View File
@@ -1,283 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_CONTEXT_H
#define GRANTLEE_CONTEXT_H
#include "abstractlocalizer.h"
#include "grantlee_templates_export.h"
#include <QtCore/QVariantHash>
namespace Grantlee
{
class RenderContext;
class ContextPrivate;
/// @headerfile context.h grantlee/context.h
/**
@brief The **%Context** class holds the context to render a Template with.
For application developers, using the **%Context** class is a matter of
inserting keys and values as appropriate for rendering a Template using the
@ref insert method.
@code
auto t = engine->newTemplate(
"Name is {% name %} and age is {% age %}.", "some_template" );
Context c1;
c1.insert( "name", "Tom" );
c1.insert( "age", 34 );
Context c2;
c2.insert( "name", "Harry" );
c2.insert( "age", 43 );
t->render(c1); // Returns "Name is Tom and age is 43."
t->render(c2); // Returns "Name is Harry and age is 34."
@endcode
Note that one Template may be rendered multiple times with different contexts.
Note also that any QVariant may be inserted into a **%Context** object. Most
commonly, QObjects will be used here.
@see @ref custom_objects
@section context_stack Context Stack.
For template tag developers, some other **%Context** API is relevant.
It is possible to @ref push and @ref pop layers of context while a template
is being rendered. This is useful if your template tag makes additional
variables temporarily available in a part of a template. %Template tags
should only modify layers of context that they @ref push themselves, and
should @ref pop any layers created before finishing its rendering step.
See for example the @gr_tag{with} tag. In a template such as
@code
Some content
{% with person.name|toUpper as lowerName %}
Name is {% lowerName %}
{% endwith %}
@endcode
In this case, lowerName is available in the context only between the
@gr_tag{with} and @gr_tag{endwith} tags. The implementation of
the @gr_tag{with} tag render method is:
@code
void WithNode::render( OutputStream *stream, Context *c ) const
{
c->push();
// {% with m_filterExpression as m_name %}
c->insert( m_name, m_filterExpression.resolve( c ) );
m_list.render( stream, c );
c->pop(); // The section of context defining m_name is removed.
}
@endcode
Note that a **%Context** may temporarily override a variable in a parent
context. This is why it is important to @ref push a new context when adding
items to context and @ref pop it when finished.
@code
Some content
{% with "foo" as var %}
Var is {% var %} // Var is "foo"
{% with "bar" as var %}
Var is {% var %} // Var is "bar"
{% endwith %}
Var is {% var %} // Var is "foo"
{% endwith %}
@endcode
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT Context
{
public:
/**
Creates an empty context
*/
Context();
/**
Sets every key in the hash as a property name with the variant as the
value.
*/
explicit Context(const QVariantHash &hash);
/**
Copy Constructor
*/
Context(const Context &other);
/**
Assignmant operator
*/
Context &operator=(const Context &other);
#ifndef Q_QDOC
/**
@internal
Whether to automatically escape all context content. This is not usually
used directly. Use the @gr_tag{autoescape} tag instead.
*/
bool autoEscape() const;
/**
@internal
Sets whether to automatically escape all context content. This is not
usually used directly. Use the @gr_tag{autoescape} tag instead.
*/
void setAutoEscape(bool autoescape);
#endif
/**
Destructor
*/
~Context();
/**
Returns the context object identified by the key @p str
*/
QVariant lookup(const QString &str) const;
/**
Insert the context object @p object identified by @p name into
the **%Context**.
*/
void insert(const QString &name, QObject *object);
/**
Insert the context object @p variant identified by @p name into
the **%Context**.
*/
void insert(const QString &name, const QVariant &variant);
/**
Pushes a new context.
@see @ref context_stack
*/
void push();
/**
Pops the context.
@see @ref context_stack
*/
void pop();
#ifndef Q_QDOC
/**
@internal Returns the context hash at depth @p depth.
*/
QVariantHash stackHash(int depth) const;
/**
@internal
Returns whether template being rendered is being mutated.
*/
bool isMutating() const;
/**
@internal
Sets whether template being rendered is being mutated to @p mutating.
*/
void setMutating(bool mutating);
/**
@internal
*/
void addExternalMedia(const QString &absolutePart,
const QString &relativePart);
/**
@internal
*/
void clearExternalMedia();
#endif
/**
Sets the @p localizer to be used.
The **%Context** takes ownerwhip of the localizer.
*/
void setLocalizer(QSharedPointer<AbstractLocalizer> localizer);
/**
Returns the localizer currently in use.
*/
QSharedPointer<AbstractLocalizer> localizer() const;
/**
Returns the external media encountered in the Template while rendering.
*/
QList<QPair<QString, QString>> externalMedia() const;
/**
The type of urls to external media that should be put in the template.
*/
enum UrlType {
AbsoluteUrls, ///< Absolute URLs should be put in the template.
RelativeUrls ///< Relative URLs should be put in the template.
};
/**
Sets the type of external media URL to be used in the template to @p type.
@see @ref media_finder_tag
*/
void setUrlType(UrlType type);
/**
The type of URL used in the template.
*/
UrlType urlType() const;
/**
Sets the relative path to external media to be used in templates to @p
relativePath
@see @ref media_finder_tag
*/
void setRelativeMediaPath(const QString &relativePath);
/**
The relative path to external media to be used in templates.
*/
QString relativeMediaPath() const;
/**
Returns a modifiable RenderContext. This may be used to make
Template rendering threadsafe so that render state does not need to be
stored in the Node implementation itself.
*/
RenderContext *renderContext() const;
private:
Q_DECLARE_PRIVATE(Context)
ContextPrivate *const d_ptr;
};
}
#endif
-259
View File
@@ -1,259 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_ENGINE_H
#define GRANTLEE_ENGINE_H
#include "template.h"
#include "templateloader.h"
namespace Grantlee
{
class TagLibraryInterface;
class EnginePrivate;
/// @headerfile engine.h grantlee/engine.h
/**
@brief **%Grantlee::Engine** is the main entry point for creating %Grantlee
Templates.
The **%Grantlee::Engine** is responsible for configuring and creating Template
objects. In typical use, one or more AbstractTemplateLoader objects will be
added to the Engine to load template objects, and plugin directories will be
set to enable finding template tags and filters.
@code
auto engine = new Engine();
auto loader = QSharedPointer<FileSystemTemplateLoader>::create();
loader->setTemplateDirs( {"/usr/share/myapp/templates"} );
engine->addTemplateLoader( loader );
engine->addPluginPath( "/usr/lib/myapp" );
auto template1 = engine->newTemplate( "Template content", "template name" );
auto template2 = engine->loadByName( "templatefile.html" );
@endcode
Once it is configured, the **%Engine** can be used to create new templates by
name by loading the templates with the @ref loadByName method, or by defining
the content in the @ref newTemplate method.
By default the builtin tags and filters distributed with %Grantlee are
available in all templates without using the @gr_tag{load} tag in the
template. These pre-loaded libraries may be configured if appropriate to the
application. For example, an application which defines its own tags and
filters may want them to be always available, or it may be desirable to
restrict the features available to template authors by removing built in
libraries.
Different **%Engine** objects can be used to create templates with differing
configurations.
@section smart_trim Insignificant whitespace
The output of rendering a template depends on the content of the template. In
some cases when generating content in which whitespace is significant, this
can have undesired effects. For example, given a template to generate C++ code
like:
@verbatim
class MyClass {
{# This loop creates the #}
{# methods in the class #}
{% for method in methods %}
{% if method.hasDox %}
{{ method.dox }}
{% endif %}
{{ method.signature }}
{% endfor %}
};
@endverbatim
The output would have a lot of whitespace which is not necessarily wanted.
@code
class MyClass {
void foo() const;
};
@endcode
It is possible to strip insignificant whitespace by enabling the smartTrim
feature with @ref setSmartTrimEnabled. When enabled the output will not
contain a newline for any line in the template which has only one token of
template syntax, such as a comment, tag or variable.
@code
class MyClass {
void foo() const;
};
@endcode
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT Engine : public QObject
{
Q_OBJECT
public:
/**
Constructor
*/
Engine(QObject *parent = {});
/**
Destructor.
*/
~Engine() override;
/**
Returns the TemplateLoaders currently configured on the **%Engine**.
*/
QList<QSharedPointer<AbstractTemplateLoader>> templateLoaders();
/**
Adds @p loader to the TemplateLoaders currently configured on
the **%Engine**.
*/
void addTemplateLoader(QSharedPointer<AbstractTemplateLoader> loader);
/**
Sets the plugin dirs currently configured on the **%Engine** to @p dirs.
@warning This overwrites the default paths. You normally want
@ref addPluginPath.
@see @ref finding_plugins
*/
void setPluginPaths(const QStringList &dirs);
/**
Prepend @p dir to the list of plugin dirs.
*/
void addPluginPath(const QString &dir);
/**
Removes all instances of @p dir from the list of plugin dirs.
*/
void removePluginPath(const QString &dir);
/**
Returns the currently configured plugin dirs
*/
QStringList pluginPaths() const;
/**
Returns a URI for a media item with the name @p name.
Typically this will be used for images. For example the media URI for the
image <tt>"header_logo.png"</tt> may be
<tt>"/home/user/common/header_logo.png"</tt> or
<tt>"/home/user/some_theme/header_logo.png"</tt>
depending on the @ref templateLoaders configured.
This method will not usually be called by application code. To load media
in a template, use the @gr_tag{media_finder} template tag.
*/
QPair<QString, QString> mediaUri(const QString &fileName) const;
/**
Load the Template identified by @p name.
The Templates and plugins loaded will be determined by
the **%Engine** configuration.
*/
Template loadByName(const QString &name) const;
/**
Create a new Template with the content @p content identified by @p name.
The secondary Templates and plugins loaded will be determined by
the **%Engine** configuration.
*/
Template newTemplate(const QString &content, const QString &name) const;
/**
Returns the libraries available by default to new Templates.
*/
QStringList defaultLibraries() const;
/**
Adds the library named @p libName to the libraries available by default to
new Templates.
*/
void addDefaultLibrary(const QString &libName);
/**
Removes the library named @p libName from the libraries available by
default to new Templates.
*/
void removeDefaultLibrary(const QString &libName);
/**
Returns whether the smart trim feature is enabled for newly loaded
templates.
@see smart_trim
This is false by default.
*/
bool smartTrimEnabled() const;
/**
Sets whether the smart trim feature is enabled for newly loaded templates.
@see smart_trim
*/
void setSmartTrimEnabled(bool enabled);
#ifndef Q_QDOC
/**
@internal
Loads and returns the libraries specified in defaultLibraries or @p state.
*/
void loadDefaultLibraries();
/**
@internal
Loads and returns the library specified by @p name in the
current **%Engine** configuration or @p state.
Templates wishing to load a library should use the @gr_tag{load} tag.
*/
TagLibraryInterface *loadLibrary(const QString &name);
#endif
private:
Q_DECLARE_PRIVATE(Engine)
EnginePrivate *const d_ptr;
};
}
#endif
-120
View File
@@ -1,120 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_EXCEPTION_H
#define GRANTLEE_EXCEPTION_H
#include "grantlee_templates_export.h"
#include <QtCore/QString>
#include <exception>
namespace Grantlee
{
/**
Types of errors that can occur while using %Grantlee
*/
enum Error {
NoError,
EmptyVariableError,
EmptyBlockTagError,
InvalidBlockTagError,
UnclosedBlockTagError,
UnknownFilterError,
TagSyntaxError,
// VariableSyntaxError,
VariableNotInContext,
ObjectReturnTypeInvalid,
CompileFunctionError
};
/// @headerfile exception.h grantlee/exception.h
/**
@brief An exception for use when implementing template tags.
The **%Exception** class can be used when implementing
AbstractNodeFactory::getNode. An exception can be thrown to indicate that
the syntax of a particular tag is invalid.
For example, the following template markup should throw an error because the
include tag should have exactly one argument:
@code
<div>
{% include %}
</div>
@endcode
The corresponding implementation of IncludeNodeFactory::getNode is
@code
QStringList tagContents = smartSplit( tagContent );
if ( tagContents.size() != 2 )
throw Grantlee::Exception( TagSyntaxError,
"Error: Include tag takes exactly one argument" );
// The item at index 0 in the list is the tag name, "include"
QString includeName = tagContents.at( 1 );
@endcode
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT Exception
{
public:
/**
Creates an exception for the error @p errorCode and the verbose
message @p what
*/
Exception(Error errorCode, const QString &what)
: m_errorCode(errorCode), m_what(what)
{
}
virtual ~Exception() throw() {}
#ifndef Q_QDOC
/**
@internal
Returns the verbose message for the exception.
*/
const QString what() const throw() { return m_what; }
/**
@internal
Returns the error code for the exception.
*/
Error errorCode() const { return m_errorCode; }
#endif
private:
Error m_errorCode;
QString m_what;
};
}
#endif
-117
View File
@@ -1,117 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
// krazy:excludeall=dpointer
#ifndef GRANTLEE_FILTER_H
#define GRANTLEE_FILTER_H
#include "grantlee_templates_export.h"
#include "outputstream.h"
#include "safestring.h"
#include <QtCore/QSharedPointer>
#include <QtCore/QStringList>
#include <QtCore/QVariant>
namespace Grantlee
{
/// @headerfile filter.h grantlee/filter.h
/**
@brief Base class for all filters.
The **%Filter** class can be implemented in plugin libraries to make
additional functionality available to templates.
Developers are required only to implement the @ref doFilter method and
integrate the filter as part of a custom plugin, but will never create or
access filters directly in application code.
The FilterExpression class is the access interface to a chain of **%Filter**
objects.
The @ref escape and @ref conditionalEscape methods are available for escaping
data where needed.
@see @ref filters
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT Filter
{
public:
/**
Destructor.
*/
virtual ~Filter();
#ifndef Q_QDOC
/**
FilterExpression makes it possible to access stream methods like escape
while resolving.
*/
void setStream(OutputStream *stream);
#endif
/**
Escapes and returns @p input. The OutputStream::escape method is used to
escape @p input.
*/
SafeString escape(const QString &input) const;
/**
Escapes and returns @p input. The OutputStream::escape method is used to
escape @p input.
*/
SafeString escape(const SafeString &input) const;
/**
Escapes @p input if not already safe from further escaping and returns it.
The OutputStream::escape method is used to escape @p input.
*/
SafeString conditionalEscape(const SafeString &input) const;
/**
Reimplement to filter @p input given @p argument.
@p autoescape determines whether the autoescape feature is currently on or
off. Most filters will not use this.
@see @ref autoescaping
*/
virtual QVariant doFilter(const QVariant &input,
const QVariant &argument = {},
bool autoescape = {}) const = 0;
/**
Reimplement to return whether this filter is safe.
*/
virtual bool isSafe() const;
private:
#ifndef Q_QDOC
OutputStream *m_stream;
#endif
};
}
#endif
-200
View File
@@ -1,200 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_FILTEREXPRESSION_H
#define GRANTLEE_FILTEREXPRESSION_H
#include "variable.h"
#include "grantlee_templates_export.h"
namespace Grantlee
{
class Filter;
class OutputStream;
class Parser;
struct Token;
class FilterExpressionPrivate;
/// @headerfile filterexpression.h grantlee/filterexpression.h
/**
@brief A **%FilterExpression** object represents a filter expression in a
template.
This class is only relevant if implementing custom tags or filters. Most of
the API here is internal.
Usually when implementing tags or filters, filter expressions will just be
created and resolved.
In template markup, a filter expression is a variable followed by one or more
filters separated by pipes:
%Filter expressions may appear in variable nodes:
@code
{{ some_var|upper_filter|lower_filter }}
@endcode
Or as arguments to tags
@code
{% some_tag some_arg1|filter1|filter2 some_arg2|filter3 %}
@endcode
The **%FilterExpression** class would be used in the getNode implementation of
the AbstractNodeFactory implementation for the <tt>some_tag</tt> tag.
@code
Node* SomeTagFactory::getNode(const QString &tagContent, Parser *p) const {
auto parts = smartSplit( tagContent );
parts.removeFirst(); // Remove the "some_tag" part.
FilterExpression arg1( parts.first(), p );
FilterExpression arg2( parts.at( 1 ), p );
return new SomeTagNode( arg1, arg2, p );
}
@endcode
@see AbstractNodeFactory::getFilterExpressionList
When implementing the Node::render method, the @ref resolve method may be used
to process the filter expression.
For example, if our <tt>SomeTagNode</tt> was to concatenate the resolved
values given as arguments:
@code
void SomeTagNode::render( QTextStream *stream, Context *c ) {
m_arg1.resolve( stream, c );
m_arg2.resolve( stream, c );
}
@endcode
Because Filters are highly generic, they do not all write data to the stream.
For example, a Filter might take as input a string, and return a list by
splitting the string on commas, or a Filter might compare an input to its
argument and return whether they are the same, but not write anything to the
stream. For that reason, the @ref resolve method writes data to the given
stream, and returns the same data in its returned QVariant.
The suitability of either of the @ref resolve methods will depend on the
implementation and requirements of your custom tag. For example if the
<tt>SomeTagNode</tt> ran a comparison of the arguments:
@code
void SomeTagNode::render( QTextStream *stream, Context *c ) {
QString first = m_arg1.resolve( c ).toString();
QString second = m_arg2.resolve( c ).toString();
if ( first == second )
m_trueList.render( stream, c );
else
m_falseList.render( stream, c );
}
@endcode
@see @ref tags_with_end_tags
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT FilterExpression
{
public:
/**
Constructs an invalid **%FilterExpression**.
*/
FilterExpression();
/**
Constructs a filter expression from the string @p varString. The Parser @p
parser is used to retrieve filters.
*/
FilterExpression(const QString &varString, Grantlee::Parser *parser);
/**
Copy constructor.
*/
FilterExpression(const FilterExpression &other);
/**
Destructor.
*/
~FilterExpression();
/**
Assignment operator.
*/
FilterExpression &operator=(const FilterExpression &other);
/**
Returns the initial variable in the **%FilterExpression**.
*/
Variable variable() const;
/**
Resolves the **%FilterExpression** in the Context @p c and writes it to the
stream @p stream.
*/
QVariant resolve(OutputStream *stream, Context *c) const;
/**
Resolves the **%FilterExpression** in the Context @p c.
*/
QVariant resolve(Context *c) const;
/**
Returns whether the Filter resolves to true in the Context @p c.
@see @ref truthiness
*/
bool isTrue(Context *c) const;
/**
Returns a list for the **%FilterExpression**.
If the **%FilterExpression** can not be resolved to a list, an empty list
will be returned.
*/
QVariantList toList(Context *c) const;
/**
Returns whether a filter expression is valid.
A **%FilterExpression** is valid if all filters in the expression exist and
the initial variable being filtered is valid.
*/
bool isValid() const;
#ifndef Q_QDOC
/**
@internal
Returns the list of filters in the **%FilterExpression**.
*/
QStringList filters() const;
#endif
private:
Q_DECLARE_PRIVATE(FilterExpression)
FilterExpressionPrivate *const d_ptr;
};
}
#endif
@@ -1,42 +0,0 @@
#ifndef GRANTLEE_TEMPLATES_EXPORT_H
#define GRANTLEE_TEMPLATES_EXPORT_H
#ifdef GRANTLEE_TEMPLATES_STATIC_DEFINE
# define GRANTLEE_TEMPLATES_EXPORT
# define GRANTLEE_TEMPLATES_NO_EXPORT
#else
# ifndef GRANTLEE_TEMPLATES_EXPORT
# ifdef Grantlee_Templates_EXPORTS
/* We are building this library */
# define GRANTLEE_TEMPLATES_EXPORT __attribute__((visibility("default")))
# else
/* We are using this library */
# define GRANTLEE_TEMPLATES_EXPORT __attribute__((visibility("default")))
# endif
# endif
# ifndef GRANTLEE_TEMPLATES_NO_EXPORT
# define GRANTLEE_TEMPLATES_NO_EXPORT __attribute__((visibility("hidden")))
# endif
#endif
#ifndef GRANTLEE_TEMPLATES_DEPRECATED
# define GRANTLEE_TEMPLATES_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef GRANTLEE_TEMPLATES_DEPRECATED_EXPORT
# define GRANTLEE_TEMPLATES_DEPRECATED_EXPORT GRANTLEE_TEMPLATES_EXPORT GRANTLEE_TEMPLATES_DEPRECATED
#endif
#ifndef GRANTLEE_TEMPLATES_DEPRECATED_NO_EXPORT
# define GRANTLEE_TEMPLATES_DEPRECATED_NO_EXPORT GRANTLEE_TEMPLATES_NO_EXPORT GRANTLEE_TEMPLATES_DEPRECATED
#endif
#if 0 /* DEFINE_NO_DEPRECATED */
# ifndef GRANTLEE_TEMPLATES_NO_DEPRECATED
# define GRANTLEE_TEMPLATES_NO_DEPRECATED
# endif
#endif
#endif /* GRANTLEE_TEMPLATES_EXPORT_H */
@@ -1,42 +0,0 @@
#ifndef GRANTLEE_TEXTDOCUMENT_EXPORT_H
#define GRANTLEE_TEXTDOCUMENT_EXPORT_H
#ifdef GRANTLEE_TEXTDOCUMENT_STATIC_DEFINE
# define GRANTLEE_TEXTDOCUMENT_EXPORT
# define GRANTLEE_TEXTDOCUMENT_NO_EXPORT
#else
# ifndef GRANTLEE_TEXTDOCUMENT_EXPORT
# ifdef Grantlee_TextDocument_EXPORTS
/* We are building this library */
# define GRANTLEE_TEXTDOCUMENT_EXPORT __attribute__((visibility("default")))
# else
/* We are using this library */
# define GRANTLEE_TEXTDOCUMENT_EXPORT __attribute__((visibility("default")))
# endif
# endif
# ifndef GRANTLEE_TEXTDOCUMENT_NO_EXPORT
# define GRANTLEE_TEXTDOCUMENT_NO_EXPORT __attribute__((visibility("hidden")))
# endif
#endif
#ifndef GRANTLEE_TEXTDOCUMENT_DEPRECATED
# define GRANTLEE_TEXTDOCUMENT_DEPRECATED __attribute__ ((__deprecated__))
#endif
#ifndef GRANTLEE_TEXTDOCUMENT_DEPRECATED_EXPORT
# define GRANTLEE_TEXTDOCUMENT_DEPRECATED_EXPORT GRANTLEE_TEXTDOCUMENT_EXPORT GRANTLEE_TEXTDOCUMENT_DEPRECATED
#endif
#ifndef GRANTLEE_TEXTDOCUMENT_DEPRECATED_NO_EXPORT
# define GRANTLEE_TEXTDOCUMENT_DEPRECATED_NO_EXPORT GRANTLEE_TEXTDOCUMENT_NO_EXPORT GRANTLEE_TEXTDOCUMENT_DEPRECATED
#endif
#if 0 /* DEFINE_NO_DEPRECATED */
# ifndef GRANTLEE_TEXTDOCUMENT_NO_DEPRECATED
# define GRANTLEE_TEXTDOCUMENT_NO_DEPRECATED
# endif
#endif
#endif /* GRANTLEE_TEXTDOCUMENT_EXPORT_H */
-7
View File
@@ -1,7 +0,0 @@
#define GRANTLEE_VERSION_MAJOR 5
#define GRANTLEE_VERSION_MINOR 3
#define GRANTLEE_VERSION_PATCH 0
#define GRANTLEE_VERSION_STRING "5.3.0"
#define GRANTLEE_VERSION ((5<<16)|(3<<8)|(0))
#define GRANTLEE_MAJOR_MINOR_VERSION_STRING "5.3"
#define GRANTLEE_MIN_PLUGIN_VERSION 0
-306
View File
@@ -1,306 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_MARKUPDIRECTOR_H
#define GRANTLEE_MARKUPDIRECTOR_H
#include "abstractmarkupbuilder.h"
#include "grantlee_textdocument_export.h"
#include <QtGui/QTextDocument>
#include <QtGui/QTextFrame>
class QTextTable;
class QTextTableCell;
class QTextList;
class QTextCharFormat;
namespace Grantlee
{
class MarkupDirectorPrivate;
/// @headerfile markupdirector.h grantlee/markupdirector.h
/**
@brief Instructs a builder object to create markup output
The **%MarkupDirector** is used with an implementation of
AbstractMarkupBuilder to create a marked up document output.
Usage can be quite simple.
@code
auto doc = editor->document(); // editor is a QTextEdit
auto builder = new HTMLBuilder();
auto md = new MarkupDirector(builder);
md->processDocument(doc);
browser->setHtml(builder->getResult()); // browser is a QTextBrowser.
@endcode
Or with a different builder:
@code
auto builder = new PlainTextMarkupBuilder();
auto md = new MarkupDirector(builder);
md->processDocument(doc);
browser->setPlainText(builder->getResult());
@endcode
The **%MarkupDirector** also provides API for processing just part of a
QTextDocument, such as a QTextFrame or a QTextBlock. The appropriate method
may then be called with an invalid iterator as appropriate.
@code
// ... Do some processing to get a QTextFrame.
auto frame = getFrame();
auto builder = new PlainTextMarkupBuilder();
auto md = new MarkupDirector(builder);
// Create output from only the frame.
md->processFrame(QTextFrame::iterator(), frame);
browser->setPlainText(builder->getResult());
@endcode
The behaviour of the **%MarkupDirector** can be customized by subclassing.
Support for custom types can also be added by implementing the @ref
processCustomFragment method.
@see @ref custom_qtextobject
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEXTDOCUMENT_EXPORT MarkupDirector
{
public:
/**
Constructor
*/
MarkupDirector(AbstractMarkupBuilder *builder);
/**
Destructor
*/
virtual ~MarkupDirector();
/**
Constructs the output by directing the builder to create the markup.
*/
virtual void processDocument(QTextDocument *doc);
/**
Directs the builder to create output for the single @p frame. If calling
this method directly, an invalid QTextFrame::iterator may be used.
*/
virtual QTextFrame::iterator processFrame(QTextFrame::iterator it,
QTextFrame *frame);
/**
Directs the builder to create output for the single @p block. If calling
this method directly, an invalid QTextFrame::iterator may be used.
This method does not process the contents of the @p block, but uses the
@ref processBlockContents method to do so.
*/
virtual QTextFrame::iterator processBlock(QTextFrame::iterator it,
const QTextBlock &block);
/**
Directs the builder to create output for the single @p textObject. If
calling this method directly, an invalid QTextFrame::iterator may be used.
The block @p block is the container of the @p textObject.
*/
virtual QTextFrame::iterator processObject(QTextFrame::iterator it,
const QTextBlock &block,
QTextObject *textObject);
/**
Directs the builder to create output for the single @p textBlockGroup. If
calling this method directly, an invalid QTextFrame::iterator may be used.
The block @p block is the first block in the @p textBlockGroup.
*/
virtual QPair<QTextFrame::iterator, QTextBlock>
processBlockGroup(QTextFrame::iterator it, const QTextBlock &block,
QTextBlockGroup *textBlockGroup);
/**
Directs the builder to create output for the single @p textList. If
calling this method directly, an invalid QTextFrame::iterator may be used.
The block @p block is the first block in the @p textList.
*/
virtual QPair<QTextFrame::iterator, QTextBlock>
processList(QTextFrame::iterator it, const QTextBlock &block,
QTextList *textList);
/**
Directs the builder to create output for the contents of the single @p
block. If calling this method directly, an invalid QTextFrame::iterator
may be used.
*/
virtual QTextFrame::iterator processBlockContents(QTextFrame::iterator it,
const QTextBlock &block);
/**
Hook for instructing the builder to create output for the @p fragemnt with
a custom type. @p doc is the document the fragment is in.
*/
virtual void processCustomFragment(const QTextFragment &fragment,
QTextDocument const *doc);
/**
Directs the builder to create output for the contents of the single @p
fragment. If calling this method directly, an invalid QTextBlock::iterator
may be used. @p doc is the document the fragment is in.
*/
virtual QTextBlock::iterator processFragment(QTextBlock::iterator it,
const QTextFragment &fragment,
QTextDocument const *doc);
/**
Directs the builder to create output for the contents of the single @p
textObject. The @p textObject is represented in the QTextDocument with the
QTextFragment @p fragment.
If calling this method directly, an invalid QTextBlock::iterator may be
used.
*/
virtual QTextBlock::iterator
processCharTextObject(QTextBlock::iterator it, const QTextFragment &fragment,
QTextObject *textObject);
/**
Directs the builder to create output for the image represented by the @p
imageFormat.
If calling this method directly, an invalid QTextBlock::iterator may be
used. @p doc is the document the fragment is in.
*/
virtual QTextBlock::iterator processImage(QTextBlock::iterator it,
const QTextImageFormat &imageFormat,
QTextDocument *doc);
/**
Directs the builder to create output for the contents of the single @p
table.
If calling this method directly, an invalid QTextFrame::iterator may be
used.
*/
virtual QTextFrame::iterator processTable(QTextFrame::iterator it,
QTextTable *table);
/**
Directs the builder to create output for the contents of the single @p
tableCell. The tableCell is in the @p table.
*/
virtual void processTableCell(const QTextTableCell &tableCell,
QTextTable *table);
protected:
/**
Processes the document between @p begin and @p end
*/
void processDocumentContents(QTextFrame::iterator begin,
QTextFrame::iterator end);
/**
Iterates the iterator @p it to the first block after @p blockGroup. @p
_block is any block in the @p blockGroup.
The return pair is the iterator pointing after the end of @p blockGroup
and the first block after @p blockGroup.
*/
QPair<QTextFrame::iterator, QTextBlock>
skipBlockGroup(QTextFrame::iterator it, const QTextBlock &_block,
QTextBlockGroup *blockGroup);
/**
Returns a list of tags contained in @p openingTags sorted so they can be
opened in order and will be closed in the correct order.
@p openingTags should be a set of tags opened at the fragment pointed to
by @p it.
*/
QList<int> sortOpeningOrder(QSet<int> openingTags,
QTextBlock::iterator it) const;
/**
Directs the builder to close the appropriate tags at the position of @p
it.
*/
virtual void processClosingElements(QTextBlock::iterator it);
/**
Directs the builder to open the appropriate tags at the position of @p it.
*/
virtual void processOpeningElements(QTextBlock::iterator it);
/**
Returns the tags that should be closed at the position of @p it.
*/
virtual QSet<int> getElementsToClose(QTextBlock::iterator it) const;
/**
Returns the tags that should be opened at the position of @p it.
*/
virtual QList<int> getElementsToOpen(QTextBlock::iterator it);
/**
Flags for the tags that may be open.
*/
enum OpenElementValues {
None = 0x0, /// No tags are open
SuperScript = 0x01, /// A superscript tag is open
SubScript = 0x02, /// A subscript tag is open
Anchor = 0x04, /// An anchor tag is open
SpanForeground = 0x08, /// A foreground altering span tag is open.
SpanBackground = 0x10, /// A background altering span tag is open.
SpanFontFamily = 0x20, /// A font family altering span tag is open.
SpanFontPointSize = 0x40, /// A font size altering span tag is open.
Strong = 0x80, /// A strong tag is open.
Emph = 0x100, /// A emphasis tag is open.
Underline = 0x200, /// An underline tag is open.
StrikeOut = 0x400 /// A strikeout tag is open.
};
protected:
#ifndef Q_QDOC
MarkupDirectorPrivate *const d_ptr;
#endif
/**
The builder this MarkupDirector is operating on. This is available when
subclassing to customize behaviour.
*/
AbstractMarkupBuilder *m_builder;
#ifndef Q_QDOC
private:
Q_DECLARE_PRIVATE(MarkupDirector)
#endif
};
}
#endif
@@ -1,79 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_MEDIAWIKIMARKUPBUILDER_H
#define GRANTLEE_MEDIAWIKIMARKUPBUILDER_H
#include "abstractmarkupbuilder.h"
namespace Grantlee
{
/**
@brief Creates MediaWiki markup from a QTextDocument
*/
class MediaWikiMarkupBuilder : public AbstractMarkupBuilder
{
public:
MediaWikiMarkupBuilder();
~MediaWikiMarkupBuilder() override;
void beginStrong() override;
void endStrong() override;
void beginEmph() override;
void endEmph() override;
void beginUnderline() override;
void endUnderline() override;
void beginStrikeout() override;
void endStrikeout() override;
void endParagraph() override;
void addNewline() override;
void beginAnchor(const QString &href = {}, const QString &name = {}) override;
void endAnchor() override;
void beginHeader(int level) override;
void endHeader(int level) override;
void beginList(QTextListFormat::Style type) override;
void endList() override;
void beginListItem() override;
void endListItem() override;
void appendLiteralText(const QString &text) override;
/**
Escapes @p text appropriately for MediaWiki.
*/
const QString escape(const QString &s);
QString getResult() override;
private:
QList<QTextListFormat::Style> currentListItemStyles;
QString m_text;
};
}
#endif
-244
View File
@@ -1,244 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2010 Michael Jansen <kde@michael-jansen.biz>
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_METATYPE_H
#define GRANTLEE_METATYPE_H
#include "grantlee_templates_export.h"
#include "typeaccessor.h"
#include <QtCore/QVariant>
/// @file
namespace Grantlee
{
/// @headerfile metatype.h grantlee/metatype.h
#ifndef Q_QDOC
/**
@brief The **%MetaType** is the interface to the Grantlee introspection
system.
The **%MetaType** class is used as part of the type registration system of
%Grantlee.
@see @ref generic_types_and_templates
@author Michael Jansen <kde@michael-jansen.biz>
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT MetaType
{
public:
/**
@internal The signature for a property lookup method
*/
typedef QVariant (*LookupFunction)(const QVariant &, const QString &);
/**
@internal Registers a property lookup method
*/
static void registerLookUpOperator(int id, LookupFunction f);
/**
@internal
*/
static void internalLock();
/**
@internal
*/
static void internalUnlock();
/**
@internal
*/
static QVariant lookup(const QVariant &object, const QString &property);
/**
@internal
*/
static bool lookupAlreadyRegistered(int id);
private:
MetaType();
};
#endif
namespace
{
/*
This is a helper to select an appropriate overload of indexAccess
*/
template <typename RealType, typename HandleAs> struct LookupTrait {
static QVariant doLookUp(const QVariant &object, const QString &property)
{
typedef typename Grantlee::TypeAccessor<RealType> Accessor;
return Accessor::lookUp(object.value<RealType>(), property);
}
};
template <typename RealType, typename HandleAs>
struct LookupTrait<RealType &, HandleAs &> {
static QVariant doLookUp(const QVariant &object, const QString &property)
{
typedef typename Grantlee::TypeAccessor<HandleAs &> Accessor;
return Accessor::lookUp(object.value<HandleAs>(), property);
}
};
template <typename RealType, typename HandleAs> static int doRegister(int id)
{
if (MetaType::lookupAlreadyRegistered(id))
return id;
QVariant (*lf)(const QVariant &, const QString &)
= LookupTrait<RealType, HandleAs>::doLookUp;
MetaType::registerLookUpOperator(
id, reinterpret_cast<MetaType::LookupFunction>(lf));
return id;
}
/*
Register a type so grantlee knows how to handle it.
*/
template <typename RealType, typename HandleAs> struct InternalRegisterType {
static int doReg()
{
const int id = qMetaTypeId<RealType>();
return doRegister<RealType &, HandleAs &>(id);
}
};
template <typename RealType, typename HandleAs>
struct InternalRegisterType<RealType *, HandleAs *> {
static int doReg()
{
const int id = qMetaTypeId<RealType *>();
return doRegister<RealType *, HandleAs *>(id);
}
};
}
/**
@brief Registers the type RealType with the metatype system.
This method can take a second template parameter to specify a cast
that should be invoked during registration. This is useful if a base type is
already supported.
@code
class SomeType
{
public:
QString someProp() const;
};
// define some introspectable API for SomeType
GRANTLEE_BEGIN_LOOKUP(SomeType)
if (property == "someProp")
return object.someProp();
GRANTLEE_END_LOOKUP
class OtherType : public SomeType
{
// ...
};
registerMetaType<SomeType>();
// Only the introspectable API from SomeType is needed, so we can reuse that
registration.
registerMetaType<OtherType, SomeType>();
@endcode
@see @ref generic_types_and_templates
*/
template <typename RealType, typename HandleAs> int registerMetaType()
{
MetaType::internalLock();
const int id = InternalRegisterType<RealType, HandleAs>::doReg();
MetaType::internalUnlock();
return id;
}
#ifndef Q_QDOC
/**
@internal
Register a type so %Grantlee knows how to handle it.
This is a convenience method.
*/
template <typename Type> int registerMetaType()
{
return registerMetaType<Type, Type>();
}
#endif
} // namespace Grantlee
/**
Top boundary of a lookup function for Type.
@see @ref generic_types
*/
#define GRANTLEE_BEGIN_LOOKUP(Type) \
namespace Grantlee \
{ \
template <> \
inline QVariant TypeAccessor<Type &>::lookUp(const Type &object, \
const QString &property) \
{
/**
Top boundary of a lookup function for Type*.
@see @ref generic_types
*/
#define GRANTLEE_BEGIN_LOOKUP_PTR(Type) \
namespace Grantlee \
{ \
template <> \
inline QVariant TypeAccessor<Type *>::lookUp(const Type *const object, \
const QString &property) \
{
/**
Bottom boundary of a lookup function for Type.
@see @ref generic_types
*/
#define GRANTLEE_END_LOOKUP \
return QVariant(); \
} \
}
#endif // #define GRANTLEE_METATYPE_H
-380
View File
@@ -1,380 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_NODE_H
#define GRANTLEE_NODE_H
// krazy:excludeall=dpointer
#include "context.h"
#include "filterexpression.h"
#include "grantlee_templates_export.h"
#include "outputstream.h"
#include "safestring.h"
#include <QtCore/QStringList>
// Need these for inheriting from QList<T> to work
// http://lists.trolltech.com/qt-interest/2008-01/thread00578-0.html
#include <QtCore/QSet>
#include <QtCore/QVector>
namespace Grantlee
{
class Engine;
class NodeList;
class TemplateImpl;
class NodePrivate;
/// @headerfile node.h grantlee/node.h
/**
@brief Base class for all nodes.
The **%Node** class can be implemented to make additional functionality
available to Templates.
A node is represented in template markup as content surrounded by percent
signed tokens.
@code
text content
{% some_tag arg1 arg2 %}
text content
{% some_other_tag arg1 arg2 %}
text content
{% end_some_other_tag %}
text content
@endcode
This is parsed into a tree of **%Node** objects by an implementation of
AbstractNodeFactory. The **%Node** objects can then later be rendered by their
@ref render method.
Rendering a **%Node** will usually mean writing some output to the stream. The
content written to the stream could be determined by the arguments to the tag,
or by the content of child nodes between a start and end tag, or both.
@see FilterExpression
@see @ref tags
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT Node : public QObject
{
Q_OBJECT
public:
/**
Constructor.
@param parent The parent QObject
*/
explicit Node(QObject *parent = {});
/**
Destructor.
*/
~Node() override;
/**
Reimplement this to render the template in the Context @p c.
This will also involve calling render on and child nodes.
*/
virtual void render(OutputStream *stream, Context *c) const = 0;
#ifndef Q_QDOC
/**
@internal
*/
virtual bool mustBeFirst()
{ // krazy:exclude:inline
return false;
}
#endif
protected:
/**
Renders the value @p input in the Context @p c. This will involve escaping
@p input if necessary.
This is only relevant to developing template tags.
*/
void streamValueInContext(OutputStream *stream, const QVariant &input,
Grantlee::Context *c) const;
/**
Returns a raw pointer to the Template this **%Node** is in.
*/
TemplateImpl *containerTemplate() const;
private:
Q_DECLARE_PRIVATE(Node)
NodePrivate *const d_ptr;
};
/// @headerfile node.h grantlee/node.h
/**
@brief A list of Nodes with some convenience API for rendering them.
Typically, tags which have an end tag will create and later render a list of
child nodes.
This class contains API such as @ref append and @ref render to make creating
such list easily.
The @ref findChildren method behaves similarly to the QObject::findChildren
method, returning a list of nodes of a particular type from the Node objects
contained in the list (and their children).
@see @ref tags_with_end_tags
*/
class GRANTLEE_TEMPLATES_EXPORT NodeList : public QList<Grantlee::Node *>
{
public:
/**
Creates an empty **%NodeList**.
*/
NodeList();
/**
Copy constructor.
*/
NodeList(const NodeList &list);
NodeList &operator=(const NodeList &list);
/**
Convenience constructor
*/
/* implicit */ NodeList(const QList<Grantlee::Node *> &list);
/**
Destructor.
*/
~NodeList();
/**
Appends @p node to the end of this **%NodeList**.
*/
void append(Grantlee::Node *node);
/**
Appends @p nodeList to the end of this **%NodeList**.
*/
void append(QList<Grantlee::Node *> nodeList);
/**
Returns true if this **%NodeList** contains non-text nodes.
*/
bool containsNonText() const;
/**
A recursive listing of nodes in this tree of type @p T.
*/
template <typename T> QList<T> findChildren()
{
QList<T> children;
QList<Grantlee::Node *>::const_iterator it;
const QList<Grantlee::Node *>::const_iterator first = constBegin();
const QList<Grantlee::Node *>::const_iterator last = constEnd();
for (it = first; it != last; ++it) {
T object = qobject_cast<T>(*it);
if (object) {
children << object;
}
children << (*it)->findChildren<T>();
}
return children;
}
/**
Renders the list of Nodes in the Context @p c.
*/
void render(OutputStream *stream, Context *c) const;
private:
bool m_containsNonText;
};
class AbstractNodeFactoryPrivate;
/// @headerfile node.h grantlee/node.h
/**
@brief Base class for all NodeFactories
This class can be used to make custom tags available to templates.
The getNode method should be implemented to return a Node to be rendered.
A node is represented in template markup as content surrounded by percent
signed tokens.
@code
text content
{% some_tag arg1 arg2 %}
text content
{% some_other_tag arg1 arg2 %}
text content
{% end_some_other_tag %}
text content
@endcode
It is the responsibility of an **%AbstractNodeFactory** implementation to
process the contents of a tag and return a Node implementation from its
getNode method.
The @ref getNode method would for example be called with the tagContent
\"<tt>some_tag arg1 arg2</tt>\". That content could then be split up, the
arguments processed and a Node created
@code
Node* SomeTagFactory::getNode(const QString &tagContent, Parser *p) {
QStringList parts = smartSplit( tagContent );
parts.removeFirst(); // Remove the "some_tag" part.
FilterExpression arg1( parts.first(), p );
FilterExpression arg2( parts.at( 1 ), p );
return new SomeTagNode( arg1, arg2, p );
}
@endcode
The @ref getNode implementation might also advance the parser. For example if
we had a @gr_tag{times} tag which rendered content the amount of times it was
given in its argument, it could be used like this:
@code
Some text content.
{% times 5 %}
the bit to be repeated
{% end_times %}
End text content
@endcode
The argument to @gr_tag{times} might not be a simple number, but could be a
FilterExpression such as \"<tt>someobject.some_property|getDigit:1</tt>\".
The implementation could look like
@code
Node* SomeOtherTagFactory::getNode(const QString &tagContent, Parser *p) {
QStringList parts = smartSplit( tagContent );
parts.removeFirst(); // Remove the "times" part.
FilterExpression arg( parts.first(), p );
auto node = new SomeTagNode( arg, p );
auto childNodes = p->parse( node, "end_times" );
node->setChildNodes( childNodes );
p->removeNextToken();
return node;
}
@endcode
Note that it is necessary to invoke the parser to create the child nodes only
after creating the Node to return. That node must be passed to the Parser to
perform as the parent QObject to the child nodes.
@see Parser::parse
*/
class GRANTLEE_TEMPLATES_EXPORT AbstractNodeFactory : public QObject
{
Q_OBJECT
public:
/**
Constructor.
@param parent The parent QObject
*/
explicit AbstractNodeFactory(QObject *parent = {});
/**
Destructor.
*/
~AbstractNodeFactory() override;
/**
This method should be reimplemented to return a Node which can be
rendered.
The @p tagContent is the content of the tag including the tag name and
arguments. For example, if the template content is @gr_tag{my_tag arg1
arg2}, the tagContent will be &quot;my_tag arg1 arg2&quot;.
The Parser @p p is available and can be advanced if appropriate. For
example, if the tag has an end tag, the parser can be advanced to the end
tag.
@see tags
*/
virtual Node *getNode(const QString &tagContent, Parser *p) const = 0;
#ifndef Q_QDOC
/**
@internal
Sets the Engine which created this NodeFactory. Used by the
ScriptableNodeFactory.
*/
virtual void setEngine(Engine *) {}
#endif
protected:
/**
Splits @p str into a list, taking quote marks into account.
This is typically used in the implementation of getNode with the
tagContent.
If @p str is 'one &quot;two three&quot; four 'five &quot; six' seven', the
returned list will contain the following strings:
- one
- &quot;two three&quot;
- four
- five &quot; six
- seven
*/
Q_INVOKABLE QStringList smartSplit(const QString &str) const;
protected:
/**
Returns a list of FilterExpression objects created with Parser @p p as
described by the content of @p list.
This is used for convenience when handling the arguments to a tag.
*/
QList<FilterExpression> getFilterExpressionList(const QStringList &list,
Parser *p) const;
private:
Q_DECLARE_PRIVATE(AbstractNodeFactory)
AbstractNodeFactoryPrivate *const d_ptr;
};
}
#endif
-145
View File
@@ -1,145 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_OUTPUTSTREAM_H
#define GRANTLEE_OUTPUTSTREAM_H
#include "grantlee_templates_export.h"
#include <QtCore/QSharedPointer>
#include <QtCore/QTextStream>
namespace Grantlee
{
class SafeString;
/// @headerfile outputstream.h grantlee/outputstream.h
/**
@brief The **%OutputStream** class is used to render templates to a
QTextStream
A **%OutputStream** instance may be passed to the render method of a Template
to render the template to a stream.
@code
QFile outputFile("./output");
outputFile.open(QFile::WriteOnly);
QTextStream tstream( &outputFile );
OutputStream os(&tstream);
t->render( &os, &context );
@endcode
The **%OutputStream** is used to escape the content streamed to it. By
default, the escaping is html escaping, converting "&" to "&amp;" for example.
If generating non-html output, the @ref escape method may be overriden to
perform a different escaping, or non at all.
If overriding the @ref escape method, the @ref clone method must also be
overriden to return an **%OutputStream** with the same escaping behaviour.
@code
class NoEscapeStream : public Grantlee::OutputStream
{
public:
// ...
QString escape( const QString &input ) const
{
return input;
}
QSharedPointer<OutputStream> clone( QTextStream *stream ) const
{
return QSharedPointer<NoEscapeStream>::create( stream );
}
};
@endcode
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT OutputStream
{
public:
/**
Creates a null **%OutputStream**. Content streamed to
this **%OutputStream** is sent to <tt>/dev/null</tt>
*/
OutputStream();
/**
Creates an **%OutputStream** which will stream content to @p stream
with appropriate escaping.
*/
explicit OutputStream(QTextStream *stream);
/**
Destructor
*/
virtual ~OutputStream();
/**
Returns an escaped version of @p input. Does not write anything to the
stream.
*/
virtual QString escape(const QString &input) const;
/**
Returns an escaped version of @p input. Does not write anything to the
stream.
*/
QString escape(const SafeString &input) const;
/**
Returns a cloned **%OutputStream** with the same filtering behaviour.
*/
virtual QSharedPointer<OutputStream> clone(QTextStream *stream) const;
/**
Returns @p after escaping it, unless @p input is "safe", in which case,
@p input is returned unmodified.
*/
QString conditionalEscape(const Grantlee::SafeString &input) const;
/**
Writes @p input to the stream after escaping it.
*/
OutputStream &operator<<(const QString &input);
/**
Writes @p input to the stream after escaping it if necessary.
*/
OutputStream &operator<<(const SafeString &input);
/**
Reads the content of @p stream and writes it unmodified to the result
stream.
*/
OutputStream &operator<<(QTextStream *stream);
private:
QTextStream *m_stream;
Q_DISABLE_COPY(OutputStream)
};
}
#endif
-144
View File
@@ -1,144 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_PARSER_H
#define GRANTLEE_PARSER_H
#include "filter.h"
#include "node.h"
#include "token.h"
#include <QtCore/QStringList>
namespace Grantlee
{
class TemplateImpl;
class ParserPrivate;
/// @headerfile parser.h grantlee/parser.h
/**
@brief The **%Parser** class processes a string template into a tree of nodes.
For application developers, this class is internal.
For template tag authors it may be necessary to advance the parser and process
contained tags if the tag works in a tag -- endtag fashion.
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT Parser : public QObject
{
Q_OBJECT
public:
/**
Constructor.
Initialises the **%Parser** with the @p tokenList.
*/
Parser(const QList<Token> &tokenList, QObject *parent);
/**
Destructor.
*/
~Parser() override;
/**
Advance the parser, using @p parent as the parent of new Nodes. The parser
will stop if it encounters a tag which is contained in the list @p stopAt.
For example, the @gr_tag{if} tag would stopAt both @gr_tag{endif} and
@gr_tag{else} tags.
@see AbstractNodeFactory::getNode
*/
NodeList parse(Node *parent, const QStringList &stopAt = {});
/**
This is an overloaded method.
@see parse.
*/
NodeList parse(TemplateImpl *parent, const QStringList &stopAt = {});
/**
This is an overloaded method.
@see parse.
*/
NodeList parse(Node *parent, const QString &stopAt);
/**
Returns the filter object called @p name or an invalid object if no filter
with that name is loaded.
*/
QSharedPointer<Filter> getFilter(const QString &name) const;
/**
Advances the parser to the tag @p tag. This method is similar to @ref parse,
but it does not create nodes for tags encountered.
*/
void skipPast(const QString &tag);
/**
Returns the next token to be processed by the parser. This can be examined
in template tag implementations to determine why parsing stopped.
For example, if the @gr_tag{if} tag, parsing may stop at an @gr_tag{else}
tag, in which case parsing should be restarted, or it could stop at an
@gr_tag{endif} tag, in which case parsing is finished for that node.
*/
Token takeNextToken();
/**
Returns whether the parser has another token to process.
*/
bool hasNextToken() const;
/**
Deletes the next token available to the parser.
*/
void removeNextToken();
void invalidBlockTag(const Token &token, const QString &command,
const QStringList &stopAt = {});
#ifndef Q_QDOC
/**
@internal
Used by the @gr_tag{load} tag to load libraries.
*/
void loadLib(const QString &name);
#endif
protected:
/**
Puts the token @p token to the front of the list to be processed by the
parser.
*/
void prependToken(const Token &token);
private:
Q_DECLARE_PRIVATE(Parser)
ParserPrivate *const d_ptr;
};
}
#endif
@@ -1,211 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_PLAINTEXTMARKUPBUILDER_H
#define GRANTLEE_PLAINTEXTMARKUPBUILDER_H
#ifdef Q_OS_WIN
#pragma warning(disable : 4250)
#endif
#define LETTERSINALPHABET 26
#define DIGITSOFFSET 10
#include "abstractmarkupbuilder.h"
#include "grantlee_textdocument_export.h"
#include "markupdirector.h"
class QBrush;
namespace Grantlee
{
class PlainTextMarkupBuilderPrivate;
/// @headerfile plaintextmarkupbuilder.h grantlee/plaintextmarkupbuilder.h
/**
@brief Creates a simple marked up plain text document
This class creates a simple plain text markup.
Text that may be represented as
@code
A paragraph with <b>bold</b> text, <i>italic</i> text,
and <u>underlined</u> text.
@endcode
would be output as
@code
A paragraph with *bold* text /italic/ text,
and _underlined_ text.
@endcode
The markup is intended to be simple, plain and easily human readable. No
markup is created for different font-familiy, font-size, foreground or
background colors.
Lists are marked up by preceding the list element with '*' for disc, 'o' for
circle, 'X' for square, or a letter or number. Lists are also indented if
nested. eg:
@code
A. One
B. Two
o Three
o Four
\* Five
\* Six
C. Seven
@endcode
External references such as external urls and images are represented in the
body text as a reference, and references are maintained at the bottom of the
output.
Eg,
@code
Here is a link to <a href="http://www.kde.org">KDE</a> and
the <a href="http://pim.kde.org">KDEPIM project</a>.
@endcode
becomes:
@code
Here is a link to KDE[1], and
the KDEPIM project[2].
---- References ----
[1] http://www.kde.org
[2] http://pim.kde.org
@endcode
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEXTDOCUMENT_EXPORT PlainTextMarkupBuilder
: virtual public AbstractMarkupBuilder
{
public:
PlainTextMarkupBuilder();
~PlainTextMarkupBuilder() override;
void beginStrong() override;
void endStrong() override;
void beginEmph() override;
void endEmph() override;
void beginUnderline() override;
void endUnderline() override;
void beginStrikeout() override;
void endStrikeout() override;
void beginAnchor(const QString &href = {}, const QString &name = {}) override;
void endAnchor() override;
void beginForeground(const QBrush &brush) override;
void endForeground() override;
void beginBackground(const QBrush &brush) override;
void endBackground() override;
void beginFontFamily(const QString &family) override;
void endFontFamily() override;
void beginFontPointSize(int size) override;
void endFontPointSize() override;
void beginParagraph(Qt::Alignment a = Qt::AlignLeft, qreal top = 0.0,
qreal bottom = 0.0, qreal left = 0.0,
qreal right = 0.0) override;
void endParagraph() override;
void addNewline() override;
void insertHorizontalRule(int width = -1) override;
void insertImage(const QString &src, qreal width, qreal height) override;
void beginList(QTextListFormat::Style style) override;
void endList() override;
void beginListItem() override;
void endListItem() override;
void beginSuperscript() override;
void endSuperscript() override;
void beginSubscript() override;
void endSubscript() override;
void beginTable(qreal cellpadding, qreal cellspacing,
const QString &width) override;
void beginTableRow() override;
void beginTableHeaderCell(const QString &width, int colSpan,
int rowSpan) override;
void beginTableCell(const QString &width, int colSpan, int rowSpan) override;
void endTable() override;
void endTableRow() override;
void endTableHeaderCell() override;
void endTableCell() override;
void beginHeader(int level) override;
void endHeader(int level) override;
void appendLiteralText(const QString &text) override;
void appendRawText(const QString &text) override;
/**
Adds a reference to @p reference to the internal list of references in the
document.
*/
int addReference(const QString &reference);
/**
Returns the finalised plain text markup, including references at the end.
*/
QString getResult() override;
private:
PlainTextMarkupBuilderPrivate *const d_ptr;
Q_DECLARE_PRIVATE(PlainTextMarkupBuilder)
};
}
#endif
-135
View File
@@ -1,135 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_QTLOCALIZER_P_H
#define GRANTLEE_QTLOCALIZER_P_H
#include "abstractlocalizer.h"
class QTranslator;
namespace Grantlee
{
class QtLocalizerPrivate;
/**
@brief Provides internationalization based on QLocale and QTranslator.
This class implements access to the %Qt Localization system. Localizable
types such as strings, numbers, dates and times can be processed.
@code
auto t = m_engine->loadTemplate(someTemplate);
auto c = getContext();
// Render with the German locale
c.setLocalizer(m_de_Localizer);
auto deText = t->render(&c);
de_display->setText(deText);
// Render with the French locale
c.setLocalizer(m_fr_Localizer);
auto frText = t->render(&c);
fr_display->setText(frText);
@endcode
*/
class GRANTLEE_TEMPLATES_EXPORT QtLocalizer : public AbstractLocalizer
{
public:
/**
Constructs a new **%QtLocalizer** using the @p locale
*/
QtLocalizer(const QLocale &locale = QLocale::system());
/**
Destructor
*/
~QtLocalizer() override;
/**
Set the path to look for translations of the application strings.
*/
void setAppTranslatorPath(const QString &path);
/**
Set the prefix of translation files. For example, if the German translation
file is called <tt>myapp_de_DE.qm</tt>, the prefix should be set to
<tt>myapp_</tt>.
*/
void setAppTranslatorPrefix(const QString &prefix);
/**
Install a @p translator to use for a particular @p localeName.
@code
auto deTranslator = new QTranslator(this);
auto loaded = deTranslator->load("myapp_de_DE");
if (!loaded)
return;
de_localizer->installTranslator(deTranslator, "de_DE");
@endcode
*/
void installTranslator(QTranslator *translator,
const QString &localeName = QLocale::system().name());
QString currentLocale() const override;
void pushLocale(const QString &localeName) override;
void popLocale() override;
void loadCatalog(const QString &path, const QString &catalog) override;
void unloadCatalog(const QString &catalog) override;
QString localizeNumber(int number) const override;
QString localizeNumber(qreal number) const override;
QString localizeMonetaryValue(qreal value, const QString &currencyCode
= {}) const override;
QString localizeDate(const QDate &date,
QLocale::FormatType formatType
= QLocale::ShortFormat) const override;
QString localizeTime(const QTime &time,
QLocale::FormatType formatType
= QLocale::ShortFormat) const override;
QString localizeDateTime(const QDateTime &dateTime,
QLocale::FormatType formatType
= QLocale::ShortFormat) const override;
QString localizeString(const QString &string,
const QVariantList &arguments = {}) const override;
QString localizeContextString(const QString &string, const QString &context,
const QVariantList &arguments
= {}) const override;
QString localizePluralContextString(const QString &string,
const QString &pluralForm,
const QString &context,
const QVariantList &arguments
= {}) const override;
QString localizePluralString(const QString &string, const QString &pluralForm,
const QVariantList &arguments
= {}) const override;
private:
Q_DECLARE_PRIVATE(QtLocalizer)
Q_DISABLE_COPY(QtLocalizer)
QtLocalizerPrivate *const d_ptr;
};
}
#endif
-83
View File
@@ -1,83 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_RENDERCONTEXT_H
#define GRANTLEE_RENDERCONTEXT_H
#include "grantlee_templates_export.h"
#include <QtCore/QVariantHash>
/// @headerfile rendercontext.h grantlee/rendercontext.h
namespace Grantlee
{
class ContextPrivate;
class TemplateImpl;
class Node;
class RenderContextPrivate;
/**
@brief Provides storage facility for state while rendering a template.
This class can not be instatiated by users of it. An instance
of **%RenderContext** is available through Context::renderContext() for use
with implementations of re-entrant template tags.
*/
class GRANTLEE_TEMPLATES_EXPORT RenderContext
{
public:
/**
Returns the data for the node @p scopeNode.
*/
QVariant &data(const Node *const scopeNode);
/**
Returns whether the **%RenderContext** contains data for @p scopeNode.
*/
bool contains(Node *const scopeNode) const;
/**
Destructor
*/
~RenderContext();
#ifndef Q_QDOC
private:
RenderContext();
void push();
void pop();
private:
friend class ContextPrivate;
friend class TemplateImpl;
Q_DISABLE_COPY(RenderContext)
Q_DECLARE_PRIVATE(RenderContext)
RenderContextPrivate *const d_ptr;
#endif
};
}
#endif
-436
View File
@@ -1,436 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_SAFESTRING_H
#define GRANTLEE_SAFESTRING_H
#include "grantlee_templates_export.h"
#include <QtCore/QString>
#include <QtCore/QVariant>
namespace Grantlee
{
/// @headerfile safestring.h grantlee/safestring.h
/**
@brief A QString wrapper class for containing whether a string is safe or
needs to be escaped.
This allows lazy escaping of strings. Otherwise a string may be escaped
multiple times where it should only be escaped once.
The **%SafeString** class itself provides information about whether a string
is safe from further escaping through the @ref isSafe method. The actual
string content held by the **%SafeString** instance is available through the
@ref get method. The @ref get method returns a QString subclass which should
be used like any other QString. The difference is that all methods on
NestedString return a **%SafeString** instead of a QString.
@code
SafeString s("this & that", SafeString::IsSafe);
s.get().replace( "this", "these" ).toUpper();
qDebug() << s.get() << s.isSafe(); // outputs "these & that" false
@endcode
Note that most operations on strings make the string unsafe. For example,
while <tt>"K &amp; R"</tt> is safe, using replace("m", "n") will result in
<tt>"K &anp; R"</tt>, which is unsafe. Likewise using upper() will return
<tt>"K &AMP; R"</tt>, which is unsafe. Because the **%SafeString** can not
determine whether a method call with particular arguments will change
a **%SafeString** from being safe to being unsafe, any operation which can
possibly make the string unsafe does cause the string to become unsafe. It is
then up to the caller to restore safe-ness if needed.
NestedString has overloads for SafeStrings whereever appropriate so that
strings remain marked as safe where possible.
For example:
@code
SafeString s1("this & that", SafeString::IsSafe);
s2 = s1;
s1.append( QString( " & the other" ) );
// s1 is now "this & that & the other" and is unsafe.
SafeString s3(" Wobl & Bob", SafeString::IsSafe);
s2.append(s3);
// Both s2 and s3 are safe, and append is a safe operation, so s2
// is still safe
@endcode
@see @ref autoescaping
@see OutputStream::escape
The **%SafeString** class has appropriate operator overloads to make it
convenient to use in methods returning a QVariant, such as Filter::doFilter,
or as a QString. Note that a raw QString is essentially the same
as a **%SafeString** which is marked as unsafe.
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT SafeString
{
public:
/**
Possible safety states of a **%SafeString**
*/
enum Safety {
IsSafe, ///< The string is safe and requires no further escaping
IsNotSafe ///< The string is not safe. It will be escaped before being
/// added to the output of rendering.
};
/**
Constructs an empty **%SafeString**.
*/
SafeString();
/**
Copy constructor
*/
SafeString(const SafeString &safeString);
/**
Constructs a **%SafeString** with the content @p str whose safety is given
by @p safe.
*/
SafeString(const QString &str, bool safe);
/**
Constructs a **%SafeString** with the content @p str whose safety is given
by @p safety.
*/
/* implicit */ SafeString(const QString &str,
Safety safety
= IsNotSafe); // krazy:exclude=explicit
/**
Destructor
*/
~SafeString();
#ifndef Q_QDOC
/**
Set whether the string should be escaped.
*/
void setNeedsEscape(bool needsEscape);
#endif
/**
Whether the string needs to be escaped.
*/
bool needsEscape() const;
/**
Whether the string is safe.
*/
bool isSafe() const;
#ifndef Q_QDOC
/**
Set whether the string is safe.
*/
void setSafety(Safety safety);
#endif
/**
@brief The NestedString is a QString whose methods always return a
SafeString
This class is largely an implementation detail. See the SafeString
documentation for details.
*/
class GRANTLEE_TEMPLATES_EXPORT NestedString : public QString
{
#ifndef Q_QDOC
friend class SafeString;
SafeString *m_safeString;
public:
NestedString(SafeString *safeString);
NestedString(const QString &content, SafeString *safeString);
SafeString &append(const SafeString &str);
SafeString &append(const QString &str);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
SafeString &append(const QStringRef &ref);
#endif
SafeString &append(const QLatin1String &str);
#ifndef QT_NO_CAST_FROM_ASCII
SafeString &append(const QByteArray &ba)
{
QString::append(ba);
m_safeString->m_safety = IsNotSafe;
return *m_safeString;
}
SafeString &append(const char *str)
{
QString::append(str);
m_safeString->m_safety = IsNotSafe;
return *m_safeString;
}
#endif
SafeString &append(const QChar ch);
SafeString &fill(QChar ch, int size = -1);
SafeString &insert(int position, const SafeString &str);
SafeString &insert(int position, const QString &str);
SafeString &insert(int position, const QLatin1String &str);
SafeString &insert(int position, const QChar *unicode, int size);
SafeString &insert(int position, QChar ch);
SafeString left(int n) const;
SafeString leftJustified(int width, QChar fill = QLatin1Char(' '),
bool truncate = {}) const;
SafeString mid(int position, int n = -1) const;
SafeString normalized(NormalizationForm mode) const;
SafeString normalized(NormalizationForm mode,
QChar::UnicodeVersion version) const;
SafeString &prepend(const SafeString &str);
SafeString &prepend(const QString &str);
SafeString &prepend(const QLatin1String &str);
#ifndef QT_NO_CAST_FROM_ASCII
SafeString &prepend(const QByteArray &ba)
{
QString::prepend(ba);
m_safeString->m_safety = IsNotSafe;
return *m_safeString;
}
SafeString &prepend(const char *str)
{
QString::prepend(str);
m_safeString->m_safety = IsNotSafe;
return *m_safeString;
}
#endif
SafeString &prepend(QChar ch);
void push_back(const SafeString &other);
void push_front(const SafeString &other);
SafeString &remove(int position, int n);
SafeString &remove(QChar ch, Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &remove(const SafeString &str,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &remove(const QString &str,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &remove(const QRegularExpression &rx);
SafeString repeated(int times) const;
SafeString &replace(int position, int n, const SafeString &after);
SafeString &replace(int position, int n, const QString &after);
SafeString &replace(int position, int n, const QChar *unicode, int size);
SafeString &replace(int position, int n, QChar after);
SafeString &replace(const SafeString &before, const SafeString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const QString &before, const SafeString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const SafeString &before, const QString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const QString &before, const QString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const QChar *before, int blen, const QChar *after,
int alen, Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(QChar ch, const SafeString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(QChar ch, const QString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(QChar before, QChar after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const QLatin1String &before, const QLatin1String &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const QLatin1String &before, const SafeString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const QLatin1String &before, const QString &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const SafeString &before, const QLatin1String &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const QString &before, const QLatin1String &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(QChar c, const QLatin1String &after,
Qt::CaseSensitivity cs = Qt::CaseSensitive);
SafeString &replace(const QRegularExpression &rx, const SafeString &after);
SafeString &replace(const QRegularExpression &rx, const QString &after);
SafeString right(int n) const;
SafeString rightJustified(int width, QChar fill = QLatin1Char(' '),
bool truncate = {}) const;
SafeString section(QChar sep, int start, int end = -1,
SectionFlags flags = SectionDefault) const;
SafeString section(const SafeString &sep, int start, int end = -1,
SectionFlags flags = SectionDefault) const;
SafeString section(const QString &sep, int start, int end = -1,
SectionFlags flags = SectionDefault) const;
SafeString section(const QRegularExpression &reg, int start, int end = -1,
SectionFlags flags = SectionDefault) const;
SafeString &setNum(int n, int base = 10);
SafeString &setNum(uint n, int base = 10);
SafeString &setNum(long n, int base = 10);
SafeString &setNum(ulong n, int base = 10);
SafeString &setNum(qlonglong n, int base = 10);
SafeString &setNum(qulonglong n, int base = 10);
SafeString &setNum(short n, int base = 10);
SafeString &setNum(ushort n, int base = 10);
SafeString &setNum(double n, char format = 'g', int precision = 6);
SafeString &setNum(float n, char format = 'g', int precision = 6);
SafeString &setUnicode(const QChar *unicode, int size);
SafeString &setUtf16(const ushort *unicode, int size);
SafeString simplified() const;
// QT_DEPRECATED_SINCE(5, 15) to support consumers building with
// -DQT_DISABLE_DEPRECATED_BEFORE=0x050f00
// where QString enums will be invisible to the compiler
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_DEPRECATED_SINCE(5, 15)
// Calls with default argument for "behavior" should pick the Qt >= 5.14
// version, if available
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList split(const SafeString &sep, QString::SplitBehavior behavior,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QString &sep, QString::SplitBehavior behavior,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QChar &sep, QString::SplitBehavior behavior,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QRegularExpression &rx,
QString::SplitBehavior behavior) const;
#else
QStringList split(const SafeString &sep,
QString::SplitBehavior behavior = QString::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QString &sep,
QString::SplitBehavior behavior = QString::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QChar &sep,
QString::SplitBehavior behavior = QString::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QRegularExpression &rx,
QString::SplitBehavior behavior
= QString::KeepEmptyParts) const;
#endif
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QStringList split(const SafeString &sep,
Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QString &sep,
Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QChar &sep,
Qt::SplitBehavior behavior = Qt::KeepEmptyParts,
Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
QStringList split(const QRegularExpression &rx,
Qt::SplitBehavior behavior = Qt::KeepEmptyParts) const;
#endif
SafeString toLower() const;
SafeString toUpper() const;
SafeString trimmed() const;
void chop(int n);
#endif
};
/**
Returns the String held by this **%SafeString**
*/
const NestedString &get() const { return m_nestedString; }
/**
Returns the String held by this **%SafeString**
*/
NestedString &get() { return m_nestedString; }
/**
Convenience operator for treating a **%SafeString** like a QString.
*/
operator QString() const { return m_nestedString; }
/**
Assignment operator.
*/
SafeString &operator=(const SafeString &str);
/**
Returns a concatenation of this with @p str.
The result is not safe because str is not safe.
*/
SafeString operator+(const QString &str);
/**
Returns a concatenation of this with @p str.
The result is safe if both this and str are safe.
*/
SafeString operator+(const SafeString &str);
/**
Appends the content of @p str to this.
The result is not safe because @p str is not safe.
*/
SafeString &operator+=(const QString &str);
/**
Appends the content of @p str to this.
The result is safe if both this and @p str are safe.
*/
SafeString &operator+=(const SafeString &str);
/**
Returns true if the content of @p other matches the content of this.
Safeness and needing escaping are not accounted for in the comparison.
*/
bool operator==(const SafeString &other) const;
/**
Returns true if the content of @p other matches the content of this.
Safeness and needing escaping are not accounted for in the comparison.
*/
bool operator==(const QString &other) const;
/**
Convenience operator for storing a **%SafeString** in a QVariant.
*/
operator QVariant() const { return QVariant::fromValue(*this); }
private:
#ifndef Q_QDOC
NestedString m_nestedString;
#endif
Safety m_safety;
bool m_needsescape;
};
}
Q_DECLARE_METATYPE(Grantlee::SafeString)
#endif
-110
View File
@@ -1,110 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TAGLIBRARYINTERFACE_H
#define TAGLIBRARYINTERFACE_H
#include "outputstream.h"
#include <QtCore/QHash>
#include <QtCore/QObject>
namespace Grantlee
{
class AbstractNodeFactory;
class Engine;
class Filter;
/// @headerfile taglibraryinterface.h grantlee/taglibraryinterface.h
/**
@brief The **%TagLibraryInterface** returns available tags and filters from
libraries.
This interface must be implemented in tag and filter libraries.
The implementation will usually be very simple.
@code
class MyTagLibrary : public QObject, public TagLibraryInterface
{
Q_OBJECT
Q_INTERFACES( Grantlee::TagLibraryInterface )
public:
MyTagLibrary( QObject *parent = {} )
: QObject( parent ) {
}
QHash<QString, AbstractNodeFactory*>
nodeFactories(const QString &name = {}) {
Q_UNUSED( name );
QHash<QString, AbstractNodeFactory*> nodeFactories;
nodeFactories.insert( "mytag1", new MyTag1() );
nodeFactories.insert( "mytag2", new MyTag2() );
return nodeFactories;
}
QHash<QString, Filter*> filters( const QString &name = {} ) {
Q_UNUSED( name );
QHash<QString, Filter*> filters;
filters.insert( "myfilter1", new MyFilter1() );
filters.insert( "myfilter2", new MyFilter2() );
return filters;
}
};
@endcode
@author Stephen Kelly <steveire@gmail.com>
*/
class TagLibraryInterface
{
public:
virtual ~TagLibraryInterface() {}
/**
Returns the AbstractNodeFactory implementations available in this library.
*/
virtual QHash<QString, AbstractNodeFactory *>
nodeFactories(const QString &name = {})
{
Q_UNUSED(name);
static const QHash<QString, AbstractNodeFactory *> h;
return h;
};
/**
Returns the Filter implementations available in this library.
*/
virtual QHash<QString, Filter *> filters(const QString &name = {})
{
Q_UNUSED(name);
static const QHash<QString, Filter *> h;
return h;
};
};
}
Q_DECLARE_INTERFACE(Grantlee::TagLibraryInterface,
"org.grantlee.TagLibraryInterface/1.0")
#endif
-161
View File
@@ -1,161 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_TEMPLATE_H
#define GRANTLEE_TEMPLATE_H
#include "exception.h"
#include "grantlee_templates_export.h"
#include "node.h"
#include <QtCore/QSharedPointer>
#include <QtCore/QStringList>
namespace Grantlee
{
class Context;
class Engine;
class TemplateImpl;
class OutputStream;
#ifdef Q_QDOC
#define TemplateImpl Template
#else
typedef QSharedPointer<TemplateImpl> Template;
#endif
class TemplatePrivate;
/// @headerfile template.h grantlee/template.h
/**
@brief The **%Template** class is a tree of nodes which may be rendered.
All Templates are created through the Grantlee::Engine class.
A **%Template** is created by parsing some text markup passed into the Engine,
or by reading it from a file.
Note that **%Template** is actually a typedef for a
<tt>QSharedPointer&lt;TemplateImpl&gt;</tt>, so all of its members should be
accessed with <tt>operator-&gt;()</tt>.
The result of parsing is a **%Template** object which can be rendered multiple
times with multiple different Contexts.
@code
auto engine = getEngine();
auto t = engine->newTemplate(
"{{ name }} is aged {{ age }}",
"simple template" );
if ( t->error() )
{
// Tokenizing or parsing error, or couldn't find custom tags or filters.
qDebug() << t->errorString();
return;
}
QTextStream textStream( stdout );
OutputStream stream( textStream );
for ( ... )
{
Context c;
// ... c.insert
t->render( stream, c );
if (t->error())
{
// Rendering error.
qDebug() << t->errorString();
}
}
@endcode
If there is an error in parsing or rendering, the @ref error and @ref
errorString methods can be used to check the source of the error.
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT TemplateImpl : public QObject
{
Q_OBJECT
public:
~TemplateImpl() override;
/**
Renders the **%Template** to a string given the Context @p c.
*/
QString render(Context *c) const;
/**
Renders the **%Template** to the OutputStream @p stream given the Context c.
*/
OutputStream *render(OutputStream *stream, Context *c) const;
#ifndef Q_QDOC
/**
@internal
*/
NodeList nodeList() const;
/**
@internal
*/
void setNodeList(const NodeList &list);
#endif
/**
Returns an error code for the error encountered.
*/
Error error() const;
/**
Returns more information to developers in the form of a string.
*/
QString errorString() const;
/**
Returns the Engine that created this **%Template**.
*/
Engine const *engine() const;
#ifndef Q_QDOC
protected:
TemplateImpl(Engine const *engine, QObject *parent = {});
TemplateImpl(Engine const *engine, bool smartTrim, QObject *parent = {});
void setContent(const QString &templateString);
#endif
private:
// Don't allow setting the parent on a Template, which is memory managed as
// a QSharedPointer.
using QObject::setParent;
private:
Q_DECLARE_PRIVATE(Template)
TemplatePrivate *const d_ptr;
#ifndef Q_QDOC
friend class Engine;
friend class Parser;
#endif
};
}
#endif
-229
View File
@@ -1,229 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_TEMPLATELOADER_H
#define GRANTLEE_TEMPLATELOADER_H
#include "grantlee_templates_export.h"
#include "template.h"
#include <QtCore/QSharedPointer>
namespace Grantlee
{
class AbstractLocalizer;
/// @headerfile templateloader.h grantlee/templateloader.h
/**
@brief An retrieval interface to a storage location for Template objects.
This interface can be implemented to define new ways of retrieving the content
of Templates.
The interface of this class should not be called directly from applications.
TemplateLoaders will typically be created, configured and added to the
Grantlee::Engine which will call the appropriate API.
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT AbstractTemplateLoader
{
public:
/**
Destructor
*/
virtual ~AbstractTemplateLoader();
/**
Load a Template called @p name. Return an invalid Template if no content
by that name exists.
*/
virtual Template loadByName(const QString &name,
Engine const *engine) const = 0;
/**
Return a complete URI for media identified by fileName.
*/
virtual QPair<QString, QString>
getMediaUri(const QString &fileName) const = 0;
/**
Return true if a Template identified by @p name exists and can be loaded.
*/
virtual bool canLoadTemplate(const QString &name) const = 0;
};
/// @headerfile templateloader.h grantlee/templateloader.h
class FileSystemTemplateLoaderPrivate;
/**
@brief The **%FileSystemTemplateLoader** loads Templates from the file system.
This template loader works by traversing a list of directories to find
templates. Directories are checked in order, and the first match hit is parsed
and returned.
@code
loader->setTemplateDirs({
"/home/user/app/templates",
"/usr/local/share/app/templates"
});
engine->setTemplateLoader( loader );
// This will try /home/user/app/templates/mytemplate.html
// followed by /usr/local/share/app/templates/mytemplate.html
engine->loadByName( "mytemplate.html" );
@endcode
Additionally, a themeName may be set on the template loader, which will be
appended to search paths before the template name.
@code
loader->setTemplateDirs({
"/home/user/app/templates" <<
"/usr/local/share/app/templates"
});
loader->setTheme( "simple_theme" );
engine->setTemplateLoader( loader );
// This will try /home/user/app/templates/simple_theme/mytemplate.html
// followed by /usr/local/share/app/templates/simple_theme/mytemplate.html
engine->loadByName( "mytemplate.html" );
@endcode
Media URIs may be retrieved for media relative to the directories searched
queried for templates.
@code
loader->setTemplateDirs({
"/home/user/app/templates",
"/usr/local/share/app/templates"
});
loader->setTheme( "simple_theme" );
engine->setTemplateLoader( loader );
// This will try /home/user/app/templates/simple_theme/logo.png
// followed by /usr/local/share/app/templates/simple_theme/logo.png
// and return the first one that exists.
engine->mediaUri( "logo.png" );
@endcode
The template files loaded by a %**FileSystemTemplateLoader** must be UTF-8
encoded.
@see @ref deploying_templates
*/
class GRANTLEE_TEMPLATES_EXPORT FileSystemTemplateLoader
: public AbstractTemplateLoader
{
public:
/**
Constructor
*/
FileSystemTemplateLoader(const QSharedPointer<AbstractLocalizer> localizer
= {});
/**
Destructor
*/
~FileSystemTemplateLoader() override;
Template loadByName(const QString &name, Engine const *engine) const override;
bool canLoadTemplate(const QString &name) const override;
QPair<QString, QString> getMediaUri(const QString &fileName) const override;
/**
Sets the theme of this loader to @p themeName
*/
void setTheme(const QString &themeName);
/**
The themeName of this TemplateLoader
*/
QString themeName() const;
/**
Sets the directories to look for template files to @p dirs.
*/
void setTemplateDirs(const QStringList &dirs);
/**
The directories this TemplateLoader looks in for template files.
*/
QStringList templateDirs() const;
private:
Q_DECLARE_PRIVATE(FileSystemTemplateLoader)
FileSystemTemplateLoaderPrivate *const d_ptr;
};
/// @headerfile templateloader.h grantlee/templateloader.h
/**
@brief The **%InMemoryTemplateLoader** loads Templates set dynamically in
memory
This class is mostly used for testing purposes, but can also be used for
simple uses of %Grantlee.
Templates can be made available using the @ref setTemplate method, and will
then be retrieved by the Grantlee::Engine as appropriate.
*/
class GRANTLEE_TEMPLATES_EXPORT InMemoryTemplateLoader
: public AbstractTemplateLoader
{
public:
InMemoryTemplateLoader();
~InMemoryTemplateLoader() override;
Template loadByName(const QString &name, Engine const *engine) const override;
bool canLoadTemplate(const QString &name) const override;
QPair<QString, QString> getMediaUri(const QString &fileName) const override;
/**
Add a template content to this Loader.
Example:
@code
auto loader = QSharedPointer<InMemoryTemplateLoader::create();
loader->setTemplate( "name_template", "My name is {{ name }}" );
loader->setTemplate( "age_template", "My age is {{ age }}" );
engine->addTemplateLoader( loader );
// Both templates may now be retrieved by calling Engine::loadByName.
@endcode
*/
void setTemplate(const QString &name, const QString &content);
private:
QHash<QString, QString> m_namedTemplates;
};
}
#endif
-238
View File
@@ -1,238 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_TEXTHTMLBUILDER_H
#define GRANTLEE_TEXTHTMLBUILDER_H
#ifdef Q_CC_MSVC
#pragma warning(disable : 4250)
#endif
#include "abstractmarkupbuilder.h"
#include "grantlee_textdocument_export.h"
#include "markupdirector.h"
namespace Grantlee
{
class TextHTMLBuilderPrivate;
/// @headerfile texthtmlbuilder.h grantlee/texthtmlbuilder.h
/**
@brief The TextHTMLBuilder creates a clean html markup output.
This class creates html output which is as minimal as possible and restricted
to the rich text features supported in %Qt.
(https://doc.qt.io/qt-5/richtext-html-subset.html)
The output contains only the body content, not the head element or other
metadata.
eg:
@code
<p>
This is some <strong>formatted content</strong> in a paragraph.
</p>
@endcode
instead of the content produced by %Qt:
@code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><meta
http-equiv="Content-Type" content="text/html; charset=UTF-8" /><style
type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Sans Serif'; font-size:10pt;
font-weight:400; font-style:normal;">
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px;
margin-right:0px; -qt-block-indent:0; text-indent:0px;">This is some <span
style=" font-weight:600;">formatted content</span> in a paragraph.
</p></body></html>
@endcode
Such tags should be created separately. For example:
@code
auto b = new TextHTMLBuilder();
auto md = new MarkupDirector(b);
md->constructContent();
QString cleanHtml(
"<head>\n<title>%1</title>\n</head>\n<body>%2</body>\n</html>")
.arg(document.metaInformation(QTextDocument::DocumentTitle))
.arg(b->getOutput());
file.write(cleanHtml);
@endcode
Font formatting information on elements is represented by individual span
elements.
eg:
@code
<span style"color:blue;">
<span style="background-color:red;">
Blue text on red background
</span>
</span>
@endcode
instead of
@code
<span style="color:blue;background-color:red;">
Blue text on red background
</span>
@endcode
It my be possible to change this if necessary.
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEXTDOCUMENT_EXPORT TextHTMLBuilder
: virtual public AbstractMarkupBuilder
{
public:
TextHTMLBuilder();
~TextHTMLBuilder() override;
void beginStrong() override;
void endStrong() override;
void beginEmph() override;
void endEmph() override;
void beginUnderline() override;
void endUnderline() override;
void beginStrikeout() override;
void endStrikeout() override;
void beginForeground(const QBrush &brush) override;
void endForeground() override;
void beginBackground(const QBrush &brush) override;
void endBackground() override;
void beginAnchor(const QString &href = {}, const QString &name = {}) override;
void endAnchor() override;
// Maybe this stuff should just be added to a list, and then when I add
// literal text,
// add some kind of style attribute in one span instead of many.
void beginFontFamily(const QString &family) override;
void endFontFamily() override;
/**
Begin a new font point size
@param size The new size to begin.
*/
void beginFontPointSize(int size) override;
void endFontPointSize() override;
/**
Begin a new paragraph
@param al The new paragraph alignment
@param topMargin The new paragraph topMargin
@param bottomMargin The new paragraph bottomMargin
@param leftMargin The new paragraph leftMargin
@param rightMargin The new paragraph rightMargin
*/
void beginParagraph(Qt::Alignment al = Qt::AlignLeft, qreal topMargin = 0.0,
qreal bottomMargin = 0.0, qreal leftMargin = 0.0,
qreal rightMargin = 0.0) override;
/**
Begin a new header element.
@param level The new level to begin.
*/
void beginHeader(int level) override;
/**
End a header element.
@param level The new level to end.
*/
void endHeader(int level) override;
void endParagraph() override;
void addNewline() override;
void insertHorizontalRule(int width = -1) override;
void insertImage(const QString &src, qreal width, qreal height) override;
void beginList(QTextListFormat::Style type) override;
void endList() override;
void beginListItem() override;
void endListItem() override;
void beginSuperscript() override;
void endSuperscript() override;
void beginSubscript() override;
void endSubscript() override;
void beginTable(qreal cellpadding, qreal cellspacing,
const QString &width) override;
void beginTableRow() override;
void beginTableHeaderCell(const QString &width, int colspan,
int rowspan) override;
void beginTableCell(const QString &width, int colspan, int rowspan) override;
void endTable() override;
void endTableRow() override;
void endTableHeaderCell() override;
void endTableCell() override;
/**
Reimplemented from AbstractMarkupBuilder.
This implementation escapes the text before appending so that
@verbatim
A sample <b>bold</b> word.
@endverbatim
becomes
@verbatim
A sample &lt;b&gt;bold&lt;/b&gt; word.
@endverbatim
*/
void appendLiteralText(const QString &text) override;
/**
Append @p text without escaping.
This is useful if extending MarkupDirector
*/
void appendRawText(const QString &text) override;
QString getResult() override;
private:
TextHTMLBuilderPrivate *d_ptr;
Q_DECLARE_PRIVATE(TextHTMLBuilder)
};
}
#endif
-57
View File
@@ -1,57 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_TOKEN_H
#define GRANTLEE_TOKEN_H
#include <QtCore/QString>
namespace Grantlee
{
/**
@internal
The available token types.
*/
enum TokenType {
TextToken, ///< The Token is a text fragment
VariableToken, ///< The Token is a variable node
BlockToken, ///< The Token is a block, ie, part of a tag
CommentToken ///< The Token is a comment node.
};
/// @headerfile token.h grantlee/token.h
/**
A token in a parse stream for a template.
This class is only relevant for template tag implementations.
*/
struct Token {
int tokenType; ///< The Type of this Token
int linenumber; ///< The line number this Token starts at
QString content; ///< The content of this Token
};
}
Q_DECLARE_TYPEINFO(Grantlee::Token, Q_MOVABLE_TYPE);
#endif
-48
View File
@@ -1,48 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_TYPEACCESSOR_H
#define GRANTLEE_TYPEACCESSOR_H
#include "grantlee_templates_export.h"
#include <QtCore/QObject>
/// @file
namespace Grantlee
{
#ifndef Q_QDOC
template <typename T> struct TypeAccessor {
static QVariant lookUp(const T object, const QString &property);
};
template <typename T> struct TypeAccessor<T *> {
static QVariant lookUp(const T *const object, const QString &property);
};
template <typename T> struct TypeAccessor<T &> {
static QVariant lookUp(const T &object, const QString &property);
};
#endif
}
#endif
-111
View File
@@ -1,111 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_UTIL_P_H
#define GRANTLEE_UTIL_P_H
#include "context.h"
#include "grantlee_templates_export.h"
#include "safestring.h"
#include <QtCore/QVariant>
/// @file util.h Utility functions used throughout %Grantlee.
namespace Grantlee
{
/**
Returns whether the @p variant is evaluated to true.
@see @ref truthiness
*/
GRANTLEE_TEMPLATES_EXPORT bool variantIsTrue(const QVariant &variant);
/**
Converts the @p input into its unescaped form.
Double slashes are converted to single slashes, \\&quot is converted to &quot
etc.
*/
GRANTLEE_TEMPLATES_EXPORT QString unescapeStringLiteral(const QString &input);
/**
Marks the @p input as safe.
*/
GRANTLEE_TEMPLATES_EXPORT Grantlee::SafeString
markSafe(const Grantlee::SafeString &input);
/**
Marks the @p input as requiring escaping.
*/
GRANTLEE_TEMPLATES_EXPORT Grantlee::SafeString
markForEscaping(const Grantlee::SafeString &input);
/**
Retrieves and returns a SafeString from the @p input.
*/
GRANTLEE_TEMPLATES_EXPORT Grantlee::SafeString
getSafeString(const QVariant &input);
/**
Returns whether @p input contains a SafeString.
*/
GRANTLEE_TEMPLATES_EXPORT bool isSafeString(const QVariant &input);
/**
Returns true if the type of @p input can be inserted into a rendered template
directly.
Note that lists, hashes and QObject*s can not be.
*/
GRANTLEE_TEMPLATES_EXPORT bool supportedOutputType(const QVariant &input);
/**
Compares @p lhs and @p rhs for equality. SafeStrings are compared as raw
QStrings. Their safeness is not part of the comparison.
@see QVariant::operator==
*/
GRANTLEE_TEMPLATES_EXPORT bool equals(const QVariant &lhs, const QVariant &rhs);
/**
Converts @p size into the nearest file size unit like MB or MiB, based on the
@p unitSystem value. Use @c 2 for the @p unitSystem to get binary units, use
@c 10 to get decimal units - by default, decimal units will be returned. The
@p multiplier can be used if the input @p size is not in pure bytes. If @p
size is for example given in @a KiB, use a multiplier of @a 1024. The returned
pair will have the converted size as @a first and the unit as @a second.
*/
GRANTLEE_TEMPLATES_EXPORT std::pair<qreal, QString>
calcFileSize(qreal size, int unitSystem = 10, qreal multiplier = 1.0);
#ifndef Q_QDOC
/**
@internal
Returns the @p list as a formatted string. This is for debugging purposes
only.
*/
GRANTLEE_TEMPLATES_EXPORT Grantlee::SafeString
toString(const QVariantList &list);
#endif
}
#endif
-129
View File
@@ -1,129 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_VARIABLE_H
#define GRANTLEE_VARIABLE_H
#include "grantlee_templates_export.h"
#include <QtCore/QVariant>
namespace Grantlee
{
class Context;
class VariablePrivate;
/// @headerfile variable.h grantlee/variable.h
/**
@brief A container for static variables defined in Templates.
This class is only relevant to Template tag authors.
When processing a template tag in a AbstractNodeFactory implementation, it
will sometimes make sense to process arguments to the tag as
Grantlee::Variables. Note that usually they should be processed as
FilterExpression objects instead.
Arguments to the tag can be used to construct Variables, which may then be
resolved into the objects they represent in the given Context in the render
stage.
@author Stephen Kelly <steveire@gmail.com>
*/
class GRANTLEE_TEMPLATES_EXPORT Variable
{
public:
/**
Constructs an invalid **%Variable**
*/
Variable();
/**
Creates a **%Variable** represented by the given @p var
*/
explicit Variable(const QString &var);
/**
Copy constructor
*/
Variable(const Variable &other);
/**
Destructor
*/
~Variable();
/**
Assignment operator.
*/
Variable &operator=(const Variable &other);
/**
Returns whether this **%Variable** is valid.
*/
bool isValid() const;
/**
Returns whether this **%Variable** evaluates to true with the Context @p c.
*/
bool isTrue(Context *c) const;
/**
Resolves this **%Variable** with the Context @p c.
*/
QVariant resolve(Context *c) const;
/**
Returns whether this **%Variable** is a constant in the Template. A constant
is represented as a static string in the template
@code
Text content
{% some_tag "constant" variable %}
@endcode
*/
bool isConstant() const;
/**
Returns whether this variable is localized, that is, if it is wrapped with
_(). @see @ref i18n_l10n
*/
bool isLocalized() const;
/**
Returns whether this variable is a literal string or number. A
literal **%Variable** does not have any lookup components.
*/
QVariant literal() const;
/**
Returns the lookup components of this **%Variable**.
*/
QStringList lookups() const;
private:
Q_DECLARE_PRIVATE(Variable)
VariablePrivate *const d_ptr;
};
}
#endif
-47
View File
@@ -1,47 +0,0 @@
/*
This file is part of the Grantlee template system.
Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_TEMPLATES_H
#define GRANTLEE_TEMPLATES_H
#include "grantlee/abstractlocalizer.h"
#include "grantlee/cachingloaderdecorator.h"
#include "grantlee/context.h"
#include "grantlee/engine.h"
#include "grantlee/exception.h"
#include "grantlee/filter.h"
#include "grantlee/filterexpression.h"
#include "grantlee/grantlee_version.h"
#include "grantlee/metatype.h"
#include "grantlee/node.h"
#include "grantlee/outputstream.h"
#include "grantlee/parser.h"
#include "grantlee/qtlocalizer.h"
#include "grantlee/rendercontext.h"
#include "grantlee/safestring.h"
#include "grantlee/taglibraryinterface.h"
#include "grantlee/template.h"
#include "grantlee/templateloader.h"
#include "grantlee/token.h"
#include "grantlee/typeaccessor.h"
#include "grantlee/util.h"
#include "grantlee/variable.h"
#endif
-31
View File
@@ -1,31 +0,0 @@
/*
This file is part of Grantlee.
Copyright (c) 2011 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRANTLEE_TEXTDOCUMENT_H
#define GRANTLEE_TEXTDOCUMENT_H
#include "grantlee/abstractmarkupbuilder.h"
#include "grantlee/bbcodebuilder.h"
#include "grantlee/markupdirector.h"
#include "grantlee/mediawikimarkupbuilder.h"
#include "grantlee/plaintextmarkupbuilder.h"
#include "grantlee/texthtmlbuilder.h"
#endif
@@ -1,23 +0,0 @@
# Grantlee CMake configuration file - http://www.grantlee.org/
# Any changes in this file will be overwritten by CMake.
if (Grantlee5_FIND_COMPONENTS)
foreach( component ${Grantlee5_FIND_COMPONENTS})
if (component STREQUAL "Textdocument")
find_package(Qt6 REQUIRED Gui)
endif()
if (component STREQUAL "Templates")
find_package(Qt6 REQUIRED Core)
if ("" OR "0")
find_package(Qt6 REQUIRED Qml)
endif()
endif()
endforeach()
else()
find_package(Qt6Gui REQUIRED)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/GrantleeTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/GrantleeMacros.cmake")
@@ -1,23 +0,0 @@
# Grantlee CMake configuration file - http://www.grantlee.org/
# Any changes in this file will be overwritten by CMake.
if (Grantlee5_FIND_COMPONENTS)
foreach( component ${Grantlee5_FIND_COMPONENTS})
if (component STREQUAL "Textdocument")
find_package(Qt6 REQUIRED COMPONENTS Gui)
endif()
if (component STREQUAL "Templates")
find_package(Qt6 REQUIRED COMPONENTS Core)
if ("" OR "")
find_package(Qt6 REQUIRED COMPONENTS Qml)
endif()
endif()
endforeach()
else()
find_package(Qt5Gui REQUIRED)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/GrantleeTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/GrantleeMacros.cmake")
@@ -1,48 +0,0 @@
# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
# The variable CVF_VERSION must be set before calling configure_file().
set(PACKAGE_VERSION "5.3.0")
if (PACKAGE_FIND_VERSION_RANGE)
# Package version must be in the requested version range
if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
endif()
else()
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
set(PACKAGE_VERSION_COMPATIBLE TRUE)
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
set(PACKAGE_VERSION_EXACT TRUE)
endif()
endif()
endif()
# if the installed project requested no architecture check, don't perform the check
if("FALSE")
return()
endif()
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
return()
endif()
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
math(EXPR installedBits "8 * 8")
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()
@@ -1,19 +0,0 @@
include(CMakeParseArguments)
macro(grantlee_adjust_plugin_name pluginname)
set_target_properties(${pluginname}
PROPERTIES PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/grantlee/${Grantlee5_VERSION_MAJOR}.${Grantlee5_VERSION_MINOR}"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/grantlee/${Grantlee5_VERSION_MAJOR}.${Grantlee5_VERSION_MINOR}"
DEBUG_POSTFIX "d"
)
foreach(cfg ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${cfg} CFG)
set_target_properties(${pluginname}
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY_${CFG} "${CMAKE_BINARY_DIR}/grantlee/${Grantlee5_VERSION_MAJOR}.${Grantlee5_VERSION_MINOR}"
RUNTIME_OUTPUT_DIRECTORY_${CFG} "${CMAKE_BINARY_DIR}/grantlee/${Grantlee5_VERSION_MAJOR}.${Grantlee5_VERSION_MINOR}"
)
endforeach()
endmacro()
@@ -1,63 +0,0 @@
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Import target "Grantlee5::Templates" for configuration ""
set_property(TARGET Grantlee5::Templates APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
set_target_properties(Grantlee5::Templates PROPERTIES
IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/lib/libGrantlee_Templates.so.5.3.0"
IMPORTED_SONAME_NOCONFIG "libGrantlee_Templates.so.5"
)
list(APPEND _IMPORT_CHECK_TARGETS Grantlee5::Templates )
list(APPEND _IMPORT_CHECK_FILES_FOR_Grantlee5::Templates "${_IMPORT_PREFIX}/lib/libGrantlee_Templates.so.5.3.0" )
# Import target "Grantlee5::loadertags" for configuration ""
set_property(TARGET Grantlee5::loadertags APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
set_target_properties(Grantlee5::loadertags PROPERTIES
IMPORTED_COMMON_LANGUAGE_RUNTIME_NOCONFIG ""
IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/lib/grantlee/5.3/grantlee_loadertags.so"
IMPORTED_NO_SONAME_NOCONFIG "TRUE"
)
list(APPEND _IMPORT_CHECK_TARGETS Grantlee5::loadertags )
list(APPEND _IMPORT_CHECK_FILES_FOR_Grantlee5::loadertags "${_IMPORT_PREFIX}/lib/grantlee/5.3/grantlee_loadertags.so" )
# Import target "Grantlee5::defaulttags" for configuration ""
set_property(TARGET Grantlee5::defaulttags APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
set_target_properties(Grantlee5::defaulttags PROPERTIES
IMPORTED_COMMON_LANGUAGE_RUNTIME_NOCONFIG ""
IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/lib/grantlee/5.3/grantlee_defaulttags.so"
IMPORTED_NO_SONAME_NOCONFIG "TRUE"
)
list(APPEND _IMPORT_CHECK_TARGETS Grantlee5::defaulttags )
list(APPEND _IMPORT_CHECK_FILES_FOR_Grantlee5::defaulttags "${_IMPORT_PREFIX}/lib/grantlee/5.3/grantlee_defaulttags.so" )
# Import target "Grantlee5::defaultfilters" for configuration ""
set_property(TARGET Grantlee5::defaultfilters APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
set_target_properties(Grantlee5::defaultfilters PROPERTIES
IMPORTED_COMMON_LANGUAGE_RUNTIME_NOCONFIG ""
IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/lib/grantlee/5.3/grantlee_defaultfilters.so"
IMPORTED_NO_SONAME_NOCONFIG "TRUE"
)
list(APPEND _IMPORT_CHECK_TARGETS Grantlee5::defaultfilters )
list(APPEND _IMPORT_CHECK_FILES_FOR_Grantlee5::defaultfilters "${_IMPORT_PREFIX}/lib/grantlee/5.3/grantlee_defaultfilters.so" )
# Import target "Grantlee5::i18ntags" for configuration ""
set_property(TARGET Grantlee5::i18ntags APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
set_target_properties(Grantlee5::i18ntags PROPERTIES
IMPORTED_COMMON_LANGUAGE_RUNTIME_NOCONFIG ""
IMPORTED_LOCATION_NOCONFIG "${_IMPORT_PREFIX}/lib/grantlee/5.3/grantlee_i18ntags.so"
IMPORTED_NO_SONAME_NOCONFIG "TRUE"
)
list(APPEND _IMPORT_CHECK_TARGETS Grantlee5::i18ntags )
list(APPEND _IMPORT_CHECK_FILES_FOR_Grantlee5::i18ntags "${_IMPORT_PREFIX}/lib/grantlee/5.3/grantlee_i18ntags.so" )
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
@@ -1,112 +0,0 @@
# Generated by CMake
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6)
message(FATAL_ERROR "CMake >= 2.6.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 2.6...3.20)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------
# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)
# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_targetsDefined)
set(_targetsNotDefined)
set(_expectedTargets)
foreach(_expectedTarget Grantlee5::Templates Grantlee5::loadertags Grantlee5::defaulttags Grantlee5::defaultfilters Grantlee5::i18ntags)
list(APPEND _expectedTargets ${_expectedTarget})
if(NOT TARGET ${_expectedTarget})
list(APPEND _targetsNotDefined ${_expectedTarget})
endif()
if(TARGET ${_expectedTarget})
list(APPEND _targetsDefined ${_expectedTarget})
endif()
endforeach()
if("${_targetsDefined}" STREQUAL "${_expectedTargets}")
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
return()
endif()
if(NOT "${_targetsDefined}" STREQUAL "")
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n")
endif()
unset(_targetsDefined)
unset(_targetsNotDefined)
unset(_expectedTargets)
# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
set(_IMPORT_PREFIX "")
endif()
# Create imported target Grantlee5::Templates
add_library(Grantlee5::Templates SHARED IMPORTED)
set_target_properties(Grantlee5::Templates PROPERTIES
INTERFACE_COMPILE_FEATURES "cxx_override"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "Qt6::Core"
)
# Create imported target Grantlee5::loadertags
add_library(Grantlee5::loadertags MODULE IMPORTED)
# Create imported target Grantlee5::defaulttags
add_library(Grantlee5::defaulttags MODULE IMPORTED)
# Create imported target Grantlee5::defaultfilters
add_library(Grantlee5::defaultfilters MODULE IMPORTED)
# Create imported target Grantlee5::i18ntags
add_library(Grantlee5::i18ntags MODULE IMPORTED)
if(CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
endif()
# Load information for each installed configuration.
get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
file(GLOB CONFIG_FILES "${_DIR}/GrantleeTargets-*.cmake")
foreach(f ${CONFIG_FILES})
include(${f})
endforeach()
# Cleanup temporary variables.
set(_IMPORT_PREFIX)
# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
if(NOT EXISTS "${file}" )
message(FATAL_ERROR "The imported target \"${target}\" references the file
\"${file}\"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
\"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
endif()
endforeach()
unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)
# This file does not depend on other imported targets which have
# been exported from the same project but in a separate export set.
# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
libGrantlee_Templates.so.5
-1
View File
@@ -1 +0,0 @@
libGrantlee_Templates.so.5.3.0
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
libGrantlee_TextDocument.so.5
-1
View File
@@ -1 +0,0 @@
libGrantlee_TextDocument.so.5.3.0
Binary file not shown.
@@ -1,166 +0,0 @@
Verify the build-system integration of the already ported Qt6/KTextTemplate parser and ensure it correctly replaces the legacy Qt5/Grantlee5 parser behavior in the surrounding Qt5 → Qt6 migration.
## Scope
The parser port itself is already complete. This task is strictly about build integration verification and correction, with special focus on:
- original invocation logic in the Qt5 legacy build
- correct port of that invocation logic to the Qt6 build
- custom command / custom target wiring
- generated-file placement in the build tree
- downstream consumption of generated C++ files by Qt6 targets
- final Qt6 Docker build validation
- clean and incremental build correctness
## Paths to inspect
### Legacy Qt5 side
- `./qt-migration-legatus/qt5-before/qt5-legatus-legacy`
- `./qt-migration-legatus/qt5-before/qt5-legatus-legacy/Lts/Common/CodeGen`
### Qt6 migrated side
- `./qt-migration-legatus/qt6-after/qt6-migrated-legatus`
- `./qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/CodeGen`
### CMake / macro files
- `./qt-migration-legatus/qt5-before/qt5-legacy-legatus/cmake/MacroCodeGenIdl.cmake`
- `./qt-migration-legatus/qt6-after/qt6-migrated-legatus/cmake/MacroCodeGenIdl.cmake`
### Docker build entry
- `./app/Dockerfile`
### External dependencies
- `./external`
- especially ensure RTI `7.7.arcgis` from `./external` is mapped into the container correctly when needed
## Required investigation
### 1. Reconstruct the original Qt5 invocation logic
Analyze the legacy Qt5/Grantlee5 integration and determine:
- which CMake functions/macros trigger parser execution
- whether parser execution happens via `add_custom_command`, `add_custom_target`, helper macros, or another mechanism
- the exact dependency chain that causes parser execution
- when parser execution happens relative to target compilation
- which input files trigger regeneration
- which output files are declared or assumed
- how generated `.cpp` and header files are handed to downstream targets
- whether outputs are placed in source tree or build tree
- whether the original flow depends on implicit behavior that must now be made explicit
### 2. Verify the Qt6 port of that logic
Analyze the Qt6/KTextTemplate integration and verify whether the original invocation logic was ported correctly into:
`./qt-migration-legatus/qt6-after/qt6-migrated-legatus`
Check specifically:
- whether equivalent macro/function call sites exist
- whether the parser executable is invoked from the correct custom command or target
- whether invocation order matches the legacy build intent
- whether any function call logic was dropped, reordered, or incompletely migrated
- whether downstream Qt6 targets depend on generation strongly enough to avoid race/order issues
### 3. Check CMake generated-file semantics
Inspect and fix, where necessary:
- `add_custom_command(OUTPUT ...)`
- `BYPRODUCTS`
- `DEPENDS`
- `MAIN_DEPENDENCY`
- `WORKING_DIRECTORY`
- `COMMAND`
- `VERBATIM`
- `target_sources(...)`
- source properties such as `GENERATED`
- include directory wiring for generated headers
- target-level dependencies via `add_dependencies(...)`
- whether generated files are attached to the correct consuming target
- whether output paths use `${CMAKE_CURRENT_BINARY_DIR}` / build-tree locations instead of stale source-tree paths
### 4. Verify output placement
Confirm that generated files are emitted to the correct build-tree location expected by the Qt6 build.
Check for:
- stale Qt5-era output directories
- source-tree output instead of build-tree output
- mismatches between actual output location and `target_sources(...)` paths
- mismatches between parser CLI output arguments and CMake-declared outputs
- missing directory creation for generated output folders
### 5. Validate final Docker-based Qt6 builds
The final verification must execute the Qt6 build inside the Docker container defined by:
`./app/Dockerfile`
There are two required build variants and both must work:
- `BUILD_RTI=ON`
- `BUILD_RTI=OFF`
Validate both variants end-to-end:
- configure
- parser generation
- compilation
- generated-file discovery by consuming Qt6 targets
### 6. Validate external dependency mapping
External dependencies live in:
`./external`
Check and fix, if necessary:
- container mapping of `./external`
- availability of required external dependencies during configure/build
- especially correct container mapping and usability of RTI `7.7.arcgis`
- any CMake path assumptions related to mounted external dependencies
- whether `BUILD_RTI=ON` correctly picks up mapped RTI dependencies
- whether `BUILD_RTI=OFF` correctly avoids requiring RTI at configure/build time
### 7. Verify build correctness
Validate:
- clean build behavior
- incremental build behavior
- regeneration when input templates or related inputs change
- no missing dependency edges
- no accidental dependence on file timestamps outside declared CMake dependencies
- no ordering bugs hidden by already-generated files in developer workspaces
## Fixes to implement if issues are found
Implement minimal, reviewable fixes for:
- incorrect invocation timing
- incomplete migration of function/macro call logic
- missing `DEPENDS`, `BYPRODUCTS`, or `GENERATED` declarations
- incorrect output directories
- generated files not added to consuming targets
- generated headers not discoverable through include paths
- parser invocation not happening before compilation
- incremental rebuilds not retriggering generation when inputs change
- incorrect handling of `BUILD_RTI=ON` / `BUILD_RTI=OFF`
- incorrect external dependency mapping in Docker/container build flow
## Acceptance criteria
The task is complete only if all of the following are true:
1. The original Qt5 legacy parser invocation logic has been analyzed and reconstructed.
2. It has been verified whether that logic was ported correctly to the Qt6/KTextTemplate integration.
3. The Qt6 parser is invoked automatically at the correct stage of the build.
4. Generated `.cpp` files and related headers are emitted into the correct build-tree location.
5. Qt6 consuming targets reference the generated files from the actual generated paths.
6. The final Qt6 build is executed in the Docker environment defined by `./app/Dockerfile`.
7. Both build variants succeed:
- `BUILD_RTI=ON`
- `BUILD_RTI=OFF`
8. External dependencies from `./external` are handled correctly in the container build, especially RTI `7.7.arcgis`.
9. Relevant macro/CMake wiring is correct, explicit, and robust.
10. Clean and incremental builds behave correctly.
11. Any integration bugs found were fixed with minimal changes.
12. A concise final summary is provided covering:
- original Qt5 invocation flow
- Qt6 invocation flow
- whether the ported invocation logic matches
- output locations
- Docker validation results
- `BUILD_RTI=ON` result
- `BUILD_RTI=OFF` result
- external dependency mapping result
- files changed
- issues found and fixed
- remaining risks or assumptions
## Constraints
- Do not re-port parser functionality unless a very small parser-side change is strictly necessary for build integration.
- Focus on build-system correctness, invocation timing, generated-file registration, output placement, Docker validation, and RTI/non-RTI build behavior.
- Preserve already completed Qt6 migration work.
- Prefer explicit and deterministic CMake wiring over implicit behavior.
@@ -1,39 +0,0 @@
Implement a Qt6 replacement for the legacy Qt5/Grantlee5 CodeGen parser and integrate it into the Qt6 build flow.
Context:
- Legacy parser A (Qt5 + Grantlee5):
`./qt-migration-legatus/qt5-before/qt5-legatus-legacy/Lts/Common/CodeGen`
- Replacement parser B (Qt6 + KTextTemplate):
`./qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Common/CodeGen`
- Docker build entry:
`./app/Dockerfile`
- Relevant macros:
- `./qt-migration-legatus/qt5-before/qt5-legacy-legatus/cmake/MacroCodeGenIdl.cmake`
- `./qt-migration-legatus/qt6-after/qt6-migrated-legatus/cmake/MacroCodeGenIdl.cmake`
Goals:
1. Analyze how A is built and invoked in the Qt5 flow.
2. Make B build reproducibly via `./app/Dockerfile` with Qt6 + KTextTemplate.
3. Find all relevant `*grantlee*` input files and test B against all of them.
4. Fix/extend B only as needed to support real repository inputs.
5. Integrate B into the Qt6 codegen/build flow based on how A is invoked.
6. Update the relevant CMake/macro wiring.
7. Preserve existing Qt6 migration work.
Requirements:
- Use Docker for building B.
- Use Docker to create and remove folders/files
- Inspect real call sites before changing integration.
- Keep changes small and reviewable.
- Touch Qt5-side files only if needed for analysis/comparison/minimal build clarity.
- If Grantlee behavior cannot be matched exactly in KTextTemplate, implement the best practical transitional solution and document remaining gaps.
- `./qt-migration-legatus/qt5-before/qt5-legacy-legatus` is read-only
Done when:
- B builds successfully through `./app/Dockerfile`
- all relevant `*grantlee*` inputs were tested with B
- Qt6 build flow uses B instead of Grantlee5 dependency
- macro/CMake integration is updated
- remaining incompatibilities are documented
- provide a concise summary of changed files, test results, and open gaps
- commit and push in `./qt-migration-legatus/qt6-after/qt6-migrated-legatus` after user feedback