Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ce87e04
chore: remove unused keys when processing index/ordered-index
Kybxd Mar 10, 2026
2535b76
feat: add new function NumLeveledContainers
Kybxd Mar 10, 2026
9398e28
refactor: set Depth and MapDepth to 0-based
Kybxd Mar 11, 2026
0224d8e
feat: Add Fruit5Conf support with indexing at the country level
Kybxd Mar 11, 2026
3c0e530
refactor: streamline map key collection logic in generator
Kybxd Mar 11, 2026
5d9aef5
refactor: update MapKey structure and streamline key collection in ge…
Kybxd Mar 11, 2026
3eb699f
refactor: remove unused map key checks and streamline index loading l…
Kybxd Mar 11, 2026
387e4b5
refactor: remove redundant key checks in index and ordered index gene…
Kybxd Mar 11, 2026
78affcf
improve: enhance comments with examples for LevelIndex key struct gen…
wenchy Mar 12, 2026
15fa91c
ci: add testing-go workflow and update init scripts
wenchy Mar 12, 2026
458c1e6
test: add test case for Fruit3Conf index structure and level message …
Kybxd Mar 12, 2026
4a69d75
ci: add testing-cpp workflow
wenchy Mar 12, 2026
c6c90db
refactor: standardize formatting in index test cases
Kybxd Mar 12, 2026
fbf35d2
ci: fix testing-cpp workflow - cmake version and working directory
wenchy Mar 12, 2026
5ebf5f1
ci: fix Windows init/gen scripts - use cmd /c to run .bat files in ba…
wenchy Mar 12, 2026
6c9cafc
ci: setup MSVC environment on Windows for NMake Makefiles
wenchy Mar 12, 2026
e86c7dc
ci: fix non-existent action versions v6 in testing-go.yml; use --para…
wenchy Mar 12, 2026
0ee1b76
refactor: remove unused configuration getters and streamline Messager…
Kybxd Mar 12, 2026
c22d64d
ci: fix cpp testing workflow for Windows compatibility
wenchy Mar 12, 2026
4ac9712
chore: update workflow actions
wenchy Mar 12, 2026
6eb147e
ci: remove redundant Ninja installation step on Windows
wenchy Mar 12, 2026
1466e1e
Improve C++ test workflow and build scripts
wenchy Mar 12, 2026
f19c07a
Refactor index descriptor tests for improved readability and structure
Kybxd Mar 12, 2026
bec0b66
refactor: optimize key collection logic in level message generation
Kybxd Mar 12, 2026
ae16348
refactor: clarify comments on LevelIndex key struct generation logic
Kybxd Mar 12, 2026
df38df9
fix: workflow
wenchy Mar 12, 2026
9b420fe
fix: workflow
wenchy Mar 12, 2026
a30d923
fix(protobuf): disable MSVC static runtime to fix RuntimeLibrary mism…
wenchy Mar 12, 2026
7636003
fix(windows): force dynamic CRT via CMAKE_MSVC_RUNTIME_LIBRARY to fix…
wenchy Mar 12, 2026
fbaf70d
fix(windows): use static CRT (/MTd) everywhere to match protobuf defa…
wenchy Mar 12, 2026
ce723ff
fix: use find_package CONFIG mode and disable ZLIB for robust cross-p…
wenchy Mar 12, 2026
14f417e
ci(windows): consolidate CMake and Ninja installation into single cho…
wenchy Mar 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/release-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.20.x"
go-version: "1.21.x"

- name: Download dependencies
run: |
Expand Down Expand Up @@ -59,4 +59,4 @@ jobs:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ steps.package.outputs.name }}
asset_name: ${{ steps.package.outputs.name }}
asset_content_type: application/gzip
asset_content_type: application/gzip
4 changes: 2 additions & 2 deletions .github/workflows/release-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: "1.20.x"
go-version: "1.21.x"

