Skip to content

Add line range to input::SourceFile#311

Merged
GabrielDosReis merged 1 commit intomainfrom
gdr/input-lines
Jun 4, 2025
Merged

Add line range to input::SourceFile#311
GabrielDosReis merged 1 commit intomainfrom
gdr/input-lines

Conversation

@GabrielDosReis
Copy link
Copy Markdown
Owner

To iterate (one-pass) over physical lines from an input source file, assumed to have UTF-8 encoded contents.


inline SourceFile::LineRange SourceFile::lines() const noexcept
{
return LineRange{*this};

Check warning

Code scanning / PREfast

The function is declared 'noexcept' but calls function 'LineRange()' which may throw exceptions (f.6). Warning

The function is declared 'noexcept' but calls function 'LineRange()' which may throw exceptions (f.6).
throw FileMappingError{ path, GetLastError() };
auto start = MapViewOfFile(mapping.get_handle(), FILE_MAP_READ, 0, 0, 0);
view = { reinterpret_cast<const std::byte*>(start), static_cast<View::size_type>(s.QuadPart) };
view = { reinterpret_cast<const char8_t*>(start), static_cast<View::size_type>(s.QuadPart) };

Check warning

Code scanning / PREfast

Don't use reinterpret_cast. A cast from void* can use static_cast (type.1). Warning

Don't use reinterpret_cast. A cast from void* can use static_cast (type.1).
throw FileMappingError{ path, GetLastError() };
auto start = MapViewOfFile(mapping.get_handle(), FILE_MAP_READ, 0, 0, 0);
view = { reinterpret_cast<const std::byte*>(start), static_cast<View::size_type>(s.QuadPart) };
view = { reinterpret_cast<const char8_t*>(start), static_cast<View::size_type>(s.QuadPart) };

Check warning

Code scanning / PREfast

Don't use a static_cast for arithmetic conversions. Use brace initialization, gsl::narrow_cast or gsl::narrow (type.1). Warning

Don't use a static_cast for arithmetic conversions. Use brace initialization, gsl::narrow_cast or gsl::narrow (type.1).
@GabrielDosReis GabrielDosReis merged commit 72e6288 into main Jun 4, 2025
8 checks passed
@GabrielDosReis GabrielDosReis deleted the gdr/input-lines branch June 4, 2025 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants