mirror of
https://github.com/logos-co/logos-package.git
synced 2026-08-27 10:11:10 +00:00
add getter for manifest json (#12)
* add getter for manifest json * Initial plan * docs: add lgx_get_manifest_json to C API reference Co-authored-by: iurimatias <176720+iurimatias@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: iurimatias <176720+iurimatias@users.noreply.github.com> Co-authored-by: Iuri Matias <iuri.matias@gmail.com>
This commit is contained in:
co-authored by
iurimatias
copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Iuri Matias
parent
45a666c44b
commit
9fefc4d166
@@ -234,6 +234,7 @@ The header file `src/lgx.h` is installed to `include/` when using `make install`
|
||||
- `lgx_set_version(pkg, version) → lgx_result_t` - Set package version
|
||||
- `lgx_get_description(pkg) → const char*` - Get package description (owned by library)
|
||||
- `lgx_set_description(pkg, description)` - Set package description
|
||||
- `lgx_get_manifest_json(pkg) → const char*` - Get the full manifest as a JSON string (owned by library)
|
||||
|
||||
**Memory Management:**
|
||||
- `lgx_free_package(pkg)` - Free a package handle
|
||||
|
||||
@@ -184,12 +184,20 @@ LGX_EXPORT const char* lgx_get_description(lgx_package_t pkg);
|
||||
|
||||
/**
|
||||
* Set the package description in manifest.
|
||||
*
|
||||
*
|
||||
* @param pkg Package handle
|
||||
* @param description New description string
|
||||
*/
|
||||
LGX_EXPORT void lgx_set_description(lgx_package_t pkg, const char* description);
|
||||
|
||||
/**
|
||||
* Get the full manifest as a JSON string.
|
||||
*
|
||||
* @param pkg Package handle
|
||||
* @return JSON string of the manifest, owned by library (valid until package is freed)
|
||||
*/
|
||||
LGX_EXPORT const char* lgx_get_manifest_json(lgx_package_t pkg);
|
||||
|
||||
/* Memory management */
|
||||
|
||||
/**
|
||||
|
||||
+12
@@ -68,6 +68,7 @@ struct lgx_package_opaque {
|
||||
std::string name_cache;
|
||||
std::string version_cache;
|
||||
std::string description_cache;
|
||||
std::string manifest_json_cache;
|
||||
};
|
||||
|
||||
/* Package creation and loading */
|
||||
@@ -279,6 +280,17 @@ LGX_EXPORT void lgx_set_description(lgx_package_t pkg, const char* description)
|
||||
pkg->pkg->getManifest().description = description;
|
||||
}
|
||||
|
||||
LGX_EXPORT const char* lgx_get_manifest_json(lgx_package_t pkg) {
|
||||
if (!pkg) {
|
||||
set_error("Invalid argument: pkg cannot be NULL");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
clear_error();
|
||||
pkg->manifest_json_cache = pkg->pkg->getManifest().toJson();
|
||||
return pkg->manifest_json_cache.c_str();
|
||||
}
|
||||
|
||||
/* Memory management */
|
||||
|
||||
LGX_EXPORT void lgx_free_package(lgx_package_t pkg) {
|
||||
|
||||
Reference in New Issue
Block a user