Commit Graph

43 Commits

Author SHA1 Message Date
Jørgen Kvalsvik
8a4eb5279c Splitting records with string_view; test updates
The splitting of RawRecords into individual symbols uses string_view.
Also updates tests since RawRecord now assumes that the record string it
receives is complete and does *not* contain the terminating slash.
2016-05-03 09:16:28 +02:00
Jørgen Kvalsvik
0da5cadc75 RawRecords auto store, strings moved to RawRecord
The accumulated strings are moved into RawRecords, which reduces
execution time (rough measurements indicates 4-8%). To facilitate this,
RawRecords are stored directly in the vector in favour of via
shared_ptrs.
2016-03-22 08:58:48 +01:00
Jørgen Kvalsvik
f0ae5db131 opm-parser adoption of Deck automatic ownership
Since the Deck* family of classes have changed their interfaces to no
longer use shared_ptr, a lot of code broke. This patch fixes all
problems in tests, other signatures and accesses to now use the new Deck
interfaces.
2016-02-18 13:27:24 +01:00
Jørgen Kvalsvik
8b12fda9c3 Remove unused FloatItem classes
ParserItemFloat and DeckItemFloat is never used within the project.
2016-02-03 12:22:41 +01:00
Andreas Lauser
0262b333fd make items which do not have a default un-defaultable
this was a much more common problem than it seemed initially...
2014-12-18 11:43:52 +01:00
Andreas Lauser
ea38a25af4 remove all trailing white space
this is just the result of

```
find -iname "*.[ch]pp" | xargs sed -i "s/ *$//"
find opm/parser/share/keywords -type f |  xargs sed -i "s/ *$//"
```

so if it causes conflicts with other patches, the others should get
priority. The rationale behind this patch is that some people tell
their editor to remove white space which leads to larger than
necessary patches...
2014-12-08 16:34:28 +01:00
Andreas Lauser
6eb3421f38 Handle quotes better
This allows to arbitrary characters like stars into strings. e.g.

MYKEYWORD
'123*456' 2*'Hello, World! (*)' /

is now a valid record with three strings while it threw an exception
before.

This patch works by transferring the removal of the quotes from the
RawDeck class to the readValueToken<T>() function which now has a
specialization for strings that deals with quotes. One small
complication is that the RawDeck needs to be adapted in order not to
split tokens in the middle of strings.

