MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / readLine

Method readLine

TheForceEngine/TFE_System/parser.cpp:77–165  ·  view source on GitHub ↗

Read the next non-comment/whitespace line.

Source from the content-addressed store, hash-verified

75
76// Read the next non-comment/whitespace line.
77const char* TFE_Parser::readLine(size_t& bufferPos, bool skipLeadingWhitespace, bool commentOnlyAtBeginning)
78{
79 if (bufferPos >= m_bufferLen || m_bufferLen < 1) { return nullptr; }
80
81 // Keep reading lines until either one has real content or we reach the end of the buffer.
82 bool lineHasContent = false;
83 s32 skip = -1;
84 while (!lineHasContent && bufferPos < m_bufferLen)
85 {
86 s_line[0] = 0;
87 size_t linePos = 0;
88 bool inComment = false;
89 for (size_t i = bufferPos; i < m_bufferLen; i++)
90 {
91 bufferPos = i + 1;
92
93 if (m_enableBlockComments && i > 0 && m_buffer[i-1] == '*' && m_buffer[i] == '/')
94 {
95 m_blockComment = false;
96 }
97 else if (m_enableBlockComments && m_buffer[i] == '/' && m_buffer[i+1] == '*')
98 {
99 m_blockComment = true;
100 }
101 else if (m_buffer[i] == '\n' || m_buffer[i] == '\r')
102 {
103 // search for the next valid character, then end it.
104 for (size_t ii = i + 1; ii < m_bufferLen; ii++)
105 {
106 if (m_buffer[ii] != '\n' && m_buffer[ii] != '\r')
107 {
108 bufferPos = ii;
109 break;
110 }
111 }
112 break;
113 }
114 else if (!inComment && !m_blockComment)
115 {
116 // is this the beginning of a comment?
117 if (!commentOnlyAtBeginning)
118 {
119 inComment = isComment(m_buffer + i);
120 }
121
122 // if not in a comment, go ahead and add to the line.
123 if (!inComment)
124 {
125 if (m_convertToUppercase)
126 {
127 s_line[linePos++] = toupper(m_buffer[i]);
128 }
129 else
130 {
131 s_line[linePos++] = m_buffer[i];
132 }
133 assert(linePos <= 4096);
134 }

Callers 15

loadMessagesBufferFunction · 0.80
parseVueFunction · 0.80
loadFunction · 0.80
parseModelFunction · 0.80
loadFunction · 0.80
loadKeyNamesFunction · 0.80
project_loadFunction · 0.80
loadConfigFunction · 0.80
loadEditorObj3DFunction · 0.80
preprocessAssetsFunction · 0.80
editor_objectParseSeqFunction · 0.80
loadLevelObjFromAssetFunction · 0.80

Calls 1

isWhitespaceFunction · 0.85

Tested by

no test coverage detected