Handles schema version upgrades for MaterialX protobuf documents.
More...
#include <materialx_serializer.h>
|
| static void | upgradeV0ToV1 (MaterialXDocument &pb_doc) |
| | Example upgrade from version 0.x to 1.x.
|
| |
| static void | upgradeV1ToV2 (MaterialXDocument &pb_doc) |
| | Example upgrade from version 1.x to 2.x.
|
| |
| static std::string | getVersionString (const MaterialXDocument &pb_doc) |
| | Get version as a string (e.g., "1.0.0")
|
| |
| static int | compareVersions (uint32_t v1_major, uint32_t v1_minor, uint32_t v1_patch, uint32_t v2_major, uint32_t v2_minor, uint32_t v2_patch) |
| | Compare two versions.
|
| |
Handles schema version upgrades for MaterialX protobuf documents.
- Add upgrade methods for each major version transition.
- Upgrade methods should modify the protobuf message in-place or return a new one.
◆ compareVersions()
| int VersionUpgrader::compareVersions |
( |
uint32_t | v1_major, |
|
|
uint32_t | v1_minor, |
|
|
uint32_t | v1_patch, |
|
|
uint32_t | v2_major, |
|
|
uint32_t | v2_minor, |
|
|
uint32_t | v2_patch ) |
|
static |
Compare two versions.
- Returns
- -1 if v1 < v2, 0 if equal, 1 if v1 > v2
351 {
352 if (v1_major != v2_major) {
353 return (v1_major < v2_major) ? -1 : 1;
354 }
355 if (v1_minor != v2_minor) {
356 return (v1_minor < v2_minor) ? -1 : 1;
357 }
358 if (v1_patch != v2_patch) {
359 return (v1_patch < v2_patch) ? -1 : 1;
360 }
361 return 0;
362}
◆ getVersionString()
| std::string VersionUpgrader::getVersionString |
( |
const MaterialXDocument & | pb_doc | ) |
|
|
static |
Get version as a string (e.g., "1.0.0")
- Parameters
-
- Returns
- Version string.
340 {
341 if (pb_doc.has_schema_version()) {
342 const Version& v = pb_doc.schema_version();
343 std::ostringstream oss;
344 oss << v.major() << "." << v.minor() << "." << v.patch();
345 return oss.str();
346 }
347 return "unknown";
348}
◆ upgradeV0ToV1()
| void VersionUpgrader::upgradeV0ToV1 |
( |
MaterialXDocument & | pb_doc | ) |
|
|
static |
Example upgrade from version 0.x to 1.x.
- Parameters
-
| pb_doc | The protobuf document to upgrade (modified in-place). |
◆ upgradeV1ToV2()
| void VersionUpgrader::upgradeV1ToV2 |
( |
MaterialXDocument & | pb_doc | ) |
|
|
static |
Example upgrade from version 1.x to 2.x.
- Parameters
-
| pb_doc | The protobuf document to upgrade (modified in-place). |
The documentation for this class was generated from the following files: