A C++ DAL / ORM code generation framework
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.

198 lines
8.3 KiB

  1. //This is documentation, not code - the main page in doxygen output ..
  2. /*! \mainpage WORM - ORM framework
  3. *
  4. * \section intro_sec Introduction
  5. *
  6. * WORM is a Data Abstraction Layer for access to database servers and an
  7. * Object Relational Mapping system. It consists of libraries providing a
  8. * generic API for database access and database metadata mapping of schema
  9. * structure. On top of this there is a tool to generate C++ class files for a
  10. * given arbitrary database schema called "wormgen". wormgen accepts a few
  11. * arguments setting the database to use and optionally username, password,
  12. * output directory, etc. - "wormgen -h" shows usage. See below for more information.
  13. *
  14. * At this writing the framework only supports SQlite3 and MySQL databases.
  15. * and the default output supports Wt's (Web Toolkit http://webtoolkit.eu) Dbo
  16. * library. It generates header files that (with a little adjustment sometimes)
  17. * will work with Wt::Dbo for existing database schemata.
  18. *
  19. * The output is configurable using the WORM template system which uses
  20. * google's ctemplate for output templating.
  21. *
  22. * Additionally the libraries provide a general API for basic database access
  23. * including query execution with structured result sets and runtime metadata
  24. * including column information such as name, data type, defaults, extras, etc.
  25. *
  26. * NOTE: This API is not fully stable! I expect there to be some changes and
  27. * do not yet recommend building off the API for anything serious. wormgen
  28. * is functional (if simple) and changes there should not cause problems but
  29. * the libraries are under heavy development. There may be modifications
  30. * and these should be expected until this message is removed.
  31. * You have been warned :).
  32. *
  33. * \section install_sec Installation
  34. *
  35. * \subsection step1 Step 1: Requirements
  36. * NOTE: THIS IS UNTESTED ON WINDOWS or MAC AND NOT LIKELY TO WORK CURRENTLY..
  37. * linux or Unices should be ok.
  38. *
  39. * \li cmake, make, gcc, libstdc++, stl
  40. * \li Boost - basic, header only (algorithm/string, lexical_cast)
  41. * \li SQlite3 libraries - you may comment out the sqlite driver in src/CMakeLists.txt
  42. * if you don't want SQlite3 support
  43. * \li libmysqlclient - same applies, you may comment this out
  44. * \li ctemplate 1.0; libctemplate (currently the no threads version - this can be changed in the cmake files)
  45. *
  46. * \subsection step2 Step 2: Obtaining the sources
  47. * Using git(1) clone the repository thus:
  48. *\code
  49. * git clone https://github.com/erikwinn/worm.git worm
  50. * \endcode
  51. * This will create a sources directory called "worm" - alternately you can
  52. * download a tarball and unpack it.
  53. *
  54. * \subsection step3 Step 3: Building
  55. * \code
  56. * cd worm/build
  57. * cmake ../
  58. * make
  59. * \endcode
  60. * This will build the libraries and wormgen in ./build/src. By default the static
  61. * library is built - uncomment the shared library in src/CMakeLists.txt and
  62. * comment out the static library to change this (todo: add a configure script ..)
  63. *
  64. * libraries: libworm.so libworm.a
  65. * binary: wormgen
  66. *
  67. * Installation(optional):
  68. * \code
  69. * make install
  70. * ldconfig
  71. * \endcode
  72. *
  73. * This will install the libraries to /usr/local/lib/libworm.* and the
  74. * binary to /usr/local/bin/wormgen. Code generation templates will
  75. * be installed to /usr/local/share/worm/
  76. *
  77. \note You can also use wormgen without installing by doing something like this if
  78. it was built with the shared libraries:
  79. (use a full path to work outside this directory):
  80. * \code
  81. export LD_LIBRARY_PATH=./build/src
  82. ./build/src/wormgen -h
  83. * \endcode
  84. *
  85. * Uninstall:
  86. * \code
  87. * rm /usr/local/bin/wormgen
  88. * rm /usr/local/lib/libworm*
  89. * rm -rf /usr/local/share/worm
  90. * \endcode
  91. * Alternately you can do:
  92. * \code
  93. * cat install_manifest.txt | xargs rm
  94. * \endcode
  95. *
  96. * \note You can also use wormgen \em without installing by doing something like this if
  97. * it was built with the shared libraries:
  98. * (use a full path to work outside this directory):
  99. * \code
  100. * export LD_LIBRARY_PATH=./build/src
  101. * ./build/src/wormgen
  102. * \endcode
  103. *
  104. * \section usage Using WORM
  105. * \subsection codegen Generating code:
  106. * wormgen Usage:
  107. * \code
  108. * wormgen -h
  109. * \endcode
  110. * gives a description of the available options.
  111. *
  112. * The database (-d) argument is the only required argument - you must have
  113. * a database already set up and access to it. By default it assumes the username
  114. * is root with no password - for an SQlite3 database pass the filename as the
  115. * argument for -d database; for example, from within the source directory you can
  116. * generate files from the sample Sqlite3 database thus:
  117. *
  118. * \code
  119. * wormgen -D sqlite -d ./examples/blog.db
  120. * \endcode
  121. *
  122. * This will generate files in the current directory - to specify a different output
  123. * directory use -o /path/to/output, for example:
  124. *
  125. * \code
  126. * wormgen -D sqlite -d ./examples/blog.db -o /tmp
  127. * \endcode
  128. *
  129. * will place the generated files under /tmp
  130. *
  131. * Other commandline arguments include:
  132. * -D driver ([default]mysql or sqlite)
  133. * -t template directory (default /usr/local/share/worm/ or ./src/orm/templates)
  134. * -u username
  135. * -p password
  136. * -h help - use this to see all the arguments ..
  137. *
  138. * \subsection customizing Customizing the output
  139. * The output can be configured by editing or creating new template files
  140. * in the template directory - any files in this directory named with the extension
  141. * ".tpl" are assumed to be templates to use. Note that there is a naming convention
  142. * for each type of template - see the list of supported template types below.
  143. *
  144. * The default template directory is /usr/local/share/worm - the option [-t DIRECTORY]
  145. * will tell wormgen to look in DIRECTORY for templates, eg:
  146. * \code
  147. * wormgen -D sqlite -d ./examples/blog.db -o /tmp -t $HOME/my_worm_templates/
  148. * \endcode
  149. * This means that you can copy the default template to my_worm_templates/ and
  150. * experiment with it or create other templates. Each template must have a filename
  151. * like the one of the ones listed below - the filename will tell wormgen what kind of
  152. * template it is and how to name the output files for that template.
  153. *
  154. * These are the currently supported template types:
  155. *
  156. * \li base class header - generates FooBase.h:<br>
  157. * ClassDeclarationBase, //class_declaration_base.tpl
  158. * \li base class source - generates FooBase.cpp:<br>
  159. * ClassDefinitionBase, //class_definition_base.tpl
  160. * \li class header - generates Foo.h:<br>
  161. * ClassDeclaration, //class_declaration.tpl
  162. * \li class source - generates Foo.cpp:<br>
  163. * ClassDefinition, //class_definition.tpl
  164. *
  165. * Database and class naming conventions:
  166. * A table in the database should be named in lowercase with underscores
  167. * for best results (Note: this is optional but will avoid naming conflicts - wormgen
  168. * will still generate files for camel case naming schema). Ex: some_persons will
  169. * be transformed to a class SomePerson. Columns like first_name will transform
  170. * to firstName. Underscores for private variables, accessors, etc can be established
  171. * in the templates. Table names should be plural and will be transformed to singular.
  172. *
  173. * Templates:
  174. * The templates use ctemplate and currently support only the tags in the default
  175. * template (which generates Wt::Dbo object headers). A decent introduction to
  176. * ctemplate syntax is available at the ctemplate website. The supported tags are
  177. * quite simple and self-explanatory - see the default template for more.
  178. *
  179. * \section library Using the library
  180. *
  181. * Note that the library API is still unstable and may change.
  182. *
  183. * wormgen.cpp itself is quite simple and provides a quick example of using the
  184. * library - additionally, WormClassGenerator shows usage of the metadata
  185. * aspects of the library. libworm can also be used for basic database access, queries
  186. * and generic result sets - but it is currently intended primarily for the ORM
  187. * generator. The library does not support transactions, and all results are cached
  188. * locally in one call.
  189. *
  190. * There are also some small example programs under examples/ - I recommend
  191. * starting with these. Also, the library code is heavily commented -and there is
  192. * HTML documentation under doc/html. Until the API is stablized and "real"
  193. * documentation written the best course is experimentation and "reading the
  194. * source, Luke!" - the DAL functions available are documented in comments but
  195. * not yet stable so your mileage may vary.
  196. *
  197. */