- name: Download dependencies
run: |
Expand Down Expand Up @@ -58,4 +58,4 @@ jobs:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ steps.package.outputs.name }}
asset_name: ${{ steps.package.outputs.name }}
asset_content_type: application/gzip
asset_content_type: application/gzip
72 changes: 72 additions & 0 deletions .github/workflows/testing-cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Testing C++

# Trigger on pushes, PRs (excluding documentation changes), and nightly.
on:
push:
branches: [master, main]
pull_request:
schedule:
- cron: 0 0 * * * # daily at 00:00
workflow_dispatch:

permissions:
contents: read

jobs:
test:
strategy:
matrix:
include:
- os: ubuntu-latest
gen_script: bash gen.sh
cmake_config: cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Debug
run_loader: ./bin/loader
- os: windows-latest
gen_script: cmd /c gen.bat
cmake_config: cmake -S . -B build -G "Ninja" -DCMAKE_BUILD_TYPE=Debug
run_loader: .\bin\loader.exe

runs-on: ${{ matrix.os }}
timeout-minutes: 30

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.21.x
cache: true

- name: Install dependencies (Ubuntu)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y cmake ninja-build

- name: Install dependencies (Windows)
if: runner.os == 'Windows'
run: choco install cmake ninja -y

- name: Setup MSVC (Windows)
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1

- name: Init submodules and build protobuf
shell: bash
run: bash init.sh

- name: Generate protoconf
working-directory: test/cpp-tableau-loader
run: ${{ matrix.gen_script }}

- name: CMake Configure
working-directory: test/cpp-tableau-loader
run: ${{ matrix.cmake_config }}

- name: CMake Build
working-directory: test/cpp-tableau-loader
run: cmake --build build --parallel

- name: Run loader
working-directory: test/cpp-tableau-loader
run: ${{ matrix.run_loader }}
64 changes: 64 additions & 0 deletions .github/workflows/testing-go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Testing Go

# Trigger on pushes, PRs (excluding documentation changes), and nightly.
on:
push:
branches: [master, main]
pull_request:
schedule:
- cron: 0 0 * * * # daily at 00:00
workflow_dispatch:

permissions:
contents: read

