Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit b0f1b0b958b3c52a868256990d9936a84bc6e9cd @YasserAsmi committed Feb 18, 2014
Showing with 8,061 additions and 0 deletions.
  1. +45 −0 CMakeLists.txt
  2. +1,781 −0 Doxyfile
  3. +188 −0 DoxygenLayout.xml
  4. +93 −0 example/arrays.cpp
  5. +39 −0 example/basics.cpp
  6. +62 −0 example/func.cpp
  7. +83 −0 example/jsonparse.cpp
  8. +1 −0 example/jsontest/fail1.json
  9. +1 −0 example/jsontest/fail10.json
  10. +1 −0 example/jsontest/fail11.json
  11. +1 −0 example/jsontest/fail12.json
  12. +1 −0 example/jsontest/fail13.json
  13. +1 −0 example/jsontest/fail14.json
  14. +1 −0 example/jsontest/fail15.json
  15. +1 −0 example/jsontest/fail16.json
  16. +1 −0 example/jsontest/fail17.json
  17. +1 −0 example/jsontest/fail18.json
  18. +1 −0 example/jsontest/fail19.json
  19. +1 −0 example/jsontest/fail2.json
  20. +1 −0 example/jsontest/fail20.json
  21. +1 −0 example/jsontest/fail21.json
  22. +1 −0 example/jsontest/fail22.json
  23. +1 −0 example/jsontest/fail23.json
  24. +1 −0 example/jsontest/fail24.json
  25. +1 −0 example/jsontest/fail25.json
  26. +1 −0 example/jsontest/fail26.json
  27. +2 −0 example/jsontest/fail27.json
  28. +2 −0 example/jsontest/fail28.json
  29. +1 −0 example/jsontest/fail29.json
  30. +1 −0 example/jsontest/fail3.json
  31. +1 −0 example/jsontest/fail30.json
  32. +1 −0 example/jsontest/fail31.json
  33. +1 −0 example/jsontest/fail32.json
  34. +1 −0 example/jsontest/fail33.json
  35. +1 −0 example/jsontest/fail4.json
  36. +1 −0 example/jsontest/fail5.json
  37. +1 −0 example/jsontest/fail6.json
  38. +1 −0 example/jsontest/fail7.json
  39. +1 −0 example/jsontest/fail8.json
  40. +1 −0 example/jsontest/fail9.json
  41. +41 −0 example/jsontest/out/fail18.json
  42. +3 −0 example/jsontest/out/fail25.json
  43. +3 −0 example/jsontest/out/fail27.json
  44. +79 −0 example/jsontest/out/pass1.json
  45. +39 −0 example/jsontest/out/pass2.json
  46. +6 −0 example/jsontest/out/pass3.json
  47. +58 −0 example/jsontest/pass1.json
  48. +1 −0 example/jsontest/pass2.json
  49. +6 −0 example/jsontest/pass3.json
  50. +75 −0 example/misc.cpp
  51. +81 −0 example/objs.cpp
  52. +84 −0 example/printv.cpp
  53. +1,096 −0 include/arr.h
  54. +81 −0 include/json.h
  55. +13 −0 include/jvar.h
  56. +569 −0 include/str.h
  57. +198 −0 include/util.h
  58. +887 −0 include/var.h
  59. +6 −0 mainpage.dox
  60. +255 −0 src/arr.cpp
  61. +313 −0 src/json.cpp
  62. +508 −0 src/str.cpp
  63. +160 −0 src/util.cpp
  64. +1,173 −0 src/var.cpp
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 2.6)
+
+project(edge)
+
+include_directories("include/")
+link_directories("lib/")
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin/")
+set(LIBRARY_OUTPUT_PATH "lib/")
+
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall -Wextra -Wno-unused-parameter -Wno-variadic-macros")
+#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -Wall -Wextra -Wno-unused-parameter -Wno-variadic-macros")
+
+add_library(jvar STATIC base/str.cpp base/util.cpp base/arr.cpp base/var.cpp base/json.cpp)
+add_library(edgedb STATIC db/sql.cpp db/dm.cpp)
+
+add_executable(basetest test/basetest.cpp)
+target_link_libraries(basetest jvar -lrt)
+
+add_executable(parsetest test/parsetest.cpp)
+target_link_libraries(parsetest jvar -lrt)
+
+add_executable(sqltest test/sqltest.cpp)
+target_link_libraries(sqltest edgedb jvar -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -ldl)
+
+add_executable(ex_basics example/basics.cpp)
+target_link_libraries(ex_basics jvar -lrt)
+
+add_executable(ex_arrays example/arrays.cpp)
+target_link_libraries(ex_arrays jvar -lrt)
+
+add_executable(ex_objs example/objs.cpp)
+target_link_libraries(ex_objs jvar -lrt)
+
+add_executable(ex_printv example/printv.cpp)
+target_link_libraries(ex_printv jvar -lrt)
+
+add_executable(ex_jsonparse example/jsonparse.cpp)
+target_link_libraries(ex_jsonparse jvar -lrt)
+
+add_executable(ex_func example/func.cpp)
+target_link_libraries(ex_func jvar -lrt)
+
+add_executable(ex_misc example/misc.cpp)
+target_link_libraries(ex_misc jvar -lrt)
Oops, something went wrong.
@@ -0,0 +1,188 @@
+<doxygenlayout version="1.0">
+ <!-- Navigation index tabs for HTML output -->
+ <navindex>
+ <tab type="mainpage" visible="yes" title="About"/>
+ <tab type="pages" visible="yes" title="" intro=""/>
+ <tab type="modules" visible="yes" title="" intro=""/>
+ <tab type="namespaces" visible="yes" title="">
+ <tab type="namespacelist" visible="yes" title="" intro=""/>
+ <tab type="namespacemembers" visible="yes" title="" intro=""/>
+ </tab>
+ <tab type="classes" visible="yes" title="">
+ <tab type="classlist" visible="yes" title="" intro=""/>
+ <tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
+ <tab type="hierarchy" visible="yes" title="" intro=""/>
+ <tab type="classmembers" visible="yes" title="" intro=""/>
+ </tab>
+ <tab type="files" visible="yes" title="">
+ <tab type="filelist" visible="yes" title="" intro=""/>
+ <tab type="globals" visible="yes" title="" intro=""/>
+ </tab>
+ <tab type="dirs" visible="yes" title="" intro=""/>
+ <tab type="examples" visible="yes" title="" intro=""/>
+ </navindex>
+
+ <!-- Layout definition for a class page -->
+ <class>
+ <briefdescription visible="yes"/>
+ <detaileddescription title=""/>
+ <includes visible="$SHOW_INCLUDE_FILES"/>
+ <inheritancegraph visible="$CLASS_GRAPH"/>
+ <collaborationgraph visible="$COLLABORATION_GRAPH"/>
+ <!-- <allmemberslink visible="yes"/> -->
+ <memberdecl>
+ <nestedclasses visible="yes" title=""/>
+ <publictypes title=""/>
+ <publicslots title=""/>
+ <signals title=""/>
+ <publicmethods title=""/>
+ <publicstaticmethods title=""/>
+ <publicattributes title=""/>
+ <publicstaticattributes title=""/>
+ <protectedtypes title=""/>
+ <protectedslots title=""/>
+ <protectedmethods title=""/>
+ <protectedstaticmethods title=""/>
+ <protectedattributes title=""/>
+ <protectedstaticattributes title=""/>
+ <packagetypes title=""/>
+ <packagemethods title=""/>
+ <packagestaticmethods title=""/>
+ <packageattributes title=""/>
+ <packagestaticattributes title=""/>
+ <properties title=""/>
+ <events title=""/>
+ <privatetypes title=""/>
+ <privateslots title=""/>
+ <privatemethods title=""/>
+ <privatestaticmethods title=""/>
+ <privateattributes title=""/>
+ <privatestaticattributes title=""/>
+ <friends title=""/>
+ <related title="" subtitle=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <memberdef>
+ <inlineclasses title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <constructors title=""/>
+ <functions title=""/>
+ <related title=""/>
+ <variables title=""/>
+ <properties title=""/>
+ <events title=""/>
+ </memberdef>
+ <usedfiles visible="$SHOW_USED_FILES"/>
+ <authorsection visible="yes"/>
+ </class>
+
+ <!-- Layout definition for a namespace page -->
+ <namespace>
+ <briefdescription visible="yes"/>
+ <detaileddescription title=""/>
+ <memberdecl>
+ <nestednamespaces visible="yes" title=""/>
+ <classes visible="yes" title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <memberdef>
+ <inlineclasses title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ </memberdef>
+ <authorsection visible="yes"/>
+ </namespace>
+
+ <!-- Layout definition for a file page -->
+ <file>
+ <briefdescription visible="yes"/>
+ <detaileddescription title=""/>
+ <includes visible="$SHOW_INCLUDE_FILES"/>
+ <includegraph visible="$INCLUDE_GRAPH"/>
+ <includedbygraph visible="$INCLUDED_BY_GRAPH"/>
+ <sourcelink visible="yes"/>
+ <memberdecl>
+ <classes visible="yes" title=""/>
+ <namespaces visible="yes" title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <memberdef>
+ <inlineclasses title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ </memberdef>
+ <authorsection/>
+ </file>
+
+ <!-- Layout definition for a group page -->
+ <group>
+ <briefdescription visible="yes"/>
+ <detaileddescription title=""/>
+ <groupgraph visible="$GROUP_GRAPHS"/>
+ <memberdecl>
+ <classes visible="yes" title=""/>
+ <namespaces visible="yes" title=""/>
+ <dirs visible="yes" title=""/>
+ <nestedgroups visible="yes" title=""/>
+ <files visible="yes" title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <enumvalues title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <signals title=""/>
+ <publicslots title=""/>
+ <protectedslots title=""/>
+ <privateslots title=""/>
+ <events title=""/>
+ <properties title=""/>
+ <friends title=""/>
+ <membergroups visible="yes"/>
+ </memberdecl>
+ <memberdef>
+ <pagedocs/>
+ <inlineclasses title=""/>
+ <defines title=""/>
+ <typedefs title=""/>
+ <enums title=""/>
+ <enumvalues title=""/>
+ <functions title=""/>
+ <variables title=""/>
+ <signals title=""/>
+ <publicslots title=""/>
+ <protectedslots title=""/>
+ <privateslots title=""/>
+ <events title=""/>
+ <properties title=""/>
+ <friends title=""/>
+ </memberdef>
+ <authorsection visible="yes"/>
+ </group>
+
+ <!-- Layout definition for a directory page -->
+ <directory>
+ <briefdescription visible="yes"/>
+ <detaileddescription title=""/>
+ <directorygraph visible="yes"/>
+ <memberdecl>
+ <dirs visible="yes"/>
+ <files visible="yes"/>
+ </memberdecl>
+ </directory>
+</doxygenlayout>
@@ -0,0 +1,93 @@
+// Copyright (c) 2014 Yasser Asmi
+// Released under the MIT License (http://opensource.org/licenses/MIT)
+
+#include "jvar.h"
+
+using namespace jvar;
+
+/**
+ * \example arrays.cpp
+ */
+
+void showSimple()
+{
+ Variant arr;
+
+ // Create an array in this variant
+
+ arr.createArray();
+
+ // Push some items. You can also add using append() or insert()
+
+ arr.push(10);
+ arr.push(21);
+ arr.push(50);
+ arr.push(3022);
+ arr.push(44);
+
+ arr[1] = 234.00f;
+ arr[2] = "Hello world";
+
+ // Iterate over all of the array items (note: unusual syntax). One can also
+ // use length() and [] to iterate over the array.
+
+ for (Iter<Variant> i; arr.forEach(i); )
+ {
+ printf("%d %s\n", i.pos(), i->toString().c_str());
+ }
+
+ // pop() all elements from the array
+
+ Variant p;
+ while (!(p = arr.pop()).isNull())
+ {
+ printf("Pop %s\n", p.toString().c_str());
+ }
+}
+
+void showAltInit()
+{
+ Variant arr;
+
+ // Init an array using js style initializer syntax (string)
+
+ arr.createArray("[123, 23, 'can be string', 233.2, false, -20, -120]");
+
+ for (int i = 0; i < arr.length(); i++)
+ {
+ printf("%d %s\n", i, arr[i].toString().c_str());
+ }
+}
+
+void showArrOfArr()
+{
+ Variant arr;
+
+ // Arrays can contain any number of any types. Unlike JS, they cannot have holes, though
+ // the element can be of empty type. Arrays can be nested as well.
+
+ arr.createArray("[0, 'one', '2.0', 3, 'four']");
+
+ arr[3].createArray();
+ for (int i = 0; i < 4; i++)
+ {
+ arr[3].push(i);
+ }
+
+ arr[3][2].createArray("[999, 9999, 99999]");
+
+ // Print the entire array of array as string
+
+ printf("%s\n", arr.toString().c_str());
+
+ // Printed:
+ // [0,"one","2.0",[0,1,[999,9999,99999],3],"four"]
+
+}
+
+int main(int argc, char** argv)
+{
+ showSimple();
+ showAltInit();
+ showArrOfArr();
+}
@@ -0,0 +1,39 @@
+// Copyright (c) 2014 Yasser Asmi
+// Released under the MIT License (http://opensource.org/licenses/MIT)
+
+#include "jvar.h"
+
+using namespace jvar;
+
+/**
+ * \example basics.cpp
+ * Basic Variants -- You can declare a variable of type "Variant" and then assign
+ * any kind of data to it.<p>You can do conversions to different types and call
+ * operators.
+ */
+
+int main(int argc, char** argv)
+{
+ Variant v0;
+ Variant v1 = 23;
+ Variant v2;
+ Variant v3;
+
+ // Assign/modifie values
+ v0.format("-printf-style %s %p", argv[0], argv);
+
+ ++v1;
+ v2 = 553.2f;
+
+ v2 = (double)v2 * 2.0f;
+
+ // Concat
+ v3 = v1 + " Hello world ";
+ v3 += v2;
+ v3 += v0;
+
+ printf("%s\n", v3.toString().c_str());
+
+ // Printed:
+ // 24 Hello world 1106.4-printf-style ./ex_basics 0x7fff1f43d618
+}
Oops, something went wrong.

0 comments on commit b0f1b0b

Please sign in to comment.