This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory-site.git

commit 91907238c3cf5604c4e3935edcffe20153142bdb
Author: chaokunyang <[email protected]>
AuthorDate: Fri Jun 12 08:36:33 2026 +0000

    🔄 synced local 'docs/guide/' with remote 'docs/guide/'
---
 docs/guide/cpp/basic-serialization.md | 61 +++++++++++++++++++++++++++++++++--
 docs/guide/cpp/schema-metadata.md     | 17 ++++++++--
 2 files changed, 74 insertions(+), 4 deletions(-)

diff --git a/docs/guide/cpp/basic-serialization.md 
b/docs/guide/cpp/basic-serialization.md
index 3a1647b3d5..b4f9c58934 100644
--- a/docs/guide/cpp/basic-serialization.md
+++ b/docs/guide/cpp/basic-serialization.md
@@ -210,6 +210,63 @@ public:
 };
 ```
 
+### Accessor Properties
+
+Use `FORY_PROPERTY` when the serialized field is exposed through accessor
+methods instead of a data member. This keeps the type registered as a normal
+struct type:
+
+```cpp
+struct AccountImpl {
+  int32_t id = 0;
+};
+
+class Account {
+public:
+  explicit Account(AccountImpl *impl) : impl_(impl) {}
+
+  const int32_t &id() const { return impl_->id; }
+  Account &id(int32_t value) {
+    impl_->id = value;
+    return *this;
+  }
+
+private:
+  AccountImpl *impl_ = nullptr;
+
+public:
+  FORY_STRUCT(Account, FORY_PROPERTY(id));
+};
+```
+
+`FORY_PROPERTY(id)` calls `obj.id()` to read the field and `obj.id(value)` to
+write it. The field type is inferred from the const getter return type with
+cv-qualifiers and references removed, so `const int32_t &` is treated as
+`int32_t`.
+
+Use the three-argument form when the getter and setter have different names:
+
+```cpp
+class User {
+public:
+  const int32_t &get_id() const;
+  void set_id(int32_t value);
+
+  FORY_STRUCT(User, FORY_PROPERTY(id, get_id, set_id));
+};
+```
+
+Field metadata can be attached as the final argument:
+
+```cpp
+FORY_STRUCT(Account, FORY_PROPERTY(id, fory::F().varint()));
+FORY_STRUCT(User, FORY_PROPERTY(id, get_id, set_id, fory::F(1).varint()));
+```
+
+When `FORY_STRUCT` is declared at namespace scope, the accessor methods must be
+public. For private PIMPL accessors or private data members, place
+`FORY_STRUCT` inside the class in a `public:` section.
+
 The macro:
 
 1. Generates compile-time field metadata
@@ -228,7 +285,7 @@ The macro:
 ## External / Third-Party Types
 
 When you cannot modify a third-party type, use `FORY_STRUCT` at namespace
-scope. This only works with **public** fields.
+scope. This only works with public data members or public accessor methods.
 
 ```cpp
 namespace thirdparty {
@@ -244,7 +301,7 @@ FORY_STRUCT(Foo, id, name);
 **Limitations:**
 
 - Must be declared at namespace scope in the same namespace as the type
-- Only public fields are supported
+- Only public data members or accessor methods are supported
 
 ## Inherited Fields
 
diff --git a/docs/guide/cpp/schema-metadata.md 
b/docs/guide/cpp/schema-metadata.md
index 9d1c55542b..fe455dd60c 100644
--- a/docs/guide/cpp/schema-metadata.md
+++ b/docs/guide/cpp/schema-metadata.md
@@ -20,8 +20,8 @@ license: |
 ---
 
 Field configuration is embedded directly in `FORY_STRUCT`. A field entry may be
-bare, or it may be a tuple containing the member name and a `fory::F(...)`
-builder:
+bare, it may be a tuple containing the member name and a `fory::F(...)`
+builder, or it may be a configured accessor property:
 
 ```cpp
 #include "fory/serialization/fory.h"
@@ -35,6 +35,18 @@ struct DataV2 {
 FORY_STRUCT(DataV2, id, (timestamp, fory::F().tagged()), version);
 ```
 
+Accessor properties use the same field metadata as data members:
+
+```cpp
+class Counter {
+public:
+  const uint32_t &value() const;
+  Counter &value(uint32_t value);
+
+  FORY_STRUCT(Counter, FORY_PROPERTY(value, fory::F().varint()));
+};
+```
+
 The configuration is compile-time metadata. It does not allocate codec objects
 or add virtual dispatch on the serialization path.
 
@@ -44,6 +56,7 @@ or add virtual dispatch on the serialization path.
 
 ```cpp
 FORY_STRUCT(DataV2, id, (timestamp, fory::F().tagged()), version);
+FORY_STRUCT(Counter, FORY_PROPERTY(value, fory::F().varint()));
 ```
 
 `fory::F(id)` uses explicit id-based field identity. IDs must be


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to