Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
FileLineIterator Class Reference

Implements the minimum interface for a range-based for loop iterator. More...

#include <filelineiter.h>

Public Types

enum  {
  DEFAULT = 0x0000 , REMOVE_LINEFEED = DEFAULT , KEEP_LINEFEED = 0x0001 , REMOVE_INLINE_CR = 0x0002 ,
  REMOVE_BLANK_LINES = 0x0004
}
 

Public Member Functions

 FileLineIterator (File *file, int options)
 
const std::string & operator* () const
 
bool operator!= (const FileLineIterator &other) const
 
void operator++ ()
 

Detailed Description

Implements the minimum interface for a range-based for loop iterator.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Allows to read a text file line by line with: for (const std::string& line : FileLines("myfile.txt")) { ... }

More details:

  • The lines are separated by '
    ' (which is removed by default) and have no size limits.
  • Consecutive '
    ' result in empty lines being produced.
  • If not empty, the string after the last '
    ' is produced as the last line.
  • Options are available to keep the trailing '
    ' for each line, to remove carriage-return characters ('\r'), and to remove blank lines.

Definition at line 36 of file filelineiter.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
DEFAULT 
REMOVE_LINEFEED 
KEEP_LINEFEED 
REMOVE_INLINE_CR 
REMOVE_BLANK_LINES 

Definition at line 38 of file filelineiter.h.

Constructor & Destructor Documentation

◆ FileLineIterator()

FileLineIterator::FileLineIterator ( File * file,
int options )
inline

Definition at line 46 of file filelineiter.h.

Member Function Documentation

◆ operator!=()

bool FileLineIterator::operator!= ( const FileLineIterator & other) const
inline

Definition at line 54 of file filelineiter.h.

◆ operator*()

const std::string & FileLineIterator::operator* ( ) const
inline

Definition at line 53 of file filelineiter.h.

◆ operator++()

void FileLineIterator::operator++ ( )
inline

Definition at line 57 of file filelineiter.h.


The documentation for this class was generated from the following file: