WSF
WsfParseSourceInclude.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11// ****************************************************************************
12// Updated by Infoscitex, a DCS Company.
13// ****************************************************************************
14
15#ifndef WSFPARSESOURCEINCLUDE_HPP
16#define WSFPARSESOURCEINCLUDE_HPP
17
18#include "UtMemory.hpp"
19#include "UtTextDocument.hpp"
20#include "WsfParseIndex.hpp"
21
22class WsfParseRule;
23
24using WsfParseSourceIncludeId = std::pair<UtTextDocument*, size_t>;
25
30class WSF_PARSER_EXPORT WsfParseSourceInclude
31{
32public:
33 static constexpr std::size_t cVIRTUAL_LOCATION = 0x0fffffff;
34 static const UtTextRange cVIRTUAL_RANGE;
35 static bool IsValidLocation(int aLocation) { return aLocation < 0x0effffff; }
44
46 : mParentPtr(nullptr)
47 , mSourcePtr(nullptr)
48 , mIncludeCount(1)
49 {
50 }
56 void AddInclude(const UtTextRange& aRange, UtTextDocument* aSourcePtr);
57 void AddInclude(const UtTextRange& aRange, WsfParseSourceInclude* aIncludePtr);
59
63 void AddComment(const UtTextRange& aRange, bool aIsLineComment);
64
65 void AddPreprocessorEntry(EntryType aEntryType, const UtTextRange& aRange);
66
68
69 WsfParseSourceInclude* GetRoot();
71 UtTextRange mLocation;
73 UtTextDocument* mSourcePtr;
76
77 class Entry
78 {
79 public:
82 , mIsVirtualInclude(false)
83 , mLocation()
84 , mTargetSource(nullptr)
85 , mIncludePtr(nullptr)
86 {
87 }
88 Entry(const Entry&) = delete;
89 Entry(Entry&&) = default;
90 Entry& operator=(const Entry&) = delete;
91 Entry& operator=(Entry&&) = default;
92 ~Entry() = default;
93
96 UtTextRange mLocation;
97 // valid for include commands
98 UtTextDocument* mTargetSource;
99 // valid for include commands if include_once does not prevent it
100 std::unique_ptr<WsfParseSourceInclude> mIncludePtr;
101 };
102 std::vector<Entry> mEntries;
103
104private:
111 void AddEntryP(EntryType aType,
112 bool aIsVirtualInclude,
113 UtTextRange aLocation,
114 UtTextDocument* aTargetSource,
115 std::unique_ptr<WsfParseSourceInclude> aIncludePtr);
116};
117
118#endif
std::pair< UtTextDocument *, size_t > WsfParseSourceIncludeId
Definition WsfParseSourceInclude.hpp:24
Definition WsfParseRule.hpp:131
Entry()
Definition WsfParseSourceInclude.hpp:80
bool mIsVirtualInclude
Definition WsfParseSourceInclude.hpp:95
EntryType mType
Definition WsfParseSourceInclude.hpp:94
Entry & operator=(Entry &&)=default
Entry(const Entry &)=delete
Entry & operator=(const Entry &)=delete
std::unique_ptr< WsfParseSourceInclude > mIncludePtr
Definition WsfParseSourceInclude.hpp:100
UtTextDocument * mTargetSource
Definition WsfParseSourceInclude.hpp:98
UtTextRange mLocation
Definition WsfParseSourceInclude.hpp:96
Definition WsfParseSourceInclude.hpp:31
std::vector< Entry > mEntries
Definition WsfParseSourceInclude.hpp:102
void AddPreprocessorEntry(EntryType aEntryType, const UtTextRange &aRange)
Definition WsfParseSourceInclude.cpp:119
WsfParseSourceInclude(WsfParseSourceInclude &&)=default
WsfParseSourceInclude()
Definition WsfParseSourceInclude.hpp:45
WsfParseSourceInclude & operator=(const WsfParseSourceInclude &)=delete
void AddComment(const UtTextRange &aRange, bool aIsLineComment)
Definition WsfParseSourceInclude.cpp:102
static bool IsValidLocation(int aLocation)
Definition WsfParseSourceInclude.hpp:35
static constexpr std::size_t cVIRTUAL_LOCATION
Definition WsfParseSourceInclude.hpp:33
UtTextRange mLocation
The location of the include directive. This can be null for the 'main' input file.
Definition WsfParseSourceInclude.hpp:71
size_t mIncludeCount
The number of times this file has been included.
Definition WsfParseSourceInclude.hpp:75
WsfParseSourceInclude * mParentPtr
Definition WsfParseSourceInclude.hpp:72
void AddVirtualInclude(WsfParseSourceInclude *aIncludePtr)
Definition WsfParseSourceInclude.cpp:77
WsfParseSourceIncludeId GetId() const
Definition WsfParseSourceInclude.hpp:67
void AddInclude(const UtTextRange &aRange, UtTextDocument *aSourcePtr)
Definition WsfParseSourceInclude.cpp:37
EntryType
Definition WsfParseSourceInclude.hpp:37
@ cBLOCK_COMMENT
Definition WsfParseSourceInclude.hpp:40
@ cPREPROCESSOR_VARIABLE
Definition WsfParseSourceInclude.hpp:42
@ cLINE_COMMENT
Definition WsfParseSourceInclude.hpp:39
@ cINCLUDE_COMMAND
Definition WsfParseSourceInclude.hpp:38
@ cPREPROCESSOR_DEFINE
Definition WsfParseSourceInclude.hpp:41
UtTextDocument * mSourcePtr
Definition WsfParseSourceInclude.hpp:73
WsfParseSourceInclude & operator=(WsfParseSourceInclude &&)=default
static const UtTextRange cVIRTUAL_RANGE
Definition WsfParseSourceInclude.hpp:19
WsfParseSourceInclude(const WsfParseSourceInclude &)=delete
Copyrights Multiple, All Rights Reserved