jobs:
test:
strategy:
matrix:
go-version: [1.21.x]
os: [ubuntu-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout Code
uses: actions/checkout@v6

- name: Install Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
cache: true

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
version: "23.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install protoc-gen-go
run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2

- name: Init Git submodules
run: git submodule update --init --recursive

- name: Generate protoconf
shell: bash
run: PROTOC=protoc bash test/go-tableau-loader/gen.sh

- name: Vet
run: go vet ./...

- name: Unittest
run: go test -v -timeout 30m -race ./... -coverprofile=coverage.txt -covermode=atomic

- name: Run loader
working-directory: test/go-tableau-loader
run: go run .

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: tableauio/loader
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ cmd/protoc-gen-go-tableau-loader/protoc-gen-go-tableau-loader

test/go-tableau-loader/go-tableau-loader
_lab/ts/src/protoconf
coverage.txt
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The official config loader for [Tableau](https://github.com/tableauio/tableau).
- C++17: `cmake -S . -B build`
- C++20: `cmake -S . -B build -DCMAKE_CXX_STANDARD=20`
- clang: `cmake -S . -B build -DCMAKE_CXX_COMPILER=clang++`
- Build: `cmake --build build -j16`
- Build: `cmake --build build --parallel`
- Run: `./bin/loader`

### Dev at Windows
Expand All @@ -44,7 +44,7 @@ The official config loader for [Tableau](https://github.com/tableauio/tableau).
- CMake:
- C++17: `cmake -S . -B build -G "NMake Makefiles"`
- C++20: `cmake -S . -B build -G "NMake Makefiles" -DCMAKE_CXX_STANDARD=20`
- Build: `cmake --build build`
- Build: `cmake --build build --parallel`
- Run: `.\bin\loader.exe`

### References
Expand All @@ -58,7 +58,7 @@ The official config loader for [Tableau](https://github.com/tableauio/tableau).
- Install protoc-gen-go: `go install google.golang.org/protobuf/cmd/protoc-gen-go@latest`
- Change dir: `cd test/go-tableau-loader`
- Generate protoconf: `bash ./gen.sh`
- Build: `go build`
- Run: `go run .`

### References

Expand Down
1 change: 1 addition & 0 deletions cmd/protoc-gen-cpp-tableau-loader/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ func ParseLeveledMapPrefix(md protoreflect.MessageDescriptor, mapFd protoreflect
type MapKey struct {
Type string
Name string
Fd protoreflect.FieldDescriptor // the map field descriptor this key belongs to
}

type MapKeySlice []MapKey
Expand Down
42 changes: 29 additions & 13 deletions cmd/protoc-gen-cpp-tableau-loader/indexes/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ type Generator struct {
message *protogen.Message

// level message
maxDepth int
keys helper.MapKeySlice
mapFds []protoreflect.FieldDescriptor
keys helper.MapKeySlice
}

func NewGenerator(g *protogen.GeneratedFile, descriptor *index.IndexDescriptor, message *protogen.Message) *Generator {
Expand All @@ -31,16 +29,18 @@ func NewGenerator(g *protogen.GeneratedFile, descriptor *index.IndexDescriptor,
}

func (x *Generator) initLevelMessage() {
for levelMessage := x.descriptor.LevelMessage; levelMessage != nil; levelMessage = levelMessage.NextLevel {
if fd := levelMessage.FD; fd != nil && fd.IsMap() {
for lm := x.descriptor.LevelMessage; lm != nil; lm = lm.NextLevel {
if fd := lm.FD; fd != nil && fd.IsMap() {
// Only collect map keys/fds when a deeper level has an index or ordered index,
// because these keys are used solely for building upper-level (leveled) containers.
if !lm.NextLevel.NeedGenAnyIndex() {
break
}
x.keys = x.keys.AddMapKey(helper.MapKey{
Type: helper.ParseMapKeyType(fd.MapKey()),
Name: helper.ParseMapFieldName(fd),
Fd: fd,
})
x.mapFds = append(x.mapFds, fd)
}
if len(levelMessage.Indexes) != 0 || len(levelMessage.OrderedIndexes) != 0 {
x.maxDepth = levelMessage.MapDepth
}
}
}
Expand Down Expand Up @@ -84,16 +84,32 @@ func (x *Generator) GenHppIndexFinders() {
if !x.NeedGenerate() {
return
}
for i := 1; i <= x.maxDepth-3 && i <= len(x.mapFds)-1; i++ {
if i == 1 {
// Generate LevelIndex key structs for intermediate map levels.
//
// x.keys holds one entry per map level whose next level still needs an
// index (populated by initLevelMessage). For a 3-level map keyed by
// (k1, k2, k3) with an index at the deepest level, x.keys = [k1, k2, k3].
//
// Level containers at depth 1 are keyed by a single scalar (k1), so no
// composite key struct is needed. Only depths ≥ 2 require a LevelIndex
// struct that bundles all ancestor keys up to that depth:
//
// keys = [k1, k2, k3] → struct for depth 2: {k1, k2}
// keys = [k1, k2, k3, k4] → struct for depth 2: {k1, k2}
// struct for depth 3: {k1, k2, k3}
//
// The loop starts at i=2 (depth 2) and creates a struct from keys[:i].
// It runs len(x.keys)-2 times (0 times when len ≤ 2).
for i := 2; i < len(x.keys); i++ {
if i == 2 {
x.g.P()
x.g.P(helper.Indent(1), "// LevelIndex keys.")
x.g.P(" public:")
}
fd := x.mapFds[i]
fd := x.keys[i-1].Fd
keyType := x.levelKeyType(fd)
x.g.P(helper.Indent(1), "struct ", keyType, " {")
keys := x.keys[:i+1]
keys := x.keys[:i]
for _, key := range keys {
x.g.P(helper.Indent(2), key.Type, " ", key.Name, ";")
}
Expand Down
Loading
Loading