123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732 |
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <!-- This file is generated by Nim. -->
- <html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>std/parsecfg</title>
- <!-- Google fonts -->
- <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
- <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
- <!-- Favicon -->
- <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
- <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
- <!-- CSS -->
- <link rel="stylesheet" type="text/css" href="nimdoc.out.css?v=2.3.1">
- <!-- JS -->
- <script type="text/javascript" src="dochack.js?v=2.3.1"></script>
- </head>
- <body>
- <div class="document" id="documentId">
- <div class="container">
- <h1 class="title">std/parsecfg</h1>
- <div class="row">
- <div class="three columns">
- <div class="theme-select-wrapper">
- <label for="theme-select">Theme: </label>
- <select id="theme-select" onchange="setTheme(this.value)">
- <option value="auto">🌗 Match OS</option>
- <option value="dark">🌑 Dark</option>
- <option value="light">🌕 Light</option>
- </select>
- </div>
- <div id="global-links">
- <ul class="simple-boot">
- <li><a href="manual.html">Manual</a></li>
- <li><a href="lib.html">Standard library</a></li>
- <li> <a id="indexLink" href="theindex.html">Index</a></li>
- <li><a href="compiler/theindex.html">Compiler docs</a></li>
- <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
- <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
- </ul>
- </div>
- <div id="searchInputDiv">
- Search: <input type="search" id="searchInput"
- oninput="search()" />
- </div>
-
- <ul class="simple simple-toc" id="toc-list">
- <ul class="simple"><li><a class="reference" id="configuration-file-example_toc" href="#configuration-file-example">Configuration file example</a></li>
- <li><a class="reference" id="creating-a-configuration-file_toc" href="#creating-a-configuration-file">Creating a configuration file</a></li>
- <li><a class="reference" id="reading-a-configuration-file_toc" href="#reading-a-configuration-file">Reading a configuration file</a></li>
- <li><a class="reference" id="modifying-a-configuration-file_toc" href="#modifying-a-configuration-file">Modifying a configuration file</a></li>
- <li><a class="reference" id="deleting-a-section-key-in-a-configuration-file_toc" href="#deleting-a-section-key-in-a-configuration-file">Deleting a section key in a configuration file</a></li>
- <li><a class="reference" id="supported-ini-file-structure_toc" href="#supported-ini-file-structure">Supported INI File structure</a></li>
- </ul><li>
- <a class="reference reference-toplevel" href="#6" id="56">Imports</a>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
- <ul class="simple simple-toc-section">
- <li><a class="reference" href="#CfgEvent" title="CfgEvent = object of RootObj
- case kind*: CfgEventKind ## the kind of the event
- of cfgEof:
- nil
- of cfgSectionStart:
- section*: string ## `section` contains the name of the
- ## parsed section start (syntax: `[section]`)
- of cfgKeyValuePair, cfgOption:
- key*, value*: string ## contains the (key, value) pair if an option
- ## of the form `--key: value` or an ordinary
- ## `key= value` pair has been parsed.
- ## `value==""` if it was not specified in the
- ## configuration file.
- of cfgError: ## the parser encountered an error: `msg`
- msg*: string ## contains the error message. No exceptions
- ## are thrown if a parse error occurs.">CfgEvent</a></li>
- <li><a class="reference" href="#CfgEventKind" title="CfgEventKind = enum
- cfgEof, ## end of file reached
- cfgSectionStart, ## a `[section]` has been parsed
- cfgKeyValuePair, ## a `key=value` pair has been detected
- cfgOption, ## a `--key=value` command line option
- cfgError ## an error occurred during parsing">CfgEventKind</a></li>
- <li><a class="reference" href="#CfgParser" title="CfgParser = object of BaseLexer">CfgParser</a></li>
- <li><a class="reference" href="#Config" title="Config = OrderedTableRef[string, OrderedTableRef[string, string]]">Config</a></li>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">$
- <li><a class="reference" href="#%24%2CConfig" title="`$`(dict: Config): string">`$`(dict: Config): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">close
- <li><a class="reference" href="#close%2CCfgParser" title="close(c: var CfgParser)">close(c: var CfgParser)</a></li>
- </ul>
- <ul class="simple nested-toc-section">delSection
- <li><a class="reference" href="#delSection%2CConfig%2Cstring" title="delSection(dict: var Config; section: string)">delSection(dict: var Config; section: string)</a></li>
- </ul>
- <ul class="simple nested-toc-section">delSectionKey
- <li><a class="reference" href="#delSectionKey%2CConfig%2Cstring%2Cstring" title="delSectionKey(dict: var Config; section, key: string)">delSectionKey(dict: var Config; section, key: string)</a></li>
- </ul>
- <ul class="simple nested-toc-section">errorStr
- <li><a class="reference" href="#errorStr%2CCfgParser%2Cstring" title="errorStr(c: CfgParser; msg: string): string">errorStr(c: CfgParser; msg: string): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">getColumn
- <li><a class="reference" href="#getColumn%2CCfgParser" title="getColumn(c: CfgParser): int">getColumn(c: CfgParser): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">getFilename
- <li><a class="reference" href="#getFilename%2CCfgParser" title="getFilename(c: CfgParser): string">getFilename(c: CfgParser): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">getLine
- <li><a class="reference" href="#getLine%2CCfgParser" title="getLine(c: CfgParser): int">getLine(c: CfgParser): int</a></li>
- </ul>
- <ul class="simple nested-toc-section">getSectionValue
- <li><a class="reference" href="#getSectionValue%2CConfig%2Cstring%2Cstring%2Cstring" title="getSectionValue(dict: Config; section, key: string; defaultVal = ""): string">getSectionValue(dict: Config; section, key: string; defaultVal = ""): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">ignoreMsg
- <li><a class="reference" href="#ignoreMsg%2CCfgParser%2CCfgEvent" title="ignoreMsg(c: CfgParser; e: CfgEvent): string">ignoreMsg(c: CfgParser; e: CfgEvent): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">loadConfig
- <li><a class="reference" href="#loadConfig%2Cstring" title="loadConfig(filename: string): Config">loadConfig(filename: string): Config</a></li>
- <li><a class="reference" href="#loadConfig%2CStream%2Cstring" title="loadConfig(stream: Stream; filename: string = "[stream]"): Config">loadConfig(stream: Stream; filename: string = "[stream]"): Config</a></li>
- </ul>
- <ul class="simple nested-toc-section">newConfig
- <li><a class="reference" href="#newConfig" title="newConfig(): Config">newConfig(): Config</a></li>
- </ul>
- <ul class="simple nested-toc-section">next
- <li><a class="reference" href="#next%2CCfgParser" title="next(c: var CfgParser): CfgEvent">next(c: var CfgParser): CfgEvent</a></li>
- </ul>
- <ul class="simple nested-toc-section">open
- <li><a class="reference" href="#open%2CCfgParser%2CStream%2Cstring%2Cint" title="open(c: var CfgParser; input: Stream; filename: string; lineOffset = 0)">open(c: var CfgParser; input: Stream; filename: string; lineOffset = 0)</a></li>
- </ul>
- <ul class="simple nested-toc-section">setSectionKey
- <li><a class="reference" href="#setSectionKey%2CConfig%2Cstring%2Cstring%2Cstring" title="setSectionKey(dict: var Config; section, key, value: string)">setSectionKey(dict: var Config; section, key, value: string)</a></li>
- </ul>
- <ul class="simple nested-toc-section">warningStr
- <li><a class="reference" href="#warningStr%2CCfgParser%2Cstring" title="warningStr(c: CfgParser; msg: string): string">warningStr(c: CfgParser; msg: string): string</a></li>
- </ul>
- <ul class="simple nested-toc-section">writeConfig
- <li><a class="reference" href="#writeConfig%2CConfig%2Cstring" title="writeConfig(dict: Config; filename: string)">writeConfig(dict: Config; filename: string)</a></li>
- <li><a class="reference" href="#writeConfig%2CConfig%2CStream" title="writeConfig(dict: Config; stream: Stream)">writeConfig(dict: Config; stream: Stream)</a></li>
- </ul>
- </ul>
- </details>
- </li>
- <li>
- <details open>
- <summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
- <ul class="simple simple-toc-section">
- <ul class="simple nested-toc-section">sections
- <li><a class="reference" href="#sections.i%2CConfig" title="sections(dict: Config): lent string">sections(dict: Config): lent string</a></li>
- </ul>
- </ul>
- </details>
- </li>
- </ul>
- </div>
- <div class="nine columns" id="content">
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L1" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
- <div id="tocRoot"></div>
-
- <p class="module-desc"><p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">parsecfg</span></span></tt> module implements a high performance configuration file parser. The configuration file's syntax is similar to the Windows <tt class="docutils literal"><span class="pre"><span class="Operator">.</span><span class="Identifier">ini</span></span></tt> format, but much more powerful, as it is not a line based parser. String literals, raw string literals and triple quoted string literals are supported as in the Nim programming language.</p>
- <p>Example of how a configuration file may look like:</p>
- <pre># This is a comment.
- ; this too.
- [Common]
- cc=gcc # '=' and ':' are the same
- --foo="bar" # '--cc' and 'cc' are the same, 'bar' and '"bar"' are the same (except for '#')
- macrosym: "#" # Note that '#' is interpreted as a comment without the quotation
- --verbose
- [Windows]
- isConsoleApplication=False ; another comment
- [Posix]
- isConsoleApplication=True
- key1: "in this string backslash escapes are interpreted\n"
- key2: r"in this string not"
- key3: """triple quotes strings
- are also supported. They may span
- multiple lines."""
- --"long option with spaces": r"c:\myfiles\test.txt"
- </pre>
- <p>Here is an example of how to use the configuration file parser:</p>
- <p><strong class="examples_text">Example: cmd: -r:off</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">parsecfg</span>
- <span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">strutils</span><span class="Punctuation">,</span> <span class="Identifier">streams</span><span class="Punctuation">]</span>
- <span class="Keyword">let</span> <span class="Identifier">configFile</span> <span class="Operator">=</span> <span class="StringLit">"example.ini"</span>
- <span class="Keyword">var</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="Identifier">newFileStream</span><span class="Punctuation">(</span><span class="Identifier">configFile</span><span class="Punctuation">,</span> <span class="Identifier">fmRead</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Identifier">f</span> <span class="Operator">!=</span> <span class="Keyword">nil</span><span class="Punctuation">,</span> <span class="StringLit">"cannot open "</span> <span class="Operator">&</span> <span class="Identifier">configFile</span>
- <span class="Keyword">var</span> <span class="Identifier">p</span><span class="Punctuation">:</span> <span class="Identifier">CfgParser</span>
- <span class="Identifier">open</span><span class="Punctuation">(</span><span class="Identifier">p</span><span class="Punctuation">,</span> <span class="Identifier">f</span><span class="Punctuation">,</span> <span class="Identifier">configFile</span><span class="Punctuation">)</span>
- <span class="Keyword">while</span> <span class="Identifier">true</span><span class="Punctuation">:</span>
- <span class="Keyword">var</span> <span class="Identifier">e</span> <span class="Operator">=</span> <span class="Identifier">next</span><span class="Punctuation">(</span><span class="Identifier">p</span><span class="Punctuation">)</span>
- <span class="Keyword">case</span> <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">kind</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgEof</span><span class="Punctuation">:</span> <span class="Keyword">break</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgSectionStart</span><span class="Punctuation">:</span> <span class="Comment">## a `[section]` has been parsed</span>
- <span class="Identifier">echo</span> <span class="StringLit">"new section: "</span> <span class="Operator">&</span> <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">section</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgKeyValuePair</span><span class="Punctuation">:</span>
- <span class="Identifier">echo</span> <span class="StringLit">"key-value-pair: "</span> <span class="Operator">&</span> <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">key</span> <span class="Operator">&</span> <span class="StringLit">": "</span> <span class="Operator">&</span> <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">value</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgOption</span><span class="Punctuation">:</span>
- <span class="Identifier">echo</span> <span class="StringLit">"command: "</span> <span class="Operator">&</span> <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">key</span> <span class="Operator">&</span> <span class="StringLit">": "</span> <span class="Operator">&</span> <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">value</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgError</span><span class="Punctuation">:</span>
- <span class="Identifier">echo</span> <span class="Identifier">e</span><span class="Operator">.</span><span class="Identifier">msg</span>
- <span class="Identifier">close</span><span class="Punctuation">(</span><span class="Identifier">p</span><span class="Punctuation">)</span></pre>
- <h2><a class="toc-backref" id="configuration-file-example" href="#configuration-file-example">Configuration file example</a></h2><pre class="listing">charset = "utf-8"
- [Package]
- name = "hello"
- --threads:on
- [Author]
- name = "nim-lang"
- website = "nim-lang.org"</pre>
- <h2><a class="toc-backref" id="creating-a-configuration-file" href="#creating-a-configuration-file">Creating a configuration file</a></h2>
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">parsecfg</span>
- <span class="Keyword">var</span> <span class="Identifier">dict</span> <span class="Operator">=</span> <span class="Identifier">newConfig</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">setSectionKey</span><span class="Punctuation">(</span><span class="StringLit">""</span><span class="Punctuation">,</span><span class="StringLit">"charset"</span><span class="Punctuation">,</span> <span class="StringLit">"utf-8"</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">setSectionKey</span><span class="Punctuation">(</span><span class="StringLit">"Package"</span><span class="Punctuation">,</span> <span class="StringLit">"name"</span><span class="Punctuation">,</span> <span class="StringLit">"hello"</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">setSectionKey</span><span class="Punctuation">(</span><span class="StringLit">"Package"</span><span class="Punctuation">,</span> <span class="StringLit">"--threads"</span><span class="Punctuation">,</span> <span class="StringLit">"on"</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">setSectionKey</span><span class="Punctuation">(</span><span class="StringLit">"Author"</span><span class="Punctuation">,</span> <span class="StringLit">"name"</span><span class="Punctuation">,</span> <span class="StringLit">"nim-lang"</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">setSectionKey</span><span class="Punctuation">(</span><span class="StringLit">"Author"</span><span class="Punctuation">,</span> <span class="StringLit">"website"</span><span class="Punctuation">,</span> <span class="StringLit">"nim-lang.org"</span><span class="Punctuation">)</span>
- <span class="Identifier">assert</span> <span class="Operator">$</span><span class="Identifier">dict</span> <span class="Operator">==</span> <span class="LongStringLit">"""
- charset=utf-8
- [Package]
- name=hello
- --threads:on
- [Author]
- name=nim-lang
- website=nim-lang.org
- """</span></pre>
- <h2><a class="toc-backref" id="reading-a-configuration-file" href="#reading-a-configuration-file">Reading a configuration file</a></h2>
- <p><strong class="examples_text">Example: cmd: -r:off</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">parsecfg</span>
- <span class="Keyword">let</span> <span class="Identifier">dict</span> <span class="Operator">=</span> <span class="Identifier">loadConfig</span><span class="Punctuation">(</span><span class="StringLit">"config.ini"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">charset</span> <span class="Operator">=</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="StringLit">""</span><span class="Punctuation">,</span><span class="StringLit">"charset"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">threads</span> <span class="Operator">=</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="StringLit">"Package"</span><span class="Punctuation">,</span><span class="StringLit">"--threads"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">pname</span> <span class="Operator">=</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="StringLit">"Package"</span><span class="Punctuation">,</span><span class="StringLit">"name"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">name</span> <span class="Operator">=</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="StringLit">"Author"</span><span class="Punctuation">,</span><span class="StringLit">"name"</span><span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">website</span> <span class="Operator">=</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="StringLit">"Author"</span><span class="Punctuation">,</span><span class="StringLit">"website"</span><span class="Punctuation">)</span>
- <span class="Identifier">echo</span> <span class="Identifier">pname</span> <span class="Operator">&</span> <span class="StringLit">"</span><span class="EscapeSequence">\n</span><span class="StringLit">"</span> <span class="Operator">&</span> <span class="Identifier">name</span> <span class="Operator">&</span> <span class="StringLit">"</span><span class="EscapeSequence">\n</span><span class="StringLit">"</span> <span class="Operator">&</span> <span class="Identifier">website</span></pre>
- <h2><a class="toc-backref" id="modifying-a-configuration-file" href="#modifying-a-configuration-file">Modifying a configuration file</a></h2>
- <p><strong class="examples_text">Example: cmd: -r:off</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">parsecfg</span>
- <span class="Keyword">var</span> <span class="Identifier">dict</span> <span class="Operator">=</span> <span class="Identifier">loadConfig</span><span class="Punctuation">(</span><span class="StringLit">"config.ini"</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">setSectionKey</span><span class="Punctuation">(</span><span class="StringLit">"Author"</span><span class="Punctuation">,</span> <span class="StringLit">"name"</span><span class="Punctuation">,</span> <span class="StringLit">"nim-lang"</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">writeConfig</span><span class="Punctuation">(</span><span class="StringLit">"config.ini"</span><span class="Punctuation">)</span></pre>
- <h2><a class="toc-backref" id="deleting-a-section-key-in-a-configuration-file" href="#deleting-a-section-key-in-a-configuration-file">Deleting a section key in a configuration file</a></h2>
- <p><strong class="examples_text">Example: cmd: -r:off</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">parsecfg</span>
- <span class="Keyword">var</span> <span class="Identifier">dict</span> <span class="Operator">=</span> <span class="Identifier">loadConfig</span><span class="Punctuation">(</span><span class="StringLit">"config.ini"</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">delSectionKey</span><span class="Punctuation">(</span><span class="StringLit">"Author"</span><span class="Punctuation">,</span> <span class="StringLit">"website"</span><span class="Punctuation">)</span>
- <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">writeConfig</span><span class="Punctuation">(</span><span class="StringLit">"config.ini"</span><span class="Punctuation">)</span></pre>
- <h2><a class="toc-backref" id="supported-ini-file-structure" href="#supported-ini-file-structure">Supported INI File structure</a></h2>
- <p><strong class="examples_text">Example:</strong></p>
- <pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">parsecfg</span>
- <span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">streams</span>
- <span class="Keyword">var</span> <span class="Identifier">dict</span> <span class="Operator">=</span> <span class="Identifier">loadConfig</span><span class="Punctuation">(</span><span class="Identifier">newStringStream</span><span class="Punctuation">(</span><span class="LongStringLit">"""[Simple Values]
- key=value
- spaces in keys=allowed
- spaces in values=allowed as well
- spaces around the delimiter = obviously
- you can also use : to delimit keys from values
- [All Values Are Strings]
- values like this: 19990429
- or this: 3.14159265359
- are they treated as numbers : no
- integers floats and booleans are held as: strings
- can use the API to get converted values directly: true
- [No Values]
- key_without_value
- # empty string value is not allowed =
- [ Seletion A ]
- space around section name will be ignored
- [You can use comments]
- # like this
- ; or this
- # By default only in an empty line.
- # Inline comments can be harmful because they prevent users
- # from using the delimiting characters as parts of values.
- # That being said, this can be customized.
- [Sections Can Be Indented]
- can_values_be_as_well = True
- does_that_mean_anything_special = False
- purpose = formatting for readability
- # Did I mention we can indent comments, too?
- """</span><span class="Punctuation">)</span>
- <span class="Punctuation">)</span>
- <span class="Keyword">let</span> <span class="Identifier">section1</span> <span class="Operator">=</span> <span class="StringLit">"Simple Values"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section1</span><span class="Punctuation">,</span> <span class="StringLit">"key"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"value"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section1</span><span class="Punctuation">,</span> <span class="StringLit">"spaces in keys"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"allowed"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section1</span><span class="Punctuation">,</span> <span class="StringLit">"spaces in values"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"allowed as well"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section1</span><span class="Punctuation">,</span> <span class="StringLit">"spaces around the delimiter"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"obviously"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section1</span><span class="Punctuation">,</span> <span class="StringLit">"you can also use"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"to delimit keys from values"</span>
- <span class="Keyword">let</span> <span class="Identifier">section2</span> <span class="Operator">=</span> <span class="StringLit">"All Values Are Strings"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section2</span><span class="Punctuation">,</span> <span class="StringLit">"values like this"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"19990429"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section2</span><span class="Punctuation">,</span> <span class="StringLit">"or this"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"3.14159265359"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section2</span><span class="Punctuation">,</span> <span class="StringLit">"are they treated as numbers"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"no"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section2</span><span class="Punctuation">,</span> <span class="StringLit">"integers floats and booleans are held as"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"strings"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section2</span><span class="Punctuation">,</span> <span class="StringLit">"can use the API to get converted values directly"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"true"</span>
- <span class="Keyword">let</span> <span class="Identifier">section3</span> <span class="Operator">=</span> <span class="StringLit">"Seletion A"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section3</span><span class="Punctuation">,</span>
- <span class="StringLit">"space around section name will be ignored"</span><span class="Punctuation">,</span> <span class="StringLit">"not an empty value"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">""</span>
- <span class="Keyword">let</span> <span class="Identifier">section4</span> <span class="Operator">=</span> <span class="StringLit">"Sections Can Be Indented"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section4</span><span class="Punctuation">,</span> <span class="StringLit">"can_values_be_as_well"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"True"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section4</span><span class="Punctuation">,</span> <span class="StringLit">"does_that_mean_anything_special"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"False"</span>
- <span class="Identifier">assert</span> <span class="Identifier">dict</span><span class="Operator">.</span><span class="Identifier">getSectionValue</span><span class="Punctuation">(</span><span class="Identifier">section4</span><span class="Punctuation">,</span> <span class="StringLit">"purpose"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"formatting for readability"</span></pre></p>
- <div class="section" id="6">
- <h1><a class="toc-backref" href="#6">Imports</a></h1>
- <dl class="item">
- <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="lexbase.html">lexbase</a>, <a class="reference external" href="streams.html">streams</a>, <a class="reference external" href="tables.html">tables</a>, <a class="reference external" href="decode_helpers.html">decode_helpers</a>, <a class="reference external" href="since.html">since</a>, <a class="reference external" href="syncio.html">syncio</a>
- </dl>
- </div>
- <div class="section" id="7">
- <h1><a class="toc-backref" href="#7">Types</a></h1>
- <dl class="item">
- <div id="CfgEvent">
- <dt><pre><a href="parsecfg.html#CfgEvent"><span class="Identifier">CfgEvent</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#RootObj"><span class="Identifier">RootObj</span></a>
- <span class="Keyword">case</span> <span class="Identifier">kind</span><span class="Operator">*</span><span class="Other">:</span> <a href="parsecfg.html#CfgEventKind"><span class="Identifier">CfgEventKind</span></a> <span class="Comment">## the kind of the event</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgEof</span><span class="Other">:</span>
- <span class="Keyword">nil</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgSectionStart</span><span class="Other">:</span>
- <span class="Identifier">section</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Comment">## `section` contains the name of the</span>
- <span class="Comment">## parsed section start (syntax: `[section]`)</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgKeyValuePair</span><span class="Other">,</span> <span class="Identifier">cfgOption</span><span class="Other">:</span>
- <span class="Identifier">key</span><span class="Operator">*</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Comment">## contains the (key, value) pair if an option</span>
- <span class="Comment">## of the form `--key: value` or an ordinary</span>
- <span class="Comment">## `key= value` pair has been parsed.</span>
- <span class="Comment">## `value==""` if it was not specified in the</span>
- <span class="Comment">## configuration file.</span>
- <span class="Keyword">of</span> <span class="Identifier">cfgError</span><span class="Other">:</span> <span class="Comment">## the parser encountered an error: `msg`</span>
- <span class="Identifier">msg</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Comment">## contains the error message. No exceptions</span>
- <span class="Comment">## are thrown if a parse error occurs.</span></pre></dt>
- <dd>
-
- describes a parsing event
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L191" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L191" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="CfgEventKind">
- <dt><pre><a href="parsecfg.html#CfgEventKind"><span class="Identifier">CfgEventKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
- <span class="Identifier">cfgEof</span><span class="Other">,</span> <span class="Comment">## end of file reached</span>
- <span class="Identifier">cfgSectionStart</span><span class="Other">,</span> <span class="Comment">## a `[section]` has been parsed</span>
- <span class="Identifier">cfgKeyValuePair</span><span class="Other">,</span> <span class="Comment">## a `key=value` pair has been detected</span>
- <span class="Identifier">cfgOption</span><span class="Other">,</span> <span class="Comment">## a `--key=value` command line option</span>
- <span class="Identifier">cfgError</span> <span class="Comment">## an error occurred during parsing</span></pre></dt>
- <dd>
-
- enumeration of all events that may occur when parsing
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L184" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L184" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="CfgParser">
- <dt><pre><a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="lexbase.html#BaseLexer"><span class="Identifier">BaseLexer</span></a></pre></dt>
- <dd>
-
- the parser object.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L214" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L214" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="Config">
- <dt><pre><a href="parsecfg.html#Config"><span class="Identifier">Config</span></a> <span class="Other">=</span> <a href="tables.html#OrderedTableRef"><span class="Identifier">OrderedTableRef</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <a href="tables.html#OrderedTableRef"><span class="Identifier">OrderedTableRef</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">]</span></pre></dt>
- <dd>
-
-
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L501" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L501" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </dl>
- </div>
- <div class="section" id="12">
- <h1><a class="toc-backref" href="#12">Procs</a></h1>
- <dl class="item">
- <div id="$-procs-all">
- <div id="$,Config">
- <dt><pre><span class="Keyword">proc</span> <a href="#%24%2CConfig"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">dict</span><span class="Other">:</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Writes the contents of the table to string.<div class="admonition admonition-info"><span class="admonition-info-text"><b>Note:</b></span>
- Comment statement will be ignored.</div>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L606" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L606" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="close-procs-all">
- <div id="close,CfgParser">
- <dt><pre><span class="Keyword">proc</span> <a href="#close%2CCfgParser"><span class="Identifier">close</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Closes the parser <tt class="docutils literal"><span class="pre"><span class="Identifier">c</span></span></tt> and its associated input stream.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L237" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L237" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="delSection-procs-all">
- <div id="delSection,Config,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#delSection%2CConfig%2Cstring"><span class="Identifier">delSection</span></a><span class="Other">(</span><span class="Identifier">dict</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a><span class="Other">;</span> <span class="Identifier">section</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Deletes the specified section and all of its sub keys.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L643" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L643" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="delSectionKey-procs-all">
- <div id="delSectionKey,Config,string,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#delSectionKey%2CConfig%2Cstring%2Cstring"><span class="Identifier">delSectionKey</span></a><span class="Other">(</span><span class="Identifier">dict</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a><span class="Other">;</span> <span class="Identifier">section</span><span class="Other">,</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Deletes the key of the specified section.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L647" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L647" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="errorStr-procs-all">
- <div id="errorStr,CfgParser,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#errorStr%2CCfgParser%2Cstring"><span class="Identifier">errorStr</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">;</span> <span class="Identifier">msg</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns a properly formatted error message containing current line and column information.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L428" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L428" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getColumn-procs-all">
- <div id="getColumn,CfgParser">
- <dt><pre><span class="Keyword">proc</span> <a href="#getColumn%2CCfgParser"><span class="Identifier">getColumn</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Gets the current column the parser has arrived at.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L241" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L241" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getFilename-procs-all">
- <div id="getFilename,CfgParser">
- <dt><pre><span class="Keyword">proc</span> <a href="#getFilename%2CCfgParser"><span class="Identifier">getFilename</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Gets the filename of the file that the parser processes.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L249" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L249" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getLine-procs-all">
- <div id="getLine,CfgParser">
- <dt><pre><span class="Keyword">proc</span> <a href="#getLine%2CCfgParser"><span class="Identifier">getLine</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Gets the current line the parser has arrived at.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L245" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L245" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="getSectionValue-procs-all">
- <div id="getSectionValue,Config,string,string,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#getSectionValue%2CConfig%2Cstring%2Cstring%2Cstring"><span class="Identifier">getSectionValue</span></a><span class="Other">(</span><span class="Identifier">dict</span><span class="Other">:</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a><span class="Other">;</span> <span class="Identifier">section</span><span class="Other">,</span> <span class="Identifier">key</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">defaultVal</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
- <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Gets the key value of the specified Section. Returns the specified default value if the specified key does not exist.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L624" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L624" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="ignoreMsg-procs-all">
- <div id="ignoreMsg,CfgParser,CfgEvent">
- <dt><pre><span class="Keyword">proc</span> <a href="#ignoreMsg%2CCfgParser%2CCfgEvent"><span class="Identifier">ignoreMsg</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">;</span> <span class="Identifier">e</span><span class="Other">:</span> <a href="parsecfg.html#CfgEvent"><span class="Identifier">CfgEvent</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns a properly formatted warning message containing that an entry is ignored.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L440" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L440" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="loadConfig-procs-all">
- <div id="loadConfig,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#loadConfig%2Cstring"><span class="Identifier">loadConfig</span></a><span class="Other">(</span><span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a> {.
- <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Loads the specified configuration file into a new Config instance.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L541" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L541" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="loadConfig,Stream,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#loadConfig%2CStream%2Cstring"><span class="Identifier">loadConfig</span></a><span class="Other">(</span><span class="Identifier">stream</span><span class="Other">:</span> <a href="streams.html#Stream"><span class="Identifier">Stream</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">"[stream]"</span><span class="Other">)</span><span class="Other">:</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a> {.
- <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Loads the specified configuration from stream into a new Config instance. <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> parameter is only used for nicer error messages.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L508" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L508" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="newConfig-procs-all">
- <div id="newConfig">
- <dt><pre><span class="Keyword">proc</span> <a href="#newConfig"><span class="Identifier">newConfig</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Creates a new configuration table. Useful when wanting to create a configuration file.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L503" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L503" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="next-procs-all">
- <div id="next,CfgParser">
- <dt><pre><span class="Keyword">proc</span> <a href="#next%2CCfgParser"><span class="Identifier">next</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">)</span><span class="Other">:</span> <a href="parsecfg.html#CfgEvent"><span class="Identifier">CfgEvent</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Retrieves the first/next event. This controls the parser.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L471" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L471" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="open-procs-all">
- <div id="open,CfgParser,Stream,string,int">
- <dt><pre><span class="Keyword">proc</span> <a href="#open%2CCfgParser%2CStream%2Cstring%2Cint"><span class="Identifier">open</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">;</span> <span class="Identifier">input</span><span class="Other">:</span> <a href="streams.html#Stream"><span class="Identifier">Stream</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">lineOffset</span> <span class="Other">=</span> <span class="DecNumber">0</span><span class="Other">)</span> {.
- <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Initializes the parser with an input stream. <tt class="docutils literal"><span class="pre"><span class="Identifier">Filename</span></span></tt> is only used for nice error messages. <tt class="docutils literal"><span class="pre"><span class="Identifier">lineOffset</span></span></tt> can be used to influence the line number information in the generated error messages.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L225" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L225" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="setSectionKey-procs-all">
- <div id="setSectionKey,Config,string,string,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#setSectionKey%2CConfig%2Cstring%2Cstring%2Cstring"><span class="Identifier">setSectionKey</span></a><span class="Other">(</span><span class="Identifier">dict</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a><span class="Other">;</span> <span class="Identifier">section</span><span class="Other">,</span> <span class="Identifier">key</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.
- <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Sets the Key value of the specified Section.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L635" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L635" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="warningStr-procs-all">
- <div id="warningStr,CfgParser,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#warningStr%2CCfgParser%2Cstring"><span class="Identifier">warningStr</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="parsecfg.html#CfgParser"><span class="Identifier">CfgParser</span></a><span class="Other">;</span> <span class="Identifier">msg</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"npc$1"</span><span class="Other">,</span>
- <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Returns a properly formatted warning message containing current line and column information.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L434" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L434" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- <div id="writeConfig-procs-all">
- <div id="writeConfig,Config,string">
- <dt><pre><span class="Keyword">proc</span> <a href="#writeConfig%2CConfig%2Cstring"><span class="Identifier">writeConfig</span></a><span class="Other">(</span><span class="Identifier">dict</span><span class="Other">:</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Writes the contents of the table to the specified configuration file.<div class="admonition admonition-info"><span class="admonition-info-text"><b>Note:</b></span>
- Comment statement will be ignored.</div>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L615" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L615" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- <div id="writeConfig,Config,Stream">
- <dt><pre><span class="Keyword">proc</span> <a href="#writeConfig%2CConfig%2CStream"><span class="Identifier">writeConfig</span></a><span class="Other">(</span><span class="Identifier">dict</span><span class="Other">:</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a><span class="Other">;</span> <span class="Identifier">stream</span><span class="Other">:</span> <a href="streams.html#Stream"><span class="Identifier">Stream</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
- <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Writes the contents of the table to the specified stream.<div class="admonition admonition-info"><span class="admonition-info-text"><b>Note:</b></span>
- Comment statement will be ignored.</div>
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L566" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L566" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- <div class="section" id="15">
- <h1><a class="toc-backref" href="#15">Iterators</a></h1>
- <dl class="item">
- <div id="sections-iterators-all">
- <div id="sections.i,Config">
- <dt><pre><span class="Keyword">iterator</span> <a href="#sections.i%2CConfig"><span class="Identifier">sections</span></a><span class="Other">(</span><span class="Identifier">dict</span><span class="Other">:</span> <a href="parsecfg.html#Config"><span class="Identifier">Config</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#lent"><span class="Identifier">lent</span></a> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
- <dd>
-
- Iterates through the sections in the <tt class="docutils literal"><span class="pre"><span class="Identifier">dict</span></span></tt>.
- <a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/parsecfg.nim#L656" class="link-seesrc" target="_blank">Source</a>
- <a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/parsecfg.nim#L656" class="link-seesrc" target="_blank" >Edit</a>
- </dd>
- </div>
- </div>
- </dl>
- </div>
- </div>
- </div>
- <div class="twelve-columns footer">
- <span class="nim-sprite"></span>
- <br>
- <small style="color: var(--hint);">Made with Nim. Generated: 2025-02-06 22:28:06 UTC</small>
- </div>
- </div>
- </div>
- <script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
-
- </body>
- </html>
|