Finally, the StarToken class does not deal with the conversion from
string to the value type of the item anymore which allows it to become
a normal class instead of a template...
2014-11-05 13:05:22 +01:00
Andreas Lauser
e014896e35 add more explicit unit test for defaulted deck items
(the ParserItemTests already have one (Scan_All_WithDefaults) but a
second one won't hurt...)
2014-09-15 12:17:03 +02:00
Andreas Lauser
b72df6f406 make ParserItems always defaultable
i.e. remove the defaultSet() method and its friends. this is required
to be able to specify defaults in DATA items like grid properties or
saturation tables. e.g.

SGL
10*0.1 10* 10*0.2 /

would not be possible without this. If no meaningful default for an
item is defined, float and double items get NaN, int items get -1 and
string ones get an empty string. The hope is that if these values get
used in the simulation, they will make the result obviously
incorrect. (Whether a data point of an item was defaulted can be
queried using item->defaultApplied(index).)
2014-09-15 12:17:03 +02:00
Andreas Lauser
539c7a23ae make the defaults of an item settable per data point
instead of for the whole item...
2014-09-15 12:17:03 +02:00
Andreas Lauser
09d9508c39 remove the 'ParserBoolItem.[ch]pp' files
they were empty and as far as I can see, Eclipse does not have the
concept of boolean items...
2014-09-15 12:17:03 +02:00
Joakim Hove
bf35919c6f Default: Changed default handling in ParserItem
This is the first of several large commits changing several aspects of
the handling of defaults. The overall main purpose of these changes is
to protect against using non sensible values in the case the values have
not been sensibly specified in the deck. The changes in this commit
include:

 1. The "default default" values to be used when an item without an
    explicit default are defaulted are removed completely.

 2. If a ParserItem is queried for a default value when no default has
    been assigned it will raise an exception.
2014-09-03 10:37:00 +02:00
Joakim Hove
f59fd25668 Added boolan flag scalar = true to DeckItem.
The purpose of this flag is to keep track of whether a keyword is
supposed to have only one element, i.e. scalar, or several. The
defaultApplied method only makes sense in the case of scalar items, this
method will now throw if it is called on a non-scalar item.
2014-04-11 13:42:22 +02:00
Atle Haugan
442d0fb7bf Added ParserFloatItem + some tests. More tests may be needed. 2014-02-18 11:02:38 +01:00
Andreas Lauser
0129a382a8 units: Replace "L" by "Length" 2014-02-11 12:45:43 +01:00
Andreas Lauser
6a97d78cc6 units: replace "t" with "Time"
this makes things more explicit and more readable
2014-02-11 12:45:41 +01:00
Atle Haugan
ddd4563f97 Renamed from 'help' to 'description' for ParserKeyword and ParserItem 2014-01-10 10:57:35 +01:00
Atle Haugan
3271156f9d First pull request candidate with help support 2014-01-09 13:33:32 +01:00
Joakim Hove
7f213e4e9f Added check that dimensions are equal in ParserDoubleItem::equal() 2013-12-11 13:25:42 +01:00
Joakim Hove
ac740276f0 Added virtual function push_backDimension() and getDimension() to parserItem. 2013-12-11 13:24:27 +01:00
Joakim Hove
dd53619e0f Added functions to query the dimensions on a ParserItem. 2013-12-10 17:34:52 +01:00
Joakim Hove
bb8b3ab240 Added ability to push_back() dimension strings to ParserItems; and then to query the
ParserItem -> ParserRecord -> ParserKeyword() structure whether it has dimension.
2013-12-09 21:12:27 +01:00
Joakim Hove
91704558a6 Added test for compile time polymorphism 2013-10-28 10:00:40 +01:00
Joakim Hove
d1f0a9f5f7 Moved some tests around 2013-10-14 14:15:44 +02:00
Joakim Hove
fb7dc690d1 Added defaultApplied() method to DeckItem - and FAILING test 2013-10-10 13:32:05 +02:00
Joakim Hove
0afbcfc6e4 sizeType is default set to SINGLE - and optional in Json config 2013-09-18 07:16:09 +02:00
Joakim Hove
3992a32efc Made sizeType : SINGLE default 2013-09-17 22:27:53 +02:00
Joakim Hove
c11fdeeb42 Added ParserRecord::equal() method 2013-09-13 10:16:00 +02:00
Joakim Hove
5284b4ff89 Added equal() method for the ParserItem classes 2013-09-12 10:58:44 +02:00
Kristian Flikka
771167c02e Removed ParserXItem's scan with expected elements. Only SINGLE and ALL is now allowed 2013-08-23 14:35:47 +02:00
Kristian Flikka
375332eb99 Added check if rawRecord is empty, then default is used. Added some json data 2013-08-23 14:20:32 +02:00
Joakim Hove
fe070640ad Added test for ParserDoubleItem 2013-08-09 09:12:55 +02:00
Joakim Hove
7b9206f675 Added Json config to ParserStringItem 2013-07-31 16:24:26 +02:00
Joakim Hove
6c582a4b82 Added JsonConfig constructor to ParserIntItem 2013-07-31 16:15:22 +02:00
Joakim Hove
20a283e5d0 Added 2String and FromString methods to the Enums 2013-07-31 15:48:15 +02:00
Kristian Flikka
5fa04e5377 Added/implemented XStringItem for Parser and Deck, with tests. Added integration test for WWCT keyword. Moved DeckItem tests into type-specific files. Removed unused file. 2013-06-20 13:56:11 +02:00
Kristian Flikka
7998a84b81 Made the ParserIntItem's scan return DeckItem, and put a virtual scan in ParserItem. The ParserRecord now has a simple, but functioning parse method 2013-05-24 10:09:59 +02:00
Joakim Hove
6b338d09e7 Added skeleton implementation of DeckRecord 2013-05-14 21:23:34 +02:00
Joakim Hove
6f86bebf78 Removed ParserItemSize class; will just use plain enum 2013-05-09 12:16:15 +02:00
Kristian Flikka
a874d667db Added some tests 2013-05-08 15:50:20 +02:00
Kristian Flikka
2a331e1a3a ParserIntItem's scan function now supports ITEM_FIXED parsing 2013-05-08 15:29:58 +02:00
Kristian Flikka
2088c3e96d Simple scan implementation in ParserIntItem added. DeckIntItem now support push_back 2013-05-08 14:31:20 +02:00
Kristian Flikka
2d6e6842d6 Changed ParserItem from template based to a base-inheritance based system. Corresponds to and creates DeckItem objects 2013-05-07 21:55:49 +02:00