OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
skipper.hpp
Go to the documentation of this file.
1//
2// Namespace skipper
3//
4// Copyright (c) 2026, Paul Scherrer Institute, Villigen PSI, Switzerland
5// All rights reserved
6//
7// This file is part of OPAL.
8//
9// OPAL is free software: you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation, either version 3 of the License, or
12// (at your option) any later version.
13//
14// You should have received a copy of the GNU General Public License
15// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
16//
17#ifndef SKIPPER_HPP_
18#define SKIPPER_HPP_
19
20#include <cctype>
21#include <cstddef>
22#include <string_view>
23
24namespace SDDS {
25 namespace parser {
26 namespace skipper {
27
28 inline void skipWhitespaceAndComments(std::string_view input, std::size_t& pos) {
29 while (pos < input.size()) {
30 if (std::isspace(static_cast<unsigned char>(input[pos]))) {
31 pos++;
32 } else if (input[pos] == '!') {
33 // Skip comment to end of line.
34 pos++;
35 while (pos < input.size() && input[pos] != '\n') {
36 pos++;
37 }
38 } else if (input[pos] == ',') {
39 // Keep comma behavior aligned with legacy parser semantics.
40 pos++;
41 } else {
42 break;
43 }
44 }
45 }
46
47 } // namespace utils
48 } // namespace parser
49} // namespace SDDS
50
51#endif /* SKIPPER_HPP_ */
void skipWhitespaceAndComments(std::string_view input, std::size_t &pos)
Definition skipper.hpp:28