src/utilities/idf/IdfRegex.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*********************************************************************************************************************** | ||
| 2 | * OpenStudio(R), Copyright (c) Alliance for Energy Innovation, LLC. | ||
| 3 | * See also https://openstudio.net/license | ||
| 4 | ***********************************************************************************************************************/ | ||
| 5 | |||
| 6 | #include "IdfRegex.hpp" | ||
| 7 | |||
| 8 | namespace openstudio { | ||
| 9 | namespace idfRegex { | ||
| 10 | |||
| 11 | // todo, I have capitalized all these functions as they are static, is that right | ||
| 12 | 18449850 | const std::string& newLinestring() { | |
| 13 |
3/4✓ Branch 0 taken 861 times.
✓ Branch 1 taken 18448989 times.
✓ Branch 3 taken 861 times.
✗ Branch 4 not taken.
|
18449850 | static const std::string result("\n"); |
| 14 | 18449850 | return result; | |
| 15 | } | ||
| 16 | |||
| 17 | // Match an optional new line | ||
| 18 | // matches[1], before new line and new line | ||
| 19 | // matches[2], after new line | ||
| 20 | 867 | const std::string& optionalNewLinestring() { | |
| 21 |
3/7✓ Branch 0 taken 867 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 867 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 867 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
2601 | static const std::string result("([^\\n]*[\\n]?)(.*)"); |
| 22 | 867 | return result; | |
| 23 | } | ||
| 24 | |||
| 25 | // Match comment only line | ||
| 26 | // matches[1], the comment | ||
| 27 | // matches[2], after new line | ||
| 28 | 25378703 | const boost::regex& commentOnlyLine() { | |
| 29 |
4/7✓ Branch 0 taken 867 times.
✓ Branch 1 taken 25377836 times.
✓ Branch 3 taken 867 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 867 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
25378703 | static const boost::regex result("^[\\s\\t]*[!]([^\\n]*)[\\n]?(.*)"); |
| 30 | 25378703 | return result; | |
| 31 | } | ||
| 32 | |||
| 33 | // Match content and comment | ||
| 34 | // matches[1], the content (may include multiple fields) | ||
| 35 | // matches[2], the comment | ||
| 36 | ✗ | const boost::regex& contentAndCommentLine() { | |
| 37 | ✗ | static const boost::regex result("^([^!,;]*)[,;]?[\\s\\t]*[!]?(.*)"); //("^((?:[^!,;]*[,;])*)[\\s\\t]*[!]?(.*)"); | |
| 38 | ✗ | return result; | |
| 39 | } | ||
| 40 | |||
| 41 | // Match object end in the idf | ||
| 42 | 17263446 | const boost::regex& objectEnd() { | |
| 43 |
4/7✓ Branch 0 taken 861 times.
✓ Branch 1 taken 17262585 times.
✓ Branch 3 taken 861 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 861 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
17263446 | static const boost::regex result("^[^!]*?[;].*"); |
| 44 | 17263446 | return result; | |
| 45 | } | ||
| 46 | |||
| 47 | // Match line with an object type and name | ||
| 48 | // matches[1], before first separator | ||
| 49 | // matches[2], after first separator and before second separator | ||
| 50 | 138690 | const boost::regex& objectTypeAndName() { | |
| 51 |
4/7✓ Branch 0 taken 115 times.
✓ Branch 1 taken 138575 times.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 115 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
138690 | static const boost::regex result("^([^!]*?)[,;]([^!]*?)[,;]"); |
| 52 | 138690 | return result; | |
| 53 | } | ||
| 54 | |||
| 55 | // Match line with either a ',' or a ';' that are not preceded by '!' | ||
| 56 | // matches[1], before separator | ||
| 57 | // matches[2], after separator and before new line | ||
| 58 | // matches[3], after new line | ||
| 59 | 22841344 | const boost::regex& line() { | |
| 60 |
6/9✓ Branch 0 taken 867 times.
✓ Branch 1 taken 22840477 times.
✓ Branch 3 taken 867 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 867 times.
✓ Branch 9 taken 867 times.
✓ Branch 12 taken 867 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
|
22841344 | static const boost::regex result("^([^!]*?)[,;]" + optionalNewLinestring()); |
| 61 | 22841344 | return result; | |
| 62 | } | ||
| 63 | |||
| 64 | // Match an autosize field | ||
| 65 | ✗ | const boost::regex& autosize() { | |
| 66 | ✗ | static const boost::regex result("autosize", boost::regex_constants::icase); | |
| 67 | ✗ | return result; | |
| 68 | } | ||
| 69 | |||
| 70 | // Match an autocalculate field | ||
| 71 | ✗ | const boost::regex& autocalculate() { | |
| 72 | ✗ | static const boost::regex result("autocalculate", boost::regex_constants::icase); | |
| 73 | ✗ | return result; | |
| 74 | } | ||
| 75 | |||
| 76 | // Match line with '##def' preceded only by whitespace | ||
| 77 | // matches[1], the imf section name | ||
| 78 | 145590 | const boost::regex& imfSection() { | |
| 79 |
4/7✓ Branch 0 taken 115 times.
✓ Branch 1 taken 145475 times.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 115 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
145590 | static const boost::regex result("^[\\s\\t]*##[\\s\\t]*def[\\s\\t]*(.*?)\\[(.*?)\\]"); |
| 80 | 145590 | return result; | |
| 81 | } | ||
| 82 | |||
| 83 | 142140 | const boost::regex& imfSectionEnd() { | |
| 84 |
4/7✓ Branch 0 taken 115 times.
✓ Branch 1 taken 142025 times.
✓ Branch 3 taken 115 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 115 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
142140 | static const boost::regex result("^[\\s\\t]*##[\\s\\t]*enddef[\\s\\t]*"); |
| 85 | 142140 | return result; | |
| 86 | } | ||
| 87 | |||
| 88 | } // namespace idfRegex | ||
| 89 | } // namespace openstudio | ||
| 90 |