This file is indexed.

/usr/include/wallssurveyparser.h is in libdewalls-dev 1.0.0+ds1-4ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
#ifndef DEWALLS_WALLSPARSER_H
#define DEWALLS_WALLSPARSER_H

#include <QObject>
#include <QString>
#include <QHash>
#include <QSharedPointer>
#include <QStack>

#include "lineparser.h"
#include "unitizeddouble.h"
#include "length.h"
#include "angle.h"
#include "cardinaldirection.h"
#include "varianceoverride.h"
#include "wallstypes.h"
#include "wallsunits.h"
#include "vector.h"
#include "fixstation.h"
#include "wallsmessage.h"
#include "dewallsexport.h"

namespace dewalls {

///
/// \brief parses Walls .SRV files
/// You pass in lines frme the .SRV file to parse to parseLine(), and the parser will emit
/// signals for the various types of data it parses.  The parsed data must be interpreted
/// in the context of the current units(), date(), and segment().
///
class DEWALLS_LIB_EXPORT WallsSurveyParser : public QObject, public LineParser
{
    Q_OBJECT

public:
    typedef UnitizedDouble<Length> ULength;
    typedef UnitizedDouble<Angle>  UAngle;
    typedef QSharedPointer<VarianceOverride> VarianceOverridePtr;
    typedef void (WallsSurveyParser::*OwnProduction)();

    WallsSurveyParser();
    WallsSurveyParser(QString line);
    WallsSurveyParser(Segment segment);

    ///
    /// \brief parses the current line (which must be set by calling reset(line))
    ///
    void parseLine();
    ///
    /// \brief parses a line from a .SRV file.  This method is designed for testing
    /// and doesn't allow you to pass in the source file and line number; prefer
    /// using parseLine(Segment) instead.
    ///
    void parseLine(QString line);
    ///
    /// \brief this is the ideal method to call to parse a line of a .SRV file.
    ///
    void parseLine(Segment line);
    ///
    /// \brief parses units options that come after "#units"
    /// this can be used to parse options given by a .OPTIONS line in
    /// a .WPJ file
    ///
    void parseUnitsOptions(Segment options);

    ///
    /// \return the current Walls units (from #units directives)
    ///
    WallsUnits units() const;
    ///
    /// \return the current date associated with the data (from #date directives)
    ///
    QDate date() const;
    ///
    /// \return the current segment associated with the data (from #segment directives)
    ///
    QStringList segment() const;
    ///
    /// \return the segment that a #segment path starting with \ or / will switch back to
    ///
    QStringList rootSegment() const;
    QHash<QString, QString> macros() const;

    ///
    /// \brief sets the walls #segment.  Used for passing in name-defined segments from
    /// project files.
    ///
    void setSegment(QStringList segment);
    ///
    /// \brief sets the root #segment, which should be set to a name-defined segment
    /// from a project file.
    ///
    void setRootSegment(QStringList rootSegment);

    ULength unsignedLengthInches();
    ULength unsignedLengthNonInches(Length::Unit defaultUnit);
    ULength unsignedLength(Length::Unit defaultUnit);
    ULength length(Length::Unit defaultUnit);

    UAngle unsignedAngle(QHash<QChar, Angle::Unit> unitSuffixes, Angle::Unit defaultUnit);
    UAngle unsignedDmsAngle();

    UAngle latitude();
    UAngle longitude();

    UAngle nonQuadrantAzimuth(Angle::Unit defaultUnit);
    UAngle quadrantAzimuth();
    UAngle azimuth(Angle::Unit defaultUnit);
    UAngle azimuthOffset(Angle::Unit defaultUnit);

    UAngle unsignedInclination(Angle::Unit defaultUnit);
    UAngle inclination(Angle::Unit defaultUnit);

    VarianceOverridePtr varianceOverride(Length::Unit defaultUnit);
    VarianceOverridePtr floatedVectorVarianceOverride();
    VarianceOverridePtr floatedTraverseVarianceOverride();
    VarianceOverridePtr lengthVarianceOverride(Length::Unit defaultUnit);
    VarianceOverridePtr rmsErrorVarianceOverride(Length::Unit defaultUnit);

    template<typename F>
    QChar escapedChar(F charPredicate, std::initializer_list<QString> expectedItems);
    template<typename F>
    QString escapedText(F charPredicate, std::initializer_list<QString> expectedItems);
    QString quotedTextOrNonwhitespace();
    QString quotedText();

    template<typename R, typename F>
    bool optional(R& result, F production);

    template<typename R, typename F>
    bool optionalWithLookahead(R& result, F production);

    template<typename T>
    QList<T> elementChars(QHash<QChar, T> elements, QSet<T> requiredElements);

    void beginBlockCommentLine();
    void endBlockCommentLine();
    void insideBlockCommentLine();

