File failed to load: https://isis.astrogeology.usgs.gov/9.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
PvlObject.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "PvlObject.h"
8
9#include "FileName.h"
10#include "Pvl.h"
11#include "IException.h"
12#include "IString.h"
13#include "Message.h"
14#include "PvlFormat.h"
15
16#include <QList>
17
18#include <iostream>
19#include <sstream>
20
21using namespace std;
22using json = nlohmann::json;
23namespace Isis {
24
27 }
28
29
35 PvlObject::PvlObject(const QString &name) :
36 Isis::PvlContainer("Object", name) {
37 }
38
39
43 m_objects = other.m_objects;
44 m_groups = other.m_groups;
45 }
46
47
48
60 PvlObject::PvlObject(const QString &name, const json &jsonobj) :
61 PvlContainer("Object", name) {
62
63 for(auto it = jsonobj.begin(); it != jsonobj.end(); it++) {
64 PvlKeyword keyword;
65 keyword.setName(QString::fromStdString(it.key()));
66 if (it.value().is_array()) {
67 for(auto ar = it.value().begin(); ar!=it.value().end(); ar++) {
68 try {
69 keyword.addJsonValue(*ar);
70 }
71 catch (IException &e) {
72 QString msg = "While attempting to parse " + name + " the following occured";
73 throw IException(e, IException::Unknown, msg, _FILEINFO_);
74 }
75 }
76 }
77 else {
78 keyword.setJsonValue(*it);
79 }
80 addKeyword(keyword);
81 }
82 }
83
96 vector<PvlObject *> searchList;
97 searchList.push_back(this);
98
99 while(searchList.size() > 0) {
101 searchList[0]->findGroup(name,
102 searchList[0]->beginGroup(),
103 searchList[0]->endGroup());
104 if(it != searchList[0]->endGroup()) return *it;
105 if(opts == Traverse) {
106 for(int i = 0; i < searchList[0]->objects(); i++) {
107 searchList.push_back(&searchList[0]->object(i));
108 }
109 }
110 searchList.erase(searchList.begin());
111 }
112
113 QString msg = "Unable to find PVL group [" + name + "]";
114 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
115 throw IException(IException::Unknown, msg, _FILEINFO_);
116 }
117
118
130 PvlObject::FindOptions opts) const {
131 vector<const PvlObject *> searchList;
132 searchList.push_back(this);
133
134 while(searchList.size() > 0) {
135 ConstPvlGroupIterator it =
136 searchList[0]->findGroup(name,
137 searchList[0]->beginGroup(),
138 searchList[0]->endGroup());
139 if(it != searchList[0]->endGroup()) return *it;
140 if(opts == Traverse) {
141 for(int i = 0; i < searchList[0]->objects(); i++) {
142 searchList.push_back(&searchList[0]->object(i));
143 }
144 }
145 searchList.erase(searchList.begin());
146 }
147
148 QString msg = "Unable to find PVL group [" + name + "]";
149 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
150 throw IException(IException::Unknown, msg, _FILEINFO_);
151 }
152
169 PvlKeyword &PvlObject::findKeyword(const QString &kname,
170 FindOptions opts) {
171
172 // Call the parent's version if they don't want to dig deeper
173 if(opts == None) return findKeyword(kname);
174
175 // Search this PvlObject, and all PvlObjects and PvlContainers within
176 // it for the first occurrence of the requested keyword.
177 vector<PvlObject *> searchList;
178 searchList.push_back(this);
179
180 while(searchList.size() > 0) {
182 searchList[0]->findKeyword(kname, searchList[0]->begin(),
183 searchList[0]->end());
184 if(it != searchList[0]->end()) {
185 return *it;
186 }
187
188 // See if the keyword is inside a Group of this Object
189 for(int g = 0; g < searchList[0]->groups(); g++) {
191 searchList[0]->group(g).findKeyword(kname,
192 searchList[0]->group(g).begin(),
193 searchList[0]->group(g).end());
194 if(it != searchList[0]->group(g).end()) {
195 return *it;
196 }
197 }
198
199 // It's not in this Object or any groups in this Object, so
200 // add all Objects inside this Object to the search list
201 for(int i = 0; i < searchList[0]->objects(); i++) {
202 searchList.push_back(&searchList[0]->object(i));
203 }
204
205 // This Object has been searched to remove it from the list
206 searchList.erase(searchList.begin());
207 }
208
209 // No where else to look for the Keyword so throw an error
210 QString msg = "Unable to find PVL keyword [" + kname + "]";
211 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
212 throw IException(IException::Unknown, msg, _FILEINFO_);
213 }
214
215
228 bool PvlObject::hasKeyword(const QString &kname,
229 FindOptions opts) const {
230
231 // Call the parent's version if they don't want to dig deeper
232 if(opts == None) return hasKeyword(kname);
233
234 // Search this PvlObject, and all PvlObjects and PvlContainers within
235 // it for the first occurrence of the requested keyword.
236 vector<const PvlObject *> searchList;
237 searchList.push_back(this);
238
239 while(searchList.size() > 0) {
241 searchList[0]->findKeyword(kname, searchList[0]->begin(),
242 searchList[0]->end());
243 if(it != searchList[0]->end()) {
244 return true;
245 }
246
247 // See if the keyword is inside a Group of this Object
248 for(int g = 0; g < searchList[0]->groups(); g++) {
250 searchList[0]->group(g).findKeyword(kname,
251 searchList[0]->group(g).begin(),
252 searchList[0]->group(g).end());
253
254 if(it != searchList[0]->group(g).end()) {
255 return true;
256 }
257 }
258
259 // It's not in this Object or any groups in this Object, so
260 // add all Objects inside this Object to the search list
261 for(int i = 0; i < searchList[0]->objects(); i++) {
262 searchList.push_back(&searchList[0]->object(i));
263 }
264
265 // This Object has been searched to remove it from the list
266 searchList.erase(searchList.begin());
267 }
268 return false;
269 }
270
271
284 vector<PvlObject *> searchList;
285 searchList.push_back(this);
286
287 while(searchList.size() > 0) {
289 searchList[0]->findObject(name,
290 searchList[0]->beginObject(),
291 searchList[0]->endObject());
292 if(it != searchList[0]->endObject()) return *it;
293 if(opts == Traverse) {
294 for(int i = 0; i < searchList[0]->objects(); i++) {
295 searchList.push_back(&searchList[0]->object(i));
296 }
297 }
298 searchList.erase(searchList.begin());
299 }
300
301 QString msg = "Unable to find PVL object [" + name + "]";
302 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
303 throw IException(IException::Unknown, msg, _FILEINFO_);
304 }
305
306
317 const PvlObject &PvlObject::findObject(const QString &name,
318 FindOptions opts) const {
319 vector<const PvlObject *> searchList;
320 searchList.push_back(this);
321
322 while(searchList.size() > 0) {
323 ConstPvlObjectIterator it =
324 searchList[0]->findObject(name,
325 searchList[0]->beginObject(),
326 searchList[0]->endObject());
327
328 if(it != searchList[0]->endObject()) {
329 return *it;
330 }
331
332 if(opts == Traverse) {
333 for(int i = 0; i < searchList[0]->objects(); i++) {
334 searchList.push_back(&searchList[0]->object(i));
335 }
336 }
337
338 searchList.erase(searchList.begin());
339 }
340
341 QString msg = "Unable to find PVL object [" + name + "]";
342
343 if(m_filename.size() > 0) {
344 msg += " in file [" + m_filename + "]";
345 }
346
347 throw IException(IException::Unknown, msg, _FILEINFO_);
348 }
349
350
358 void PvlObject::deleteObject(const QString &name) {
360 if(key == endObject()) {
361 QString msg = "Unable to find PVL object [" + name + "] in " + type() +
362 " [" + this->name() + "]";
363 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
364 throw IException(IException::Unknown, msg, _FILEINFO_);
365 }
366
367 m_objects.erase(key);
368 }
369
370
378 void PvlObject::deleteObject(const int index) {
379 if(index >= (int)m_objects.size() || index < 0) {
380 QString msg = "The specified index is out of bounds in PVL " + type() +
381 " [" + name() + "]";
382 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
383 throw IException(IException::Unknown, msg, _FILEINFO_);
384 }
385
387 for(int i = 0; i < index; i++) key++;
388
389 m_objects.erase(key);
390 }
391
392
400 void PvlObject::deleteGroup(const QString &name) {
402 if(key == endGroup()) {
403 QString msg = "Unable to find PVL group [" + name + "] in " + type() +
404 " [" + this->name() + "]";
405 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
406 throw IException(IException::Unknown, msg, _FILEINFO_);
407 }
408
409 m_groups.erase(key);
410 }
411
412
420 void PvlObject::deleteGroup(const int index) {
421 if(index >= (int)m_groups.size() || index < 0) {
422 QString msg = "The specified index is out of bounds in PVL " + type() +
423 " [" + name() + "]";
424 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
425 throw IException(IException::Unknown, msg, _FILEINFO_);
426 }
427
429 for(int i = 0; i < index; i++) key++;
430
431 m_groups.erase(key);
432 }
433
434
445 if(index < 0 || index >= (int)m_groups.size()) {
446 QString msg = Message::ArraySubscriptNotInRange(index);
447 throw IException(IException::Programmer, msg, _FILEINFO_);
448 }
449
450 return m_groups[index];
451 }
452
453
463 const Isis::PvlGroup &PvlObject::group(const int index) const {
464 if(index < 0 || index >= (int)m_groups.size()) {
465 QString msg = Message::ArraySubscriptNotInRange(index);
466 throw IException(IException::Programmer, msg, _FILEINFO_);
467 }
468
469 return m_groups[index];
470 }
471
481 PvlObject &PvlObject::object(const int index) {
482 if(index < 0 || index >= (int)m_objects.size()) {
483 QString msg = Message::ArraySubscriptNotInRange(index);
484 throw IException(Isis::IException::Programmer, msg, _FILEINFO_);
485 }
486
487 return m_objects[index];
488 }
489
499 const PvlObject &PvlObject::object(const int index) const {
500 if(index < 0 || index >= (int)m_objects.size()) {
501 QString msg = Message::ArraySubscriptNotInRange(index);
502 throw IException(IException::Programmer, msg, _FILEINFO_);
503 }
504
505 return m_objects[index];
506 }
507
508
515 ostream &operator<<(std::ostream &os, PvlObject &object) {
516
517 // Set up a Formatter
518 bool removeFormatter = false;
519 if(object.format() == NULL) {
520 object.setFormat(new PvlFormat());
521 removeFormatter = true;
522 }
523
524 Isis::PvlObject outTemplate("DEFAULT");
525 if(object.hasFormatTemplate())
526 outTemplate = *(Isis::PvlObject *)object.formatTemplate();
527
528 // Look for and process all include files and remove duplicates
529 Isis::PvlObject newTemp(outTemplate.name());
530
531 // Make sure the new template has all the original's comments
532 for(int i = 0; i < outTemplate.comments(); i++) {
533 newTemp.addComment(outTemplate.comment(i));
534 }
535
536 // Include files take precedence to all other objects and groups
537 for(int i = 0; i < outTemplate.keywords(); i++) {
538 if(outTemplate[i].isNamed("Isis:PvlTemplate:File")) {
539 QString filename = outTemplate[i];
540 Isis::FileName file(filename);
541 if(!file.fileExists()) {
542 QString message = "Could not open the following PVL template file: ";
543 message += filename;
544 throw IException(IException::Io, message, _FILEINFO_);
545 }
546
547 Isis::Pvl include(file.expanded());
548
549 for(int j = 0; j < include.keywords(); j++) {
550 if(!newTemp.hasKeyword(include[j].name()))
551 newTemp.addKeyword(include[j]);
552 }
553
554 for(int j = 0; j < include.objects(); j++) {
555 if(!newTemp.hasObject(include.object(j).name()))
556 newTemp.addObject(include.object(j));
557 }
558
559 for(int j = 0; j < include.groups(); j++) {
560 if(!newTemp.hasGroup(include.group(j).name()))
561 newTemp.addGroup(include.group(j));
562 }
563 }
564 // If it is not an include file keyword add it in place
565 else if(!newTemp.hasKeyword(outTemplate[i].name()))
566 newTemp.addKeyword(outTemplate[i]);
567 }
568
569 // Copy over the objects
570 for(int i = 0; i < outTemplate.objects(); i++) {
571 if(!newTemp.hasObject(outTemplate.object(i).name()))
572 newTemp.addObject(outTemplate.object(i));
573 }
574
575 // Copy over the groups
576 for(int i = 0; i < outTemplate.groups(); i++) {
577 if(!newTemp.hasGroup(outTemplate.group(i).name()))
578 newTemp.addGroup(outTemplate.group(i));
579 }
580
581 outTemplate = newTemp;
582
583 // Write out comments for this Object that were in the template
584 if(outTemplate.comments() > 0) {
585 for(int k = 0; k < outTemplate.comments(); k++) {
586 for(int l = 0; l < object.indent(); l++) os << " ";
587 os << outTemplate.comment(k) << object.format()->formatEOL();
588 }
589 //os << object.format()->FormatEOL();
590 }
591
592 // Output the object comments and name
593 os << object.nameKeyword() << object.format()->formatEOL();
594 object.setIndent(object.indent() + 2);
595
596 // Output the keywords in this Object
597 if(object.keywords() > 0) {
598 os << (Isis::PvlContainer &) object << object.format()->formatEOL();
599 }
600
601 // This number keeps track of the number of objects have been written
602 int numObjects = 0;
603
604 // Output the Objects within this Object using the format template
605 for(int i = 0; i < outTemplate.objects(); i++) {
606 for(int j = 0; j < object.objects(); j++) {
607 if(outTemplate.object(i).name() != object.object(j).name()) continue;
608 if(j == 0 && object.keywords() > 0)
609 os << object.format()->formatEOL();
610
611 object.object(j).setIndent(object.indent());
612 object.object(j).setFormatTemplate(outTemplate.object(i));
613 object.object(j).setFormat(object.format());
614 os << object.object(j) << object.format()->formatEOL();
615 object.object(j).setFormat(NULL);
616 object.object(j).setIndent(0);
617
618 if(++numObjects < object.objects())
619 os << object.format()->formatEOL();
620 }
621 }
622
623 // Output the Objects within this Object that were not included in the
624 // format template pvl
625 for(int i = 0; i < object.objects(); i++) {
626 if(outTemplate.hasObject(object.object(i).name())) continue;
627 if(i == 0 && object.keywords() > 0)
628 os << object.format()->formatEOL();
629
630 object.object(i).setIndent(object.indent());
631 object.object(i).setFormat(object.format());
632 os << object.object(i) << object.format()->formatEOL();
633 object.object(i).setFormat(NULL);
634 object.object(i).setIndent(0);
635
636 if(++numObjects < object.objects())
637 os << object.format()->formatEOL();
638
639 }
640
641 // This number keeps track of the number of groups that have been written
642 int numgroups = 0;
643
644 // Output the groups within this Object using the format template
645 for(int i = 0; i < outTemplate.groups(); i++) {
646 for(int j = 0; j < object.groups(); j++) {
647 if(outTemplate.group(i).name() != object.group(j).name()) continue;
648 if((numgroups == 0) &&
649 (object.objects() > 0 || object.keywords() > 0))
650 os << object.format()->formatEOL();
651
652 object.group(j).setIndent(object.indent());
653 object.group(j).setFormatTemplate(outTemplate.group(i));
654 object.group(j).setFormat(object.format());
655 os << object.group(j) << object.format()->formatEOL();
656 object.group(j).setFormat(NULL);
657 object.group(j).setIndent(0);
658 if(++numgroups < object.groups()) os << object.format()->formatEOL();
659 }
660 }
661
662 // Output the groups that were not in the format template
663 for(int i = 0; i < object.groups(); i++) {
664 if(outTemplate.hasGroup(object.group(i).name())) continue;
665 if((numgroups == 0) &&
666 (object.objects() > 0 || object.keywords() > 0))
667 os << object.format()->formatEOL();
668
669 object.group(i).setIndent(object.indent());
670 object.group(i).setFormat(object.format());
671 os << object.group(i) << object.format()->formatEOL();
672 object.group(i).setFormat(NULL);
673 object.group(i).setIndent(0);
674
675 if(++numgroups < object.groups())
676 os << object.format()->formatEOL();
677 }
678
679 // Output the end of the object
680 object.setIndent(object.indent() - 2);
681 for(int i = 0; i < object.indent(); i++) os << " ";
682 os << object.format()->formatEnd("End_Object", object.nameKeyword());
683
684 if(removeFormatter) {
685 delete object.format();
686 object.setFormat(NULL);
687 }
688
689 return os;
690 }
691
692
697 std::istream &operator>>(std::istream &is, PvlObject &result) {
698 PvlKeyword termination("EndObject");
699
700 PvlKeyword errorKeywords[] = {
701 PvlKeyword("EndGroup")
702 };
703
704 PvlKeyword readKeyword;
705
706 istream::pos_type beforeKeywordPos = is.tellg();
707 is >> readKeyword;
708
709 if(readKeyword != PvlKeyword("Object")) {
710 if(is.eof() && !is.bad()) {
711 is.clear();
712 }
713
714 is.seekg(beforeKeywordPos, ios::beg);
715
716 QString msg = "Expected PVL keyword named [Object], found keyword named [";
717 msg += readKeyword.name();
718 msg += "]";
719 throw IException(IException::Programmer, msg, _FILEINFO_);
720 }
721
722 if(readKeyword.size() == 1) {
723 result.setName(readKeyword[0]);
724 }
725 else {
726 is.seekg(beforeKeywordPos, ios::beg);
727
728 QString msg = "Expected a single value for PVL object name, found [(";
729
730 for(int i = 0; i < readKeyword.size(); i++) {
731 if(i != 0) msg += ", ";
732
733 msg += readKeyword[i];
734 }
735
736 msg += ")]";
737 throw IException(IException::Unknown, msg, _FILEINFO_);
738 }
739
740 for(int comment = 0; comment < readKeyword.comments(); comment++) {
741 result.addComment(readKeyword.comment(comment));
742 }
743
744 readKeyword = PvlKeyword();
745 beforeKeywordPos = is.tellg();
746
747 is >> readKeyword;
748 while(readKeyword != termination) {
749 for(unsigned int errorKey = 0;
750 errorKey < sizeof(errorKeywords) / sizeof(PvlKeyword);
751 errorKey++) {
752 if(readKeyword == errorKeywords[errorKey]) {
753 if(is.eof() && !is.bad()) {
754 is.clear();
755 }
756
757 is.seekg(beforeKeywordPos, ios::beg);
758
759 QString msg = "Unexpected [";
760 msg += readKeyword.name();
761 msg += "] in PVL Object [";
762 msg += result.name();
763 msg += "]";
764 throw IException(IException::Unknown, msg, _FILEINFO_);
765 }
766 }
767
768 if(readKeyword == PvlKeyword("Group")) {
769 is.seekg(beforeKeywordPos);
770 PvlGroup newGroup;
771 is >> newGroup;
772 result.addGroup(newGroup);
773 }
774 else if(readKeyword == PvlKeyword("Object")) {
775 is.seekg(beforeKeywordPos);
776 PvlObject newObject;
777 is >> newObject;
778 result.addObject(newObject);
779 }
780 else {
781 result.addKeyword(readKeyword);
782 }
783
784 readKeyword = PvlKeyword();
785 beforeKeywordPos = is.tellg();
786
787 if(is.good()) {
788 is >> readKeyword;
789 }
790 else {
791 // eof found
792 break;
793 }
794 }
795
796 if(readKeyword != termination) {
797 if(is.eof() && !is.bad()) {
798 is.clear();
799 }
800
801 is.seekg(beforeKeywordPos, ios::beg);
802
803 QString msg = "PVL Object [" + result.name();
804 msg += "] EndObject not found before end of file";
805 throw IException(IException::Unknown, msg, _FILEINFO_);
806 }
807
808 return is;
809 }
810
811
814 this->PvlContainer::operator=(other);
815
816 m_objects = other.m_objects;
817 m_groups = other.m_groups;
818
819 return *this;
820 }
821
834 {
835 // Validate the current object
836 int iObjSize = objects();
837
838 for(int i=0; i<iObjSize; i++) {
839 PvlObject & pvlTmplObj = object(i);
840
841 QString sObjName = pvlTmplObj.name();
842 bool bObjFound = false;
843
844 // Pvl contains the Object Name
845 if(pPvlObj.hasObject(sObjName)) {
846 PvlObject & pvlObj = pPvlObj.findObject(sObjName);
847 pvlTmplObj.validateObject(pvlObj);
848 if(pvlObj.objects()==0 && pvlObj.groups()==0 && pvlObj.keywords()==0) {
849 pPvlObj.deleteObject(pvlObj.name());
850 }
851 bObjFound = true;
852 }
853 else {
854 QString sOption = sObjName + "__Required";
855 bObjFound = true; // optional is the default
856 if(pvlTmplObj.hasKeyword(sOption)) {
857 PvlKeyword pvlKeyOption = pvlTmplObj.findKeyword(sOption);
858 if(pvlKeyOption[0] == "true") { // Required is true
859 bObjFound = false;
860 }
861 }
862 }
863 if (bObjFound == false) {
864 QString sErrMsg = "Object \"" + sObjName + "\" Not Found in the Template File\n";
865 throw IException(IException::User, sErrMsg, _FILEINFO_);
866 }
867 }
868
869 // Validate the groups in the current object
870 int iTmplGrpSize = groups();
871 for(int i=0; i<iTmplGrpSize; i++) {
872 PvlGroup & pvlTmplGrp = group(i);
873 bool bGrpFound = false;
874 QString sGrpName = pvlTmplGrp.name();
875
876 // Pvl contains the Object Name
877 if(pPvlObj.hasGroup(sGrpName)) {
878 PvlGroup & pvlGrp = pPvlObj.findGroup(sGrpName);
879 pvlTmplGrp.validateGroup(pvlGrp);
880 if(pvlGrp.keywords()==0) {
881 pPvlObj.deleteGroup(pvlGrp.name());
882 }
883 bGrpFound = true;
884 }
885 else {
886 bGrpFound = true;
887 QString sOption = sGrpName + "__Required";
888 if(pvlTmplGrp.hasKeyword(sOption)) {
889 PvlKeyword pvlKeyOption = pvlTmplGrp.findKeyword(sOption);
890 if(pvlKeyOption[0] == "true") { // Required is true
891 bGrpFound = false;
892 }
893 }
894 }
895 if (bGrpFound == false) {
896 QString sErrMsg = "Group \"" + sGrpName + "\" Not Found in the Template File\n";
897 throw IException(IException::User, sErrMsg, _FILEINFO_);
898 }
899 }
900
901 // Validate the Keywords in the current Object
903 }
904
905} // end namespace isis
File name manipulation and expansion.
Definition FileName.h:100
bool fileExists() const
Returns true if the file exists; false otherwise.
Definition FileName.cpp:449
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition FileName.cpp:196
Isis exception class.
Definition IException.h:91
@ Unknown
A type of error that cannot be classified as any of the other error types.
Definition IException.h:118
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition IException.h:155
Contains more than one keyword-value pair.
PvlContainer(const QString &type)
Constructs a PvlContainer object with a type.
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
const PvlContainer & operator=(const PvlContainer &other)
This is an assignment operator.
QList< PvlKeyword >::iterator PvlKeywordIterator
The keyword iterator.
QString m_filename
This contains the filename used to initialize the pvl object.
PvlKeywordIterator begin()
Return the beginning iterator.
QList< PvlKeyword >::const_iterator ConstPvlKeywordIterator
The const keyword iterator.
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
int keywords() const
Returns the number of keywords contained in the PvlContainer.
PvlKeywordIterator end()
Return the ending iterator.
void setName(const QString &name)
Set the name of the container.
QString name() const
Returns the container name.
QString type() const
Returns the container type.
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.
PvlKeyword & findKeyword(const QString &name)
Find a keyword with a specified name.
Formats a Pvl name value pair to Isis standards.
Definition PvlFormat.h:108
Contains multiple PvlContainers.
Definition PvlGroup.h:41
void validateGroup(PvlGroup &pPvlGrp)
Validate a Group comparing with the Template Group.
Definition PvlGroup.cpp:207
Container for cube-like labels.
Definition Pvl.h:119
A single keyword-value pair.
Definition PvlKeyword.h:87
QString name() const
Returns the keyword name.
Definition PvlKeyword.h:103
int size() const
Returns the number of values stored in this keyword.
Definition PvlKeyword.h:133
int comments() const
Returns the number of lines of comments associated with this keyword.
Definition PvlKeyword.h:168
QString comment(const int index) const
Return a comment at the specified index.
PvlFormat * format()
Get the current PvlFormat or create one.
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
PvlObjectIterator beginObject()
Returns the index of the beginning object.
Definition PvlObject.h:235
bool hasKeyword(const QString &kname, FindOptions opts) const
See if a keyword is in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within ...
PvlGroupIterator beginGroup()
Returns the beginning group index.
Definition PvlObject.h:91
const PvlObject & operator=(const PvlObject &other)
This is an assignment operator.
friend std::istream & operator>>(std::istream &is, PvlObject &result)
This method reads a PvlObject from the input stream.
friend std::ostream & operator<<(std::ostream &os, Isis::PvlObject &object)
Outputs the PvlObject data to a specified output stream.
QList< Isis::PvlGroup >::iterator PvlGroupIterator
The counter for groups.
Definition PvlObject.h:83
PvlGroup & group(const int index)
Return the group at the specified index.
PvlObject()
Creates a blank PvlObject.
Definition PvlObject.cpp:26
QList< PvlGroup > m_groups
A vector of PvlGroups contained in the current PvlObject.
Definition PvlObject.h:355
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not.
Definition PvlObject.h:323
int groups() const
Returns the number of groups contained.
Definition PvlObject.h:75
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition PvlObject.h:274
void deleteObject(const QString &name)
Remove an object from the current PvlObject.
int objects() const
Returns the number of objects.
Definition PvlObject.h:219
QList< PvlObject >::iterator PvlObjectIterator
The counter for objects.
Definition PvlObject.h:227
PvlObject & object(const int index)
Return the object at the specified index.
bool hasGroup(const QString &name) const
Returns a boolean value based on whether the object has the specified group or not.
Definition PvlObject.h:210
FindOptions
A collection of options to use when finding.
Definition PvlObject.h:154
@ Traverse
Search child objects.
Definition PvlObject.h:158
@ None
Search only the current level.
Definition PvlObject.h:156
QList< PvlObject > m_objects
A vector of PvlObjects contained in the current PvlObject.
Definition PvlObject.h:353
void addObject(const PvlObject &object)
Add a PvlObject.
Definition PvlObject.h:307
PvlObjectIterator endObject()
Returns the index of the ending object.
Definition PvlObject.h:253
PvlKeyword & findKeyword(const QString &kname, FindOptions opts)
Finds a keyword in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within this...
void validateObject(PvlObject &pPvlObj)
Validate Object.
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
Definition PvlObject.h:186
void deleteGroup(const QString &name)
Remove a group from the current PvlObject.
PvlGroupIterator endGroup()
Returns the ending group index.
Definition PvlObject.h:109
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition PvlObject.h:129
QString ArraySubscriptNotInRange(int index)
This error should be used when an Isis object or application is checking array bounds and the legal r...
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.