lib.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. ====================
  2. Nim Standard Library
  3. ====================
  4. :Author: Andreas Rumpf
  5. :Version: |nimversion|
  6. .. contents::
  7. "The good thing about reinventing the wheel is that you can get a round one."
  8. Though the Nim Standard Library is still evolving, it is already quite
  9. usable. It is divided into *pure libraries*, *impure libraries* and *wrappers*.
  10. Pure libraries do not depend on any external ``*.dll`` or ``lib*.so`` binary
  11. while impure libraries do. A wrapper is an impure library that is a very
  12. low-level interface to a C library.
  13. Read this `document <apis.html>`_ for a quick overview of the API design.
  14. The `bottom <#nimble>`_ of this page includes a list of 3rd party packages
  15. created by the Nim community. These packages are a useful addition to the
  16. modules in the standard library.
  17. Pure libraries
  18. ==============
  19. Core
  20. ----
  21. * `system <system.html>`_
  22. Basic procs and operators that every program needs. It also provides IO
  23. facilities for reading and writing text and binary files. It is imported
  24. implicitly by the compiler. Do not import it directly. It relies on compiler
  25. magic to work.
  26. * `threads <threads.html>`_
  27. Nim thread support. **Note**: This is part of the system module. Do not
  28. import it explicitly.
  29. * `channels <channels.html>`_
  30. Nim message passing support for threads. **Note**: This is part of the
  31. system module. Do not import it explicitly.
  32. * `locks <locks.html>`_
  33. Locks and condition variables for Nim.
  34. * `rlocks <rlocks.html>`_
  35. Reentrant locks for Nim.
  36. * `macros <macros.html>`_
  37. Contains the AST API and documentation of Nim for writing macros.
  38. * `typeinfo <typeinfo.html>`_
  39. Provides (unsafe) access to Nim's run time type information.
  40. * `typetraits <typetraits.html>`_
  41. This module defines compile-time reflection procs for working with types.
  42. * `threadpool <threadpool.html>`_
  43. Implements Nim's `spawn <manual.html#spawn>`_.
  44. * `cpuinfo <cpuinfo.html>`_
  45. This module implements procs to determine the number of CPUs / cores.
  46. Collections and algorithms
  47. --------------------------
  48. * `algorithm <algorithm.html>`_
  49. Implements some common generic algorithms like sort or binary search.
  50. * `tables <tables.html>`_
  51. Nim hash table support. Contains tables, ordered tables and count tables.
  52. * `sets <sets.html>`_
  53. Nim hash and bit set support.
  54. * `lists <lists.html>`_
  55. Nim linked list support. Contains singly and doubly linked lists and
  56. circular lists ("rings").
  57. * `deques <deques.html>`_
  58. Implementation of a double-ended queue.
  59. The underlying implementation uses a ``seq``.
  60. * `intsets <intsets.html>`_
  61. Efficient implementation of a set of ints as a sparse bit set.
  62. * `critbits <critbits.html>`_
  63. This module implements a *crit bit tree* which is an efficient
  64. container for a sorted set of strings, or for a sorted mapping of strings.
  65. * `sequtils <sequtils.html>`_
  66. This module implements operations for the built-in seq type
  67. which were inspired by functional programming languages.
  68. String handling
  69. ---------------
  70. * `strutils <strutils.html>`_
  71. This module contains common string handling operations like changing
  72. case of a string, splitting a string into substrings, searching for
  73. substrings, replacing substrings.
  74. * `strmisc <strmisc.html>`_
  75. This module contains uncommon string handling operations that do not
  76. fit with the commonly used operations in strutils.
  77. * `parseutils <parseutils.html>`_
  78. This module contains helpers for parsing tokens, numbers, identifiers, etc.
  79. * `strscans <strscans.html>`_
  80. This module contains a ``scanf`` macro for convenient parsing of mini languages.
  81. * `strtabs <strtabs.html>`_
  82. The ``strtabs`` module implements an efficient hash table that is a mapping
  83. from strings to strings. Supports a case-sensitive, case-insensitive and
  84. style-insensitive mode. An efficient string substitution operator ``%``
  85. for the string table is also provided.
  86. * `unicode <unicode.html>`_
  87. This module provides support to handle the Unicode UTF-8 encoding.
  88. * `encodings <encodings.html>`_
  89. Converts between different character encodings. On UNIX, this uses
  90. the ``iconv`` library, on Windows the Windows API.
  91. * `pegs <pegs.html>`_
  92. This module contains procedures and operators for handling PEGs.
  93. * `ropes <ropes.html>`_
  94. This module contains support for a *rope* data type.
  95. Ropes can represent very long strings efficiently; especially concatenation
  96. is done in O(1) instead of O(n).
  97. * `matchers <matchers.html>`_
  98. This module contains various string matchers for email addresses, etc.
  99. * `subexes <subexes.html>`_
  100. This module implements advanced string substitution operations.
  101. Generic Operating System Services
  102. ---------------------------------
  103. * `os <os.html>`_
  104. Basic operating system facilities like retrieving environment variables,
  105. reading command line arguments, working with directories, running shell
  106. commands, etc.
  107. * `osproc <osproc.html>`_
  108. Module for process communication beyond ``os.execShellCmd``.
  109. * `times <times.html>`_
  110. The ``times`` module contains basic support for working with time.
  111. * `dynlib <dynlib.html>`_
  112. This module implements the ability to access symbols from shared libraries.
  113. * `streams <streams.html>`_
  114. This module provides a stream interface and two implementations thereof:
  115. the `FileStream` and the `StringStream` which implement the stream
  116. interface for Nim file objects (`File`) and strings. Other modules
  117. may provide other implementations for this standard stream interface.
  118. * `marshal <marshal.html>`_
  119. Contains procs for serialization and deseralization of arbitrary Nim
  120. data structures.
  121. * `terminal <terminal.html>`_
  122. This module contains a few procedures to control the *terminal*
  123. (also called *console*). The implementation simply uses ANSI escape
  124. sequences and does not depend on any other module.
  125. * `memfiles <memfiles.html>`_
  126. This module provides support for memory mapped files (Posix's ``mmap``)
  127. on the different operating systems.
  128. * `fsmonitor <fsmonitor.html>`_
  129. This module implements the ability to monitor a directory/file for changes
  130. using Posix's inotify API.
  131. **Warning:** This module will likely be moved out to a Nimble package soon.
  132. * `asyncfile <asyncfile.html>`_
  133. This module implements asynchronous file reading and writing using
  134. ``asyncdispatch``.
  135. Math libraries
  136. --------------
  137. * `math <math.html>`_
  138. Mathematical operations like cosine, square root.
  139. * `complex <complex.html>`_
  140. This module implements complex numbers and their mathematical operations.
  141. * `rationals <rationals.html>`_
  142. This module implements rational numbers and their mathematical operations.
  143. * `fenv <fenv.html>`_
  144. Floating-point environment. Handling of floating-point rounding and
  145. exceptions (overflow, zero-devide, etc.).
  146. * `basic2d <basic2d.html>`_
  147. Basic 2d support with vectors, points, matrices and some basic utilities.
  148. * `basic3d <basic3d.html>`_
  149. Basic 3d support with vectors, points, matrices and some basic utilities.
  150. * `mersenne <mersenne.html>`_
  151. Mersenne twister random number generator.
  152. * `random <random.html>`_
  153. Fast and tiny random number generator.
  154. * `stats <stats.html>`_
  155. Statistical analysis
  156. Internet Protocols and Support
  157. ------------------------------
  158. * `cgi <cgi.html>`_
  159. This module implements helpers for CGI applications.
  160. * `scgi <scgi.html>`_
  161. This module implements helpers for SCGI applications.
  162. * `browsers <browsers.html>`_
  163. This module implements procs for opening URLs with the user's default
  164. browser.
  165. * `httpserver <httpserver.html>`_
  166. This module implements a simple HTTP server.
  167. * `httpclient <httpclient.html>`_
  168. This module implements a simple HTTP client which supports both synchronous
  169. and asynchronous retrieval of web pages.
  170. * `smtp <smtp.html>`_
  171. This module implement a simple SMTP client.
  172. * `cookies <cookies.html>`_
  173. This module contains helper procs for parsing and generating cookies.
  174. * `mimetypes <mimetypes.html>`_
  175. This module implements a mimetypes database.
  176. * `uri <uri.html>`_
  177. This module provides functions for working with URIs.
  178. * `asyncdispatch <asyncdispatch.html>`_
  179. This module implements an asynchronous dispatcher for IO operations.
  180. * `asyncnet <asyncnet.html>`_
  181. This module implements asynchronous sockets based on the ``asyncdispatch``
  182. module.
  183. * `asynchttpserver <asynchttpserver.html>`_
  184. This module implements an asynchronous HTTP server using the ``asyncnet``
  185. module.
  186. * `asyncftpclient <asyncftpclient.html>`_
  187. This module implements an asynchronous FTP client using the ``asyncnet``
  188. module.
  189. * `net <net.html>`_
  190. This module implements a high-level sockets API. It will replace the
  191. ``sockets`` module in the future.
  192. * `nativesockets <nativesockets.html>`_
  193. This module implements a low-level sockets API.
  194. * `selectors <selectors.html>`_
  195. This module implements a selector API with backends specific to each OS.
  196. Currently epoll on Linux and select on other operating systems.
  197. Parsers
  198. -------
  199. * `parseopt <parseopt.html>`_
  200. The ``parseopt`` module implements a command line option parser.
  201. * `parseopt2 <parseopt2.html>`_
  202. The ``parseopt2`` module implements a command line option parser. This
  203. supports long and short command options with optional values and command line
  204. arguments.
  205. * `parsecfg <parsecfg.html>`_
  206. The ``parsecfg`` module implements a high performance configuration file
  207. parser. The configuration file's syntax is similar to the Windows ``.ini``
  208. format, but much more powerful, as it is not a line based parser. String
  209. literals, raw string literals and triple quote string literals are supported
  210. as in the Nim programming language.
  211. * `parsexml <parsexml.html>`_
  212. The ``parsexml`` module implements a simple high performance XML/HTML parser.
  213. The only encoding that is supported is UTF-8. The parser has been designed
  214. to be somewhat error correcting, so that even some "wild HTML" found on the
  215. Web can be parsed with it.
  216. * `parsecsv <parsecsv.html>`_
  217. The ``parsecsv`` module implements a simple high performance CSV parser.
  218. * `parsesql <parsesql.html>`_
  219. The ``parsesql`` module implements a simple high performance SQL parser.
  220. * `json <json.html>`_
  221. High performance JSON parser.
  222. * `lexbase <lexbase.html>`_
  223. This is a low level module that implements an extremely efficient buffering
  224. scheme for lexers and parsers. This is used by the diverse parsing modules.
  225. * `highlite <highlite.html>`_
  226. Source highlighter for programming or markup languages. Currently
  227. only few languages are supported, other languages may be added.
  228. The interface supports one language nested in another.
  229. * `rst <rst.html>`_
  230. This module implements a reStructuredText parser. A large subset
  231. is implemented. Some features of the markdown wiki syntax are
  232. also supported.
  233. * `rstast <rstast.html>`_
  234. This module implements an AST for the reStructuredText parser.
  235. * `rstgen <rstgen.html>`_
  236. This module implements a generator of HTML/Latex from reStructuredText.
  237. * `sexp <sexp.html>`_
  238. High performance sexp parser and generator, mainly for communication
  239. with emacs.
  240. XML Processing
  241. --------------
  242. * `xmldom <xmldom.html>`_
  243. This module implements the XML DOM Level 2.
  244. * `xmldomparser <xmldomparser.html>`_
  245. This module parses an XML Document into a XML DOM Document representation.
  246. * `xmltree <xmltree.html>`_
  247. A simple XML tree. More efficient and simpler than the DOM. It also
  248. contains a macro for XML/HTML code generation.
  249. * `xmlparser <xmlparser.html>`_
  250. This module parses an XML document and creates its XML tree representation.
  251. * `htmlparser <htmlparser.html>`_
  252. This module parses an HTML document and creates its XML tree representation.
  253. * `htmlgen <htmlgen.html>`_
  254. This module implements a simple XML and HTML code
  255. generator. Each commonly used HTML tag has a corresponding macro
  256. that generates a string with its HTML representation.
  257. Cryptography and Hashing
  258. ------------------------
  259. * `hashes <hashes.html>`_
  260. This module implements efficient computations of hash values for diverse
  261. Nim types.
  262. * `md5 <md5.html>`_
  263. This module implements the MD5 checksum algorithm.
  264. * `base64 <base64.html>`_
  265. This module implements a base64 encoder and decoder.
  266. * `securehash <securehash.html>`_
  267. This module implements a sha1 encoder and decoder.
  268. Multimedia support
  269. ------------------
  270. * `colors <colors.html>`_
  271. This module implements color handling for Nim. It is used by
  272. the ``graphics`` module.
  273. Miscellaneous
  274. -------------
  275. * `events <events.html>`_
  276. This module implements an event system that is not dependent on external
  277. graphical toolkits.
  278. * `oids <oids.html>`_
  279. An OID is a global ID that consists of a timestamp,
  280. a unique counter and a random value. This combination should suffice to
  281. produce a globally distributed unique ID. This implementation was extracted
  282. from the Mongodb interface and it thus binary compatible with a Mongo OID.
  283. * `endians <endians.html>`_
  284. This module contains helpers that deal with different byte orders.
  285. * `logging <logging.html>`_
  286. This module implements a simple logger.
  287. * `options <options.html>`_
  288. Types which encapsulate an optional value.
  289. * `future <future.html>`_
  290. This module implements new experimental features. Currently the syntax
  291. sugar for anonymous procedures.
  292. * `coro <coro.html>`_
  293. This module implements experimental coroutines in Nim.
  294. * `unittest <unittest.html>`_
  295. Implements a Unit testing DSL.
  296. Modules for JS backend
  297. ---------------------------
  298. * `dom <dom.html>`_
  299. Declaration of the Document Object Model for the JS backend.
  300. * `jsffi <jsffi.html>`_
  301. Types and macros for easier interaction with JavaScript.
  302. Deprecated modules
  303. ------------------
  304. * `asyncio <asyncio.html>`_
  305. This module implements an asynchronous event loop for sockets.
  306. **Deprecated since version 0.11.2:**
  307. Use the `asyncnet <asyncnet.html>`_ together with the
  308. `asyncdispatch <asyncdispatch.html>`_ module instead.
  309. * `ftpclient <ftpclient.html>`_
  310. This module implements an FTP client.
  311. **Deprecated since version 0.11.3:**
  312. Use the `asyncftpclient <asyncftpclient.html>`_ module instead.
  313. * `sockets <sockets.html>`_
  314. This module implements a simple portable type-safe sockets layer.
  315. **Deprecated since version 0.11.2:**
  316. Use the `net <net.html>`_ or the `rawsockets <rawsockets.html>`_ module
  317. instead.
  318. * `rawsockets <rawsockets.html>`_
  319. **Deprecated since version 0.11.4:**
  320. This module has been renamed to `nativesockets <nativesockets.html>`_.
  321. Impure libraries
  322. ================
  323. Regular expressions
  324. -------------------
  325. * `re <re.html>`_
  326. This module contains procedures and operators for handling regular
  327. expressions. The current implementation uses PCRE.
  328. * `nre <nre.html>`_
  329. Another implementation of procedures for using regular expressions. Also uses
  330. PCRE.
  331. Database support
  332. ----------------
  333. * `db_postgres <db_postgres.html>`_
  334. A higher level PostgreSQL database wrapper. The same interface is implemented
  335. for other databases too.
  336. * `db_mysql <db_mysql.html>`_
  337. A higher level MySQL database wrapper. The same interface is implemented
  338. for other databases too.
  339. * `db_sqlite <db_sqlite.html>`_
  340. A higher level SQLite database wrapper. The same interface is implemented
  341. for other databases too.
  342. Other
  343. -----
  344. * `ssl <ssl.html>`_
  345. This module provides an easy to use sockets-style
  346. Nim interface to the OpenSSL library.
  347. Wrappers
  348. ========
  349. The generated HTML for some of these wrappers is so huge that it is
  350. not contained in the distribution. You can then find them on the website.
  351. Windows specific
  352. ----------------
  353. * `winlean <winlean.html>`_
  354. Contains a wrapper for a small subset of the Win32 API.
  355. UNIX specific
  356. -------------
  357. * `posix <posix.html>`_
  358. Contains a wrapper for the POSIX standard.
  359. Regular expressions
  360. -------------------
  361. * `pcre <pcre.html>`_
  362. Wrapper for the PCRE library.
  363. GUI libraries
  364. -------------
  365. * `iup <iup.html>`_
  366. Wrapper of the IUP GUI library.
  367. Database support
  368. ----------------
  369. * `postgres <postgres.html>`_
  370. Contains a wrapper for the PostgreSQL API.
  371. * `mysql <mysql.html>`_
  372. Contains a wrapper for the mySQL API.
  373. * `sqlite3 <sqlite3.html>`_
  374. Contains a wrapper for SQLite 3 API.
  375. * `odbcsql <odbcsql.html>`_
  376. interface to the ODBC driver.
  377. Network Programming and Internet Protocols
  378. ------------------------------------------
  379. * `libuv <libuv.html>`_
  380. Wrapper for the libuv library used for async I/O programming.
  381. * `joyent_http_parser <joyent_http_parser.html>`_
  382. Wrapper for the joyent's high-performance HTTP parser.
  383. * `openssl <openssl.html>`_
  384. Wrapper for OpenSSL.
  385. Scientific computing
  386. --------------------
  387. * `libsvm <libsvm.html>`_
  388. Low level wrapper for `lib svm <http://www.csie.ntu.edu.tw/~cjlin/libsvm/>`_.
  389. Nimble
  390. ======
  391. Nimble is a package manager for the Nim programming language.
  392. For instructions on how to install Nimble packages see
  393. `its README <https://github.com/nim-lang/nimble#readme>`_.
  394. Official packages
  395. -----------------
  396. These packages are officially supported and will therefore be continually
  397. maintained to ensure that they work with the latest versions of the Nim
  398. compiler.
  399. .. raw:: html
  400. <div id="officialPkgList"><b>If you are reading this you are missing
  401. nimblepkglist.js or have javascript disabled in your browser.</b></div>
  402. Unofficial packages
  403. -------------------
  404. These packages have been developed by independent Nim developers and as
  405. such may not always be up to date with the latest developments in the
  406. Nim programming language.
  407. .. raw:: html
  408. <div id="unofficialPkgList"><b>If you are reading this you are missing
  409. nimblepkglist.js or have javascript disabled in your browser.</b></div>
  410. <script type="text/javascript" src="nimblepkglist.js"></script>
  411. <script type="text/javascript" src="https://irclogs.nim-lang.org/packages?callback=gotPackageList" async></script>