    void directiveLine();
    void segmentLine();
    void prefixLine();
    void noteLine();
    void flagLine();
    void symbolLine();
    void dateLine();
    void unitsLine();
    void vectorLine();

signals:
    void parsedVector(Vector parsedVector);
    void parsedFixStation(FixStation station);
    void parsedComment(QString parsedComment);
    void parsedNote(QString station, QString parsedNote);
    void parsedDate(QDate date);
    void parsedFlag(QStringList stations, QString flag);
    void willParseUnits();
    void parsedUnits();
    void parsedSegment(QString segment);
    void message(WallsMessage message);

private:
    static double approx(double val);

    static QHash<QString, Length::Unit> createLengthUnits();
    static QHash<QString, Angle::Unit> createAzmUnits();
    static QHash<QString, Angle::Unit> createIncUnits();
    static QHash<QChar, Length::Unit> createLengthUnitSuffixes();
    static QHash<QChar, Angle::Unit> createAzmUnitSuffixes();
    static QHash<QChar, Angle::Unit> createIncUnitSuffixes();
    static QHash<QChar, CardinalDirection> createCardinalDirections();
    static QHash<QChar, CardinalDirection> createNorthSouth();
    static QHash<QChar, CardinalDirection> createEastWest();
    static QHash<QChar, QChar> createEscapedChars();
    static QHash<QChar, CtMeasurement> createCtElements();
    static QHash<QChar, RectMeasurement> createRectElements();
    static QHash<QChar, LrudMeasurement> createLrudElements();
    static QHash<QString, bool> createCorrectedValues();
    static QHash<QString, CaseType> createCaseTypes();
    static QHash<QString, LrudType> createLrudTypes();
    static QHash<QString, QList<TapingMethodMeasurement>> createTapingMethods();
    static QHash<QString, int> createPrefixDirectives();
    static QHash<QString, OwnProduction> createUnitsOptionMap();
    static QHash<QString, OwnProduction> createDirectivesMap();

    static const QHash<QString, Length::Unit> lengthUnits;
    static const QHash<QString, Angle::Unit> azmUnits;
    static const QHash<QString, Angle::Unit> incUnits;
    static const QHash<QChar, Length::Unit> lengthUnitSuffixes;
    static const QHash<QChar, Angle::Unit> azmUnitSuffixes;
    static const QHash<QChar, Angle::Unit> incUnitSuffixes;
    static const QHash<QChar, CardinalDirection> cardinalDirections;
    static const QHash<QChar, CardinalDirection> northSouth;
    static const QHash<QChar, CardinalDirection> eastWest;
    static const QHash<QChar, QChar> escapedChars;
    static const QHash<QChar, CtMeasurement> ctElements;
    static const QSet<CtMeasurement> requiredCtElements;
    static const QHash<QChar, RectMeasurement> rectElements;
    static const QSet<RectMeasurement> requiredRectElements;
    static const QHash<QChar, LrudMeasurement> lrudElements;
    static const QSet<LrudMeasurement> requiredLrudElements;
    static const QHash<QString, bool> correctedValues;
    static const QHash<QString, CaseType> caseTypes;
    static const QHash<QString, LrudType> lrudTypes;
    static const QHash<QString, QList<TapingMethodMeasurement>> tapingMethods;
    static const QHash<QString, int> prefixDirectives;

    static const QRegExp wordRx;
    static const QRegExp notSemicolonRx;
    static const QRegExp unitsOptionRx;
    static const QRegExp directiveRx;
    static const QRegExp macroNameRx;
    static const QRegExp stationRx;
    static const QRegExp prefixRx;

    static const QRegExp optionalRx;
    static const QRegExp optionalStationRx;

    static const QRegExp isoDateRx;
    static const QRegExp usDateRx1;
    static const QRegExp usDateRx2;
    static const QRegExp usDateRx3;

    static const QRegExp segmentPartRx;

    static const QHash<QString, OwnProduction> unitsOptionMap;
    static const QHash<QString, OwnProduction> directivesMap;

    static const UAngle oneEighty;

    UAngle azmDifference(UAngle fs, UAngle bs);
    UAngle incDifference(UAngle fs, UAngle bs);

    void replaceMacros();
    QString movePastEndQuote();
    QString replaceMacro();

    Segment untilComment(std::initializer_list<QString> expectedItems);

    void segmentSeparator();
    QString initialSegmentPart();
    QString nonInitialSegmentPart();
    QStringList segmentPath();
    QStringList segmentDirective();
    void prefixDirective();
    void noteDirective();

    void flagDirective();
    QString slashPrefixedFlag();

    QDate dateDirective();
    QDate isoDate();
    QDate usDate1();
    QDate usDate2();
    QDate usDate3();

    void unitsOptions();
    void unitsOption();
    void macroOption();
    void save();
    void restore();
    void reset_();
    void meters();
    void feet();
    void ct();
    void d();
    void s();
    void a();
    void ab();
    void a_ab();
    void v();
    void vb();
    void v_vb();
    void order();
    void ctOrder();
    void rectOrder();
    void decl();
    void grid();
    void rect();
    void incd();
    void inch();
    void incs();
    void inca();
    void incab();
    void incv();
    void incvb();
    void typeab();
    void typevb();
    void case_();
    void lrud();
    void lrudOrder();
    void prefix1();
    void prefix2();
    void prefix3();
    void prefix(int index);
    void tape();
    void uvh();
    void uvv();
    void uv();
    void flag();

    void checkCorrectedSign(int segStart, ULength measurement, ULength correction);

    Segment station();

    void fromStation();
    void afterFromStation();
    void toStation();
    void afterToStation();
    void rectMeasurement(RectMeasurement elem);
    void east();
    void north();
    void rectUp();
    void ctMeasurement(CtMeasurement elem);
    void distance();
    void azimuth();
    void inclination();
    void instrumentHeight();
    void targetHeight();
    void lrudMeasurement(LrudMeasurement elem);
    void left();
    void right();
    void up();
    void down();
    template<class T> void warnIfNegative(UnitizedDouble<T> measurement, int start, QString name);
    void afterVectorMeasurements();
    template<class T> void varianceOverrides(T& target);
    void afterVectorVarianceOverrides();
    void lruds();
    void lrudContent();
    void afterRequiredLrudMeasurements();
    void lrudFacingAngle();
    void lrudCFlag();
    void afterLruds();
    void inlineDirective();
    template<class T> void inlineNote(T& target);
    template<class T> void inlineSegmentDirective(T& target);
    template<class T> void inlineCommentOrEndOfLine(T& target);
    template<class T> void inlineComment(T& target);

    void inlineCommentOrEndOfLine();
    void inlineComment();

    void fixLine();
    void fixedStation();
    void afterFixedStation();
    void fixRectMeasurement(RectMeasurement elem);
    void fixEast();
    void fixNorth();
    void fixUp();
    void afterFixMeasurements();
    void afterFixVarianceOverrides();
    void afterInlineFixNote();
    void inlineFixDirective();

    void comment();

    bool _inBlockComment;
    WallsUnits _units;
    QStack<WallsUnits> _stack;
    QHash<QString, QString> _macros;
    QStringList _segment;
    QStringList _rootSegment;
    QDate _date;

    bool _parsedSegmentDirective;
    Segment _fromStationSegment;
    Segment _toStationSegment;
    Segment _azmSegment;
    Segment _incSegment;

    Vector _vector;
    FixStation _fixStation;
};

inline WallsUnits WallsSurveyParser::units() const
{
    return _units;
}

inline QHash<QString, QString> WallsSurveyParser::macros() const
{
    return _macros;
}

inline QDate WallsSurveyParser::date() const
{
    return _date;
}

inline QStringList WallsSurveyParser::rootSegment() const
{
    return _rootSegment;
}

inline void WallsSurveyParser::setRootSegment(QStringList rootSegment)
{
    _rootSegment = rootSegment;
}

inline QStringList WallsSurveyParser::segment() const
{
    return _segment;
}

inline void WallsSurveyParser::setSegment(QStringList segment)
{
    _segment = segment;
}

template<typename F>
QChar WallsSurveyParser::escapedChar(F charPredicate, std::initializer_list<QString> expectedItems)
{
    QChar c = expectChar(charPredicate, expectedItems);
    return c == '\\' ? oneOfMap(escapedChars) : c;
}

template<typename F>
QString WallsSurveyParser::escapedText(F charPredicate, std::initializer_list<QString> expectedItems)
{
    QString result;
    while (maybe([&]() { result.append(escapedChar(charPredicate, expectedItems)); } ));
    return result;
}

template<typename R, typename F>
bool WallsSurveyParser::optional(R& result, F production)
{
    try
    {
        result = production();
    }
    catch (const SegmentParseExpectedException& ex)
    {
        if (maybe([&]() { return expect(optionalRx, {"-", "--"}); }))
        {
            return false;
        }
        throw;
    }

    return true;
}

template<typename R, typename F>
bool WallsSurveyParser::optionalWithLookahead(R& result, F production)
{
    int start = _i;
    try
    {
        result = production();
    }
    catch (const SegmentParseExpectedException& ex)
    {
        _i = start;
        if (maybe([&]() { return expect(optionalRx, {"-", "--"}); }))
        {
            return false;
        }
        throw;
    }

    return true;
}

template<typename T>
QList<T> WallsSurveyParser::elementChars(QHash<QChar, T> elements, QSet<T> requiredElements)
{
    QList<T> result;
    while (!elements.isEmpty())
    {
        T element;
        if (requiredElements.isEmpty()) {
            if (!maybe(element, [&]() { return oneOfMap(elements); }))
            {
                break;
            }
        }
        else {
            element = oneOfMap(elements);
        }
        result += element;
        QChar c = _line.at(_i - 1);
        elements.remove(c.toLower());
        elements.remove(c.toUpper());
        requiredElements -= element;
    }
    return result;
}

} // namespace dewalls

#endif // DEWALLS_WALLSPARSER_H