Commit Graph

53 Commits

Author SHA1 Message Date
Mark Olesen
8ad448b803 ENH: minor adjustments to token methods for more granularity 2021-04-15 10:41:54 +02:00
Mark Olesen
51cd7ceecb ENH: improvements for token methods
- direct check of punctuation.
  For example,

      while (!tok.isPunctuation(token::BEGIN_LIST)) ..

  instead of

  while (!(tok.isPunctuation() && tok.pToken() == token::BEGIN_LIST)) ..

  Using direct comparison (tok != token::BEGIN_LIST) can be fragile
  when comparing int values:

      int c = readChar(is);
      while (tok != c) ..  // Danger, uses LABEL comparison!

- direct check of word.
  For example,

      if (tok.isWord("uniform")) ..

  instead of

      if (tok.isWord() && tok.wordToken() == "uniform") ..

- make token lineNumber() a setter method

ENH: adjust internal compound method empty() -> moved()

- support named compound tokens

STYLE: setter method for stream indentation
2021-03-09 09:23:41 +01:00
Mark Olesen
f1d9fea6f2 ENH: construct token::compound from object and token from compound (#1879)
- provides a more direct means of generating a compound token without
  an Istream

- add transferCompoundToken() without Istream reference

- mark more token methods as noexcept
2020-10-15 17:21:33 +02:00
Mark Olesen
8cfb483054 STYLE: some general spelling fixes 2020-05-04 09:15:21 +02:00
Mark Olesen
d7969b1ba4 ENH: preserve tokenized directive and variable types 2020-02-18 13:51:20 +01:00
Mark Olesen
d7c18a328c STYLE: simplify/shorten some token names 2020-01-20 10:15:50 +01:00
Mark Olesen
cc16bc9338 STYLE: comments, spelling in token.H 2019-12-07 16:46:49 +01:00
Andrew Heather
fdf8d10ab4 Merge commit 'e9219558d7' into develop-v1906 2019-12-05 11:47:19 +00:00
OpenFOAM bot
e9219558d7 GIT: Header file updates 2019-10-31 14:48:44 +00:00
Mark Olesen
6b0e77ce00 STYLE: adjust doxygen for token, add DOLLAR as punctuation char 2019-10-08 18:43:38 +02:00
Mark Olesen
c9cb4ce34f ENH: minor improvements, cleanup of token class
- relax casting rules
  * down-cast of labelToken to boolToken
  * up-cast of wordToken to stringToken.
    Can use isStringType() test for word or string types

- simplify constructors, move construct etc.

- expose reset() method as public, which resets to UNDEFINED and
  clears allocated storage etc.

DEFEATURE: remove assign from word or string pointer.

- This was deprecated 2017-11 and now removed.
  For this type of content transfer, move assignment should be used
  instead of stealing pointers.
2019-08-20 17:48:31 +02:00
Mark Olesen
e95ab402fd DOC: refer string::expand documentation to stringOps::expand 2019-08-07 14:45:06 +02:00
OpenFOAM bot
154029ddd0 BOT: Cleaned up header files 2019-02-06 12:28:23 +00:00
Mark Olesen
ffec4c6fa7 STYLE: more consistent formatting for deprecated items
- Start brief descriptions with 'Deprecated(YYYY-MM)' so that it is
  readily visible in the short method description. Consistent date
  format (YYYY-MM), placed immediately after the \deprecated tag.
2018-11-11 17:17:33 +01:00
Mark Olesen
990d00d40d ENH: additional boolToken token type
- not used by the ISstream parser, but suitable for other parsing
  methods where true/false concept should be distinguishable from
  integer values.

  Only constructed via the token::boolean() static method, not
  directly assignable.
  This avoids any potential ambiguities with label.
2018-10-12 09:09:36 +02:00
Mark Olesen
f9fe71815a STYLE: consistent use of '= delete' for removed constructors/assignments
- make the purpose more explicit, and reduces some work for the
  compiler as well.
2018-05-30 12:03:17 +02:00
Mark Olesen
dffc65d41d STYLE: make token null constructor constexpr, noexcept 2018-04-25 10:42:25 +02:00
Andrew Heather
a230e8d408 STYLE: Correcting typos 2018-03-28 17:14:16 +01:00
Mark Olesen
660f3e5492 ENH: cleanup autoPtr class (issue #639)
Improve alignment of its behaviour with std::unique_ptr

  - element_type typedef
  - release() method - identical to ptr() method
  - get() method to get the pointer without checking and without releasing it.
  - operator*() for dereferencing

Method name changes

  - renamed rawPtr() to get()
  - renamed rawRef() to ref(), removed unused const version.

Removed methods/operators

  - assignment from a raw pointer was deleted (was rarely used).
    Can be convenient, but uncontrolled and potentially unsafe.
    Do allow assignment from a literal nullptr though, since this
    can never leak (and also corresponds to the unique_ptr API).

Additional methods

  - clone() method: forwards to the clone() method of the underlying
    data object with argument forwarding.

  - reset(autoPtr&&) as an alternative to operator=(autoPtr&&)

STYLE: avoid implicit conversion from autoPtr to object type in many places

- existing implementation has the following:

     operator const T&() const { return operator*(); }

  which means that the following code works:

       autoPtr<mapPolyMesh> map = ...;
       updateMesh(*map);    // OK: explicit dereferencing
       updateMesh(map());   // OK: explicit dereferencing
       updateMesh(map);     // OK: implicit dereferencing

  for clarity it may preferable to avoid the implicit dereferencing

- prefer operator* to operator() when deferenced a return value
  so it is clearer that a pointer is involve and not a function call
  etc    Eg,   return *meshPtr_;  vs.  return meshPtr_();
2018-02-26 12:00:00 +01:00
Mark Olesen
4f1e4aa59e ENH: add token type for stream flags (ASCII/BINARY) 2017-11-12 16:57:37 +01:00
Mark Olesen
c4de3e0a4d ENH: enhancements to behaviour of token
- improved memory alignment reduces overhead for Int32 compilation

- added move/swap semantics

- made the type() readonly in favour of setVariant() to allow change
  of variant within a particular storage representation.
  Eg, STRING -> VERBATIMSTRING.
2017-11-05 20:05:28 +01:00
Mark Olesen
37e863521a ENH: make token constructors explicit (issue #563)
- access tokenType enum values more consistently.
2017-08-10 11:53:37 +02:00
Mark Olesen
86ef9e86dc ENH: make treatment of stream allocators more uniform (issue #532)
- use allocator class to wrap the stream pointers instead of passing
  them into ISstream, OSstream and using a dynamic cast to delete
  then. This is especially important if we will have a bidirectional
  stream (can't delete twice!).

STYLE:

- file stream constructors with std::string (C++11)

- for rewind, explicit about in|out direction. This is not currently
  important, but avoids surprises with any future bidirectional access.

- combined string streams in StringStream.H header.
  Similar to <sstream> include that has both input and output string
  streams.
2017-07-17 15:14:38 +02:00
Mark Olesen
a4c81f5962 ENH: make streams name() methods virtual throughout (issue #479) 2017-07-04 17:17:09 +02:00
Henry Weller
c5630e5cb1 Corrected nullptr collateral damage
Resolves bug-report http://bugs.openfoam.org/view.php?id=2181
2016-08-08 15:38:53 +01:00
Henry Weller
58f905ff70 C++11: Replaced the C NULL with the safer C++11 nullptr
Requires gcc version 4.7 or higher
2016-08-05 17:19:38 +01:00
Henry Weller
a4f8f589de Added forward declaration of friend functions 2016-05-29 22:28:37 +01:00
Henry Weller
f19f48132e Consistently indent continuation backslashes in macro definitions 2016-01-11 13:00:56 +00:00
Henry Weller
56fa7c0906 Update code to use the simpler C++11 template syntax removing spaces between closing ">"s 2016-01-10 22:41:16 +00:00
Henry Weller
94401af010 Resolved issues with virtual function inheritance and warning from clang
Also removed __GNUC__ conditional compilation statements which are no
longer needed.
2015-07-17 12:11:37 +01:00
mattijs
af1f43183c STYLE: variables: have separate token type 2012-10-26 12:10:56 +01:00
Henry
c2dd153a14 Copyright transfered to the OpenFOAM Foundation 2011-08-14 12:17:30 +01:00
Henry
61db7b5bad OpenFOAM library: Add better error messaging from compound token transfer 2011-08-06 23:35:28 +01:00
Henry
84bdcedb33 Changes to template specialization specification for the latest clang version. 2011-06-09 11:58:16 +01:00
andy
d1fdcc2698 STYLE: minor code changes 2011-04-08 10:05:07 +01:00
mattijs
79939b9e18 ENH: #codeStream: preserve across preprocessing
- new token: token::VERBATIMSTRING
- writing of this type in primitiveEntry
- disabling of all functionEntries in entry
2011-02-22 15:29:57 +00:00
mattijs
6d0c6483eb ENH: ISstream: have #{ #} delimiters for verbatim strings 2011-02-18 18:07:02 +00:00
andy
eaef8d482b STYLE: Updated 1991 start copyright year to 2004 2011-01-14 16:08:00 +00:00
andy
099cc39e2e Revert "STYLE: 2011 copyright date."
This reverts commit b18f6cc1ce.
2011-01-05 18:24:29 +00:00
graham
b18f6cc1ce STYLE: 2011 copyright date. 2011-01-05 11:14:26 +00:00
graham
d79237597e STYLE: Fixing code style requirements for all src. 2010-07-28 13:31:46 +01:00
Mark Olesen
b6f3bd4c23 STYLE: follow coding guide recommendation for '//- Destructor' 2010-04-12 11:55:52 +02:00
Mark Olesen
c508b2fe17 STYLE: consistent capitalization of Private/Protected Member Functions in comments 2010-03-30 11:33:42 +02:00
Mark Olesen
d29c438657 STYLE: use url for FSF license instead of postal address, switch to GPL v3 2010-03-29 14:07:56 +02:00
henry
28258d11bd Removed Cint support. 2009-06-23 12:13:33 +01:00
Henry Weller
3345fd8378 Removed support for cint. 2009-06-22 21:03:57 +01:00
Mark Olesen
576d9388f0 Preliminary work on hashing
- Hash returns unsigned
- FixedList templated on unsigned int
- include uLabel.H in UList, HashTable etc. so the output function is know
  throughout
2009-02-27 12:40:37 +01:00
Mark Olesen
ce14f243c6 Removed handling of single-quoted strings. 2009-01-23 15:17:01 +01:00
Mark Olesen
9087cd7b8e Support for single-quoted strings
- token class handles both single and double quoted strings. Single quoted
  strings are used to tag regular expressions. At the moment this is just
  syntactical sugar and isn't (yet) treated differently than double-quoted
  strings.

- write output for std:string, with/without single quotes with the method
  writeQuoted(). Use distinct method name to avoid inadvertent compiler
  conversions.

- write wordRe and keyType using writeQuoted()
2009-01-19 11:33:37 +01:00
Mark Olesen
1d866d7fe8 reworked IOstreams
- Istream and Ostream now retain backslashes when reading/writing strings.
  The previous implementation simply discarded them, except when used to
  escape a double-quote or a newline. It is now vitally important to retain
  them, eg for quoting regular expression meta-characters.

  The backslash continues to be used as an escape character for double-quote
  and newline, but otherwise get passed through "as-is" without any other
  special meaning (ie, they are *NOT* C-style strings). This helps avoid
  'backslash hell'!
  For example,
     string:   "match real dots \.+, question mark \? or any char .*"
     C-style:  "match real dots \\.+, question mark \\? or any char .*"

- combined subfiles in db/IOstreams, some had more copyright info than code
- OPstreamI.H contained only private methods, moved into OPstream.C

Are these really correct?
   IOstreams/Istream.H:#   include "HashTable.C"
   token/token.H:#define NoHashTableC
2009-01-03 12:52:27 +01:00