9 #include "PvlKeyword.h"
10 #include "IException.h"
11 #include "PvlFormat.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";