ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

40 lines
719 B

  1. #include "json.h"
  2. #include <iostream>
  3. #include <fstream>
  4. int main(int argc,char **argv)
  5. {
  6. using namespace cppcms;
  7. if(argc!=3)
  8. return 1;
  9. std::ifstream in(argv[2]);
  10. if(!in)
  11. return 1;
  12. json::value v;
  13. if(!v.load(in,true))
  14. return 1;
  15. std::string path=argv[1];
  16. try {
  17. std::cout<<v.get<double>(path);
  18. return 0;
  19. }
  20. catch(json::bad_value_cast const &e) {}
  21. try {
  22. std::cout<<v.get<std::string>(path);
  23. return 0;
  24. }
  25. catch(json::bad_value_cast const &e) {}
  26. try {
  27. std::vector<std::string> vs=v.get<std::vector<std::string> >(path);
  28. std::string sep="";
  29. for(unsigned i=0;i<vs.size();i++) {
  30. std::cout<<sep<<vs[i];
  31. sep=" ";
  32. }
  33. return 0;
  34. }
  35. catch(json::bad_value_cast const &e) {}
  36. return 1;
  37. }