libStatGen Software 1
SamValidationErrors Class Reference

The SamValidationErrors class is a container class that holds SamValidationError Objects, allowing a validation method to return all of the invalid errors rather than just one. More...

#include <SamValidation.h>

Public Member Functions

 SamValidationErrors ()
 Constructor. More...
 
 ~SamValidationErrors ()
 Destructor. More...
 
void clear ()
 Remove all the errors from the container. More...
 
void addError (SamValidationError::Type newType, SamValidationError::Severity newSeverity, const char *newMessage)
 Add the specified error to this container. More...
 
unsigned int numErrors ()
 Return the number of validation errors contained in this object. More...
 
const SamValidationErrorgetNextError ()
 Return a pointer to the next error without removing it from the container, and returning null once all errors have been retrieved until resetErrorIter is called. More...
 
void resetErrorIter ()
 Reset the iterator to the begining of the errors. More...
 
void getErrorString (std::string &errorString) const
 Append the error messages contained in this container to the passed in string. More...
 

Detailed Description

The SamValidationErrors class is a container class that holds SamValidationError Objects, allowing a validation method to return all of the invalid errors rather than just one.

Definition at line 116 of file SamValidation.h.

Constructor & Destructor Documentation

◆ SamValidationErrors()

SamValidationErrors::SamValidationErrors ( )

Constructor.

Definition at line 103 of file SamValidation.cpp.

104 : myValidationErrors()
105{
106 myErrorIter = myValidationErrors.begin();
107}

◆ ~SamValidationErrors()

SamValidationErrors::~SamValidationErrors ( )

Destructor.

Definition at line 111 of file SamValidation.cpp.

112{
113 clear();
114}
void clear()
Remove all the errors from the container.

References clear().

Member Function Documentation

◆ addError()

void SamValidationErrors::addError ( SamValidationError::Type  newType,
SamValidationError::Severity  newSeverity,
const char *  newMessage 
)

Add the specified error to this container.

Definition at line 132 of file SamValidation.cpp.

135{
136 myValidationErrors.push_back(new SamValidationError(newType,
137 newSeverity,
138 newMessage));
139
140 // If this is the first element in the list, set the iterator.
141 if(myValidationErrors.size() == 1)
142 {
143 // set the iterator to the first element.
144 myErrorIter = myValidationErrors.begin();
145 }
146}
The SamValidationError class describes a validation error that occured, containing the error type,...
Definition: SamValidation.h:35

Referenced by SamValidator::isValid1BasedPos(), SamValidator::isValidCigar(), SamValidator::isValidQname(), SamValidator::isValidQuality(), SamValidator::isValidRefID(), SamValidator::isValidRname(), and SamValidator::isValidTags().

◆ clear()

void SamValidationErrors::clear ( )

Remove all the errors from the container.

Definition at line 117 of file SamValidation.cpp.

118{
119 // Clear the errors.
120 std::list<const SamValidationError*>::iterator errorIter;
121 for(errorIter = myValidationErrors.begin();
122 errorIter != myValidationErrors.end(); ++errorIter)
123 {
124 delete *errorIter;
125 *errorIter = NULL;
126 }
127 myValidationErrors.clear();
128 myErrorIter = myValidationErrors.end();
129}

Referenced by ~SamValidationErrors().

◆ getErrorString()

void SamValidationErrors::getErrorString ( std::string &  errorString) const

Append the error messages contained in this container to the passed in string.

Definition at line 180 of file SamValidation.cpp.

181{
182 for(std::list<const SamValidationError*>::
183 const_iterator validationErrorIter =
184 myValidationErrors.begin();
185 validationErrorIter != myValidationErrors.end();
186 validationErrorIter++)
187 {
188 std::string error = "";
189 (*validationErrorIter)->getErrorString(error);
190 errorString += error;
191 }
192}

Referenced by SamRecord::isValid().

◆ getNextError()

const SamValidationError * SamValidationErrors::getNextError ( )

Return a pointer to the next error without removing it from the container, and returning null once all errors have been retrieved until resetErrorIter is called.

Definition at line 160 of file SamValidation.cpp.

161{
162 if(myErrorIter == myValidationErrors.end())
163 {
164 // at the end of the list, return null.
165 return(NULL);
166 }
167 // Not at the end of the list, return the last element and increment.
168 return(*myErrorIter++);
169}

◆ numErrors()

unsigned int SamValidationErrors::numErrors ( )

Return the number of validation errors contained in this object.

Definition at line 151 of file SamValidation.cpp.

152{
153 return(myValidationErrors.size());
154}

◆ resetErrorIter()

void SamValidationErrors::resetErrorIter ( )

Reset the iterator to the begining of the errors.

Definition at line 173 of file SamValidation.cpp.

174{
175 myErrorIter = myValidationErrors.begin();
176}

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