| 1 |
program state_roundtrip_demo |
| 2 |
use fgof_state, only : clear_state_options, load_state_text, remove_state_document, save_state_text |
| 3 |
use fgof_state_types, only : state_document, state_options, state_text_result |
| 4 |
implicit none |
| 5 |
|
| 6 |
type(state_options) :: options |
| 7 |
type(state_document) :: document |
| 8 |
type(state_text_result) :: load_result |
| 9 |
|
| 10 |
options = clear_state_options() |
| 11 |
options%root_dir = "build/example-state-roundtrip" |
| 12 |
options%namespace = "demo-app" |
| 13 |
options%scope = "workspace" |
| 14 |
|
| 15 |
document = save_state_text("settings.json", "ready", options, version=2) |
| 16 |
if (document%error_code /= 0) error stop "save failed in roundtrip demo" |
| 17 |
|
| 18 |
load_result = load_state_text("settings.json", options, expected_version=2) |
| 19 |
if (load_result%error_code /= 0) error stop "load failed in roundtrip demo" |
| 20 |
|
| 21 |
print "(a)", trim(load_result%text) |
| 22 |
|
| 23 |
document = remove_state_document("settings.json", options) |
| 24 |
if (document%error_code /= 0) error stop "cleanup failed in roundtrip demo" |
| 25 |
end program state_roundtrip_demo |
| 26 |
|