10#include "IException.h"
49 istream::pos_type beforeKeywordPos = is.tellg();
53 if(is.eof() && !is.bad()) {
57 is.seekg(beforeKeywordPos, ios::beg);
59 QString msg =
"Expected PVL keyword named [Group], found keyword named [";
60 msg += readKeyword.
name();
61 msg +=
"] when reading PVL";
65 if(readKeyword.
size() == 1) {
69 if(is.eof() && !is.bad()) {
73 is.seekg(beforeKeywordPos, ios::beg);
75 QString msg =
"Expected a single value for group name, found [(";
77 for(
int i = 0; i < readKeyword.
size(); i++) {
78 if(i != 0) msg +=
", ";
80 msg += readKeyword[i];
83 msg +=
")] when reading PVL";
88 for(
int comment = 0; comment < readKeyword.
comments(); comment++) {
89 result.addComment(readKeyword.
comment(comment));
93 beforeKeywordPos = is.tellg();
96 while(is.good() && readKeyword != termination) {
97 for(
unsigned int errorKey = 0;
98 errorKey <
sizeof(errorKeywords) /
sizeof(
PvlKeyword);
101 if(readKeyword == errorKeywords[errorKey]) {
102 if(is.eof() && !is.bad()) {
106 is.seekg(beforeKeywordPos, ios::beg);
108 QString msg =
"Unexpected [";
109 msg += readKeyword.
name();
110 msg +=
"] in Group [";
111 msg += result.
name();
112 msg +=
"] when reading PVL";
119 beforeKeywordPos = is.tellg();
124 if(readKeyword != termination) {
125 if(is.eof() && !is.bad()) {
130 is.seekg(beforeKeywordPos, ios::beg);
132 QString msg =
"Group [" + result.
name();
133 msg +=
"] EndGroup not found before end of file when reading PVL";
148 bool removeFormatter =
false;
149 if(group.format() == NULL) {
151 removeFormatter =
true;
155 if(group.hasFormatTemplate()) temp = *(
Isis::PvlGroup *)group.formatTemplate();
158 if(temp.comments() > 0) {
159 for(
int k = 0; k < temp.comments(); k++) {
160 for(
int l = 0; l < group.indent(); l++) os <<
" ";
161 os << temp.comment(k) << group.format()->formatEOL();
167 os << group.nameKeyword() << group.format()->formatEOL();
168 group.setIndent(group.indent() + 2);
176 group.setIndent(group.indent() - 2);
177 for(
int i = 0; i < group.indent(); i++) os <<
" ";
178 os << group.format()->formatEnd(
"End_Group", group.nameKeyword());
180 if(removeFormatter) {
181 delete group.format();
182 group.setFormat(NULL);
211 QString sErrMsg =
"Group \"" + pPvlGrp.
name() +
"\" has no Keywords\n";
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Contains more than one keyword-value pair.
PvlContainer(const QString &type)
Constructs a PvlContainer object with a type.
const PvlContainer & operator=(const PvlContainer &other)
This is an assignment operator.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
void setName(const QString &name)
Set the name of the container.
QString name() const
Returns the container name.
void validateAllKeywords(PvlContainer &pPvlCont)
Validate All the Keywords in a Container comparing with the Template.
void addKeyword(const PvlKeyword &keyword, const InsertMode mode=Append)
Add a keyword to the container.
Contains multiple PvlContainers.
PvlGroup()
Creates a blank PvlGroup object.
const PvlGroup & operator=(const PvlGroup &other)
This is an assignment operator.
void validateGroup(PvlGroup &pPvlGrp)
Validate a Group comparing with the Template Group.
A single keyword-value pair.
QString name() const
Returns the keyword name.
int size() const
Returns the number of values stored in this keyword.
int comments() const
Returns the number of lines of comments associated with this keyword.
QString comment(const int index) const
Return a comment at the specified index.
This is free and unencumbered software released into the public domain.
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Namespace for the standard library.