Conversation
Kybxd
commented
Jul 7, 2025
- close load(options): support both global-level and messager-level options #261
ReadFunc with LoadFunc, support messager-level LoadFuncReadFunc with LoadFunc, support messager-level LoadFuncs
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #264 +/- ##
==========================================
+ Coverage 71.28% 71.55% +0.26%
==========================================
Files 83 84 +1
Lines 10342 10408 +66
==========================================
+ Hits 7372 7447 +75
+ Misses 2404 2394 -10
- Partials 566 567 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
39c57f3 to
d8718ad
Compare
ReadFunc with LoadFunc, support messager-level LoadFuncsReadFunc with LoadFunc, support messager-level LoadFunc
ReadFunc with LoadFunc, support messager-level LoadFuncReadFunc with LoadFunc, support messager-level LoadFunc
ReadFunc with LoadFunc, support messager-level LoadFuncLoadFunc
| // Paths maps each messager name to a corresponding config file path. | ||
| // If specified, then the main messager will be parsed from the file | ||
| // directly, other than the specified load dir. | ||
| IgnoreUnknownFields *bool |
There was a problem hiding this comment.
Is it a good idea to use *bool to represent field presence? How about other programming languages, such as C++, C#, and TypeScript?
For example, tableau's C++ LoadOptions:
https://github.com/tableauio/loader/blob/7689f47671ae338338933970e251ac9c6ca31f5d/test/cpp-tableau-loader/src/protoconf/load.pc.h#L24-L42
There was a problem hiding this comment.
Use std::optional<bool> (C++17 and later) is a good solution.
Refer https://en.cppreference.com/w/cpp/utility/optional.html)
Example:
#include <optional>
class MyClass {
public:
std::optional<bool> flag;
void print() {
if (flag.has_value()) {
std::cout << "Flag is present and is " << (flag.value() ? "true" : "false") << "\n";
} else {
std::cout << "Flag is not present\n";
}
}
};There was a problem hiding this comment.
In C#, the idiomatic way to represent the presence of a bool field (i.e., whether it has a value or not) is to use a nullable bool, which is bool?.
Explanation
bool can be either true or false.
bool? (nullable bool) can be true, false, or null.
null represents the absence of a value (field not set).
Example
class MyClass
{
public bool? Flag { get; set; }
public void Print()
{
if (Flag.HasValue)
{
Console.WriteLine($"Flag is present and is {Flag.Value}");
}
else
{
Console.WriteLine("Flag is not present");
}
}
}Usage
var obj = new MyClass();
obj.Print(); // Output: Flag is not present
obj.Flag = true;
obj.Print(); // Output: Flag is present and is True
obj.Flag = false;
obj.Print(); // Output: Flag is present and is False
obj.Flag = null;
obj.Print(); // Output: Flag is not presentSummary
Use bool? (nullable bool) to represent a boolean field that may or may not be present.
null means "not present".
true or false means "present with that value".
This is the direct equivalent of C++'s std::optional<bool>.