File indexing completed on 2026-04-09 07:49:18
0001 #include "SMeta.hh"
0002 #include "SPath.hh"
0003 #include "OPTICKS_LOG.hh"
0004
0005 void Populate(SMeta& sm )
0006 {
0007 double dval = 1.4124 ;
0008 const char* key = "key" ;
0009 std::string s = "string" ;
0010
0011 sm.js["red"] = "cyan" ;
0012 sm.js["green"] = "magenta" ;
0013 sm.js["blue"] = "yellow" ;
0014 sm.js["dval"] = dval ;
0015
0016 sm.js[key] = s ;
0017 }
0018
0019
0020 void test_1()
0021 {
0022 SMeta sm ;
0023 Populate(sm);
0024
0025 bool create_dirs = 1 ;
0026 const char* path = SPath::Resolve("$TMP", "SMetaTest.json", create_dirs );
0027 LOG(info) << path ;
0028 sm.save(path);
0029 std::cout << " sm " << std::endl << sm << std::endl ;
0030 SMeta* smp = SMeta::Load(path);
0031 std::cout << " smp " << std::endl << *smp << std::endl ;
0032 }
0033
0034
0035 void test_2()
0036 {
0037 SMeta sm ;
0038 Populate(sm);
0039
0040 int create_dirs = 1 ;
0041 const char* path = SPath::Resolve("$TMP/red/green/blue", "SMetaTest.json", create_dirs);
0042 LOG(info) << path ;
0043
0044 sm.save(path);
0045 std::cout << " sm " << std::endl << sm << std::endl ;
0046 SMeta* smp = SMeta::Load(path);
0047 std::cout << " smp " << std::endl << *smp << std::endl ;
0048 }
0049
0050
0051
0052
0053
0054 int main(int argc, char** argv)
0055 {
0056 OPTICKS_LOG(argc, argv);
0057 LOG(info) ;
0058
0059 test_2();
0060
0061 return 0 ;
0062 }