Isis 3 Programmer Reference
PvlObject.cpp
1
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#include "Application.h"
16
17#include <QList>
18
19#include <iostream>
20#include <sstream>
21
22using namespace std;
23using json = nlohmann::json;
24namespace Isis {
25
28 }
29
30
36 PvlObject::PvlObject(const QString &name) :
37 Isis::PvlContainer("Object", name) {
38 }
39
40
44 m_objects = other.m_objects;
45 m_groups = other.m_groups;
46 }
47
48
49
61 PvlObject::PvlObject(const QString &name, const json &jsonobj) :
62 PvlContainer("Object", name) {
63
64 for(auto it = jsonobj.begin(); it != jsonobj.end(); it++) {
65 PvlKeyword keyword;
66 keyword.setName(QString::fromStdString(it.key()));
67 if (it.value().is_array()) {
68 for(auto ar = it.value().begin(); ar!=it.value().end(); ar++) {
69 try {
70 keyword.addJsonValue(*ar);
71 }
72 catch (IException &e) {
73 QString msg = "While attempting to parse " + name + " the following occured";
74 throw IException(e, IException::Unknown, msg, _FILEINFO_);
75 }
76 }
77 }
78 else {
79 keyword.setJsonValue(*it);
80 }
81 addKeyword(keyword);
82 }
83 }
84
97 vector<PvlObject *> searchList;
98 searchList.push_back(this);
99
100 while(searchList.size() > 0) {
102 searchList[0]->findGroup(name,
103 searchList[0]->beginGroup(),
104 searchList[0]->endGroup());
105 if(it != searchList[0]->endGroup()) return *it;
106 if(opts == Traverse) {
107 for(int i = 0; i < searchList[0]->objects(); i++) {
108 searchList.push_back(&searchList[0]->object(i));
109 }
110 }
111 searchList.erase(searchList.begin());
112 }
113
114 QString msg = "Unable to find PVL group [" + name + "]";
115 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
116 throw IException(IException::Unknown, msg, _FILEINFO_);
117 }
118
119
130 const Isis::PvlGroup &PvlObject::findGroup(const QString &name,
131 PvlObject::FindOptions opts) const {
132 vector<const PvlObject *> searchList;
133 searchList.push_back(this);
134
135 while(searchList.size() > 0) {
136 ConstPvlGroupIterator it =
137 searchList[0]->findGroup(name,
138 searchList[0]->beginGroup(),
139 searchList[0]->endGroup());
140 if(it != searchList[0]->endGroup()) return *it;
141 if(opts == Traverse) {
142 for(int i = 0; i < searchList[0]->objects(); i++) {
143 searchList.push_back(&searchList[0]->object(i));
144 }
145 }
146 searchList.erase(searchList.begin());
147 }
148
149 QString msg = "Unable to find PVL group [" + name + "]";
150 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
151 throw IException(IException::Unknown, msg, _FILEINFO_);
152 }
153
162 QString msg = "This function(PvlObject::addLogGroup) will be depreciated in ISIS3 v9.0 in "
163 "favor of Application::appendLogGroup";
164 std::cerr << msg << std::endl;
165 };
166
183 PvlKeyword &PvlObject::findKeyword(const QString &kname,
184 FindOptions opts) {
185
186 // Call the parent's version if they don't want to dig deeper
187 if(opts == None) return findKeyword(kname);
188
189 // Search this PvlObject, and all PvlObjects and PvlContainers within
190 // it for the first occurrence of the requested keyword.
191 vector<PvlObject *> searchList;
192 searchList.push_back(this);
193
194 while(searchList.size() > 0) {
196 searchList[0]->findKeyword(kname, searchList[0]->begin(),
197 searchList[0]->end());
198 if(it != searchList[0]->end()) {
199 return *it;
200 }
201
202 // See if the keyword is inside a Group of this Object
203 for(int g = 0; g < searchList[0]->groups(); g++) {
205 searchList[0]->group(g).findKeyword(kname,
206 searchList[0]->group(g).begin(),
207 searchList[0]->group(g).end());
208 if(it != searchList[0]->group(g).end()) {
209 return *it;
210 }
211 }
212
213 // It's not in this Object or any groups in this Object, so
214 // add all Objects inside this Object to the search list
215 for(int i = 0; i < searchList[0]->objects(); i++) {
216 searchList.push_back(&searchList[0]->object(i));
217 }
218
219 // This Object has been searched to remove it from the list
220 searchList.erase(searchList.begin());
221 }
222
223 // No where else to look for the Keyword so throw an error
224 QString msg = "Unable to find PVL keyword [" + kname + "]";
225 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
226 throw IException(IException::Unknown, msg, _FILEINFO_);
227 }
228
229
242 bool PvlObject::hasKeyword(const QString &kname,
243 FindOptions opts) const {
244
245 // Call the parent's version if they don't want to dig deeper
246 if(opts == None) return hasKeyword(kname);
247
248 // Search this PvlObject, and all PvlObjects and PvlContainers within
249 // it for the first occurrence of the requested keyword.
250 vector<const PvlObject *> searchList;
251 searchList.push_back(this);
252
253 while(searchList.size() > 0) {
255 searchList[0]->findKeyword(kname, searchList[0]->begin(),
256 searchList[0]->end());
257 if(it != searchList[0]->end()) {
258 return true;
259 }
260
261 // See if the keyword is inside a Group of this Object
262 for(int g = 0; g < searchList[0]->groups(); g++) {
264 searchList[0]->group(g).findKeyword(kname,
265 searchList[0]->group(g).begin(),
266 searchList[0]->group(g).end());
267
268 if(it != searchList[0]->group(g).end()) {
269 return true;
270 }
271 }
272
273 // It's not in this Object or any groups in this Object, so
274 // add all Objects inside this Object to the search list
275 for(int i = 0; i < searchList[0]->objects(); i++) {
276 searchList.push_back(&searchList[0]->object(i));
277 }
278
279 // This Object has been searched to remove it from the list
280 searchList.erase(searchList.begin());
281 }
282 return false;
283 }
284
285
296 PvlObject &PvlObject::findObject(const QString &name,
298 vector<PvlObject *> searchList;
299 searchList.push_back(this);
300
301 while(searchList.size() > 0) {
303 searchList[0]->findObject(name,
304 searchList[0]->beginObject(),
305 searchList[0]->endObject());
306 if(it != searchList[0]->endObject()) return *it;
307 if(opts == Traverse) {
308 for(int i = 0; i < searchList[0]->objects(); i++) {
309 searchList.push_back(&searchList[0]->object(i));
310 }
311 }
312 searchList.erase(searchList.begin());
313 }
314
315 QString msg = "Unable to find PVL object [" + name + "]";
316 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
317 throw IException(IException::Unknown, msg, _FILEINFO_);
318 }
319
320
331 const PvlObject &PvlObject::findObject(const QString &name,
332 FindOptions opts) const {
333 vector<const PvlObject *> searchList;
334 searchList.push_back(this);
335
336 while(searchList.size() > 0) {
337 ConstPvlObjectIterator it =
338 searchList[0]->findObject(name,
339 searchList[0]->beginObject(),
340 searchList[0]->endObject());
341
342 if(it != searchList[0]->endObject()) {
343 return *it;
344 }
345
346 if(opts == Traverse) {
347 for(int i = 0; i < searchList[0]->objects(); i++) {
348 searchList.push_back(&searchList[0]->object(i));
349 }
350 }
351
352 searchList.erase(searchList.begin());
353 }
354
355 QString msg = "Unable to find PVL object [" + name + "]";
356
357 if(m_filename.size() > 0) {
358 msg += " in file [" + m_filename + "]";
359 }
360
361 throw IException(IException::Unknown, msg, _FILEINFO_);
362 }
363
364
372 void PvlObject::deleteObject(const QString &name) {
374 if(key == endObject()) {
375 QString msg = "Unable to find PVL object [" + name + "] in " + type() +
376 " [" + this->name() + "]";
377 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
378 throw IException(IException::Unknown, msg, _FILEINFO_);
379 }
380
381 m_objects.erase(key);
382 }
383
384
392 void PvlObject::deleteObject(const int index) {
393 if(index >= (int)m_objects.size() || index < 0) {
394 QString msg = "The specified index is out of bounds in PVL " + type() +
395 " [" + name() + "]";
396 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
397 throw IException(IException::Unknown, msg, _FILEINFO_);
398 }
399
401 for(int i = 0; i < index; i++) key++;
402
403 m_objects.erase(key);
404 }
405
406
414 void PvlObject::deleteGroup(const QString &name) {
416 if(key == endGroup()) {
417 QString msg = "Unable to find PVL group [" + name + "] in " + type() +
418 " [" + this->name() + "]";
419 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
420 throw IException(IException::Unknown, msg, _FILEINFO_);
421 }
422
423 m_groups.erase(key);
424 }
425
426
434 void PvlObject::deleteGroup(const int index) {
435 if(index >= (int)m_groups.size() || index < 0) {
436 QString msg = "The specified index is out of bounds in PVL " + type() +
437 " [" + name() + "]";
438 if(m_filename.size() > 0) msg += " in file [" + m_filename + "]";
439 throw IException(IException::Unknown, msg, _FILEINFO_);
440 }
441
443 for(int i = 0; i < index; i++) key++;
444
445 m_groups.erase(key);
446 }
447
448
459 if(index < 0 || index >= (int)m_groups.size()) {
460 QString msg = Message::ArraySubscriptNotInRange(index);
461 throw IException(IException::Programmer, msg, _FILEINFO_);
462 }
463
464 return m_groups[index];
465 }
466
467
477 const Isis::PvlGroup &PvlObject::group(const int index) const {
478 if(index < 0 || index >= (int)m_groups.size()) {
479 QString msg = Message::ArraySubscriptNotInRange(index);
480 throw IException(IException::Programmer, msg, _FILEINFO_);
481 }
482
483 return m_groups[index];
484 }
485
495 PvlObject &PvlObject::object(const int index) {
496 if(index < 0 || index >= (int)m_objects.size()) {
497 QString msg = Message::ArraySubscriptNotInRange(index);
498 throw IException(Isis::IException::Programmer, msg, _FILEINFO_);
499 }
500
501 return m_objects[index];
502 }
503
513 const PvlObject &PvlObject::object(const int index) const {
514 if(index < 0 || index >= (int)m_objects.size()) {
515 QString msg = Message::ArraySubscriptNotInRange(index);
516 throw IException(IException::Programmer, msg, _FILEINFO_);
517 }
518
519 return m_objects[index];
520 }
521
522
529 ostream &operator<<(std::ostream &os, PvlObject &object) {
530
531 // Set up a Formatter
532 bool removeFormatter = false;
533 if(object.format() == NULL) {
534 object.setFormat(new PvlFormat());
535 removeFormatter = true;
536 }
537
538 Isis::PvlObject outTemplate("DEFAULT");
539 if(object.hasFormatTemplate())
540 outTemplate = *(Isis::PvlObject *)object.formatTemplate();
541
542 // Look for and process all include files and remove duplicates
543 Isis::PvlObject newTemp(outTemplate.name());
544
545 // Make sure the new template has all the original's comments
546 for(int i = 0; i < outTemplate.comments(); i++) {
547 newTemp.addComment(outTemplate.comment(i));
548 }
549
550 // Include files take precedence to all other objects and groups
551 for(int i = 0; i < outTemplate.keywords(); i++) {
552 if(outTemplate[i].isNamed("Isis:PvlTemplate:File")) {
553 QString filename = outTemplate[i];
554 Isis::FileName file(filename);
555 if(!file.fileExists()) {
556 QString message = "Could not open the following PVL template file: ";
557 message += filename;
558 throw IException(IException::Io, message, _FILEINFO_);
559 }
560
561 Isis::Pvl include(file.expanded());
562
563 for(int j = 0; j < include.keywords(); j++) {
564 if(!newTemp.hasKeyword(include[j].name()))
565 newTemp.addKeyword(include[j]);
566 }
567
568 for(int j = 0; j < include.objects(); j++) {
569 if(!newTemp.hasObject(include.object(j).name()))
570 newTemp.addObject(include.object(j));
571 }
572
573 for(int j = 0; j < include.groups(); j++) {
574 if(!newTemp.hasGroup(include.group(j).name()))
575 newTemp.addGroup(include.group(j));
576 }
577 }
578 // If it is not an include file keyword add it in place
579 else if(!newTemp.hasKeyword(outTemplate[i].name()))
580 newTemp.addKeyword(outTemplate[i]);
581 }
582
583 // Copy over the objects
584 for(int i = 0; i < outTemplate.objects(); i++) {
585 if(!newTemp.hasObject(outTemplate.object(i).name()))
586 newTemp.addObject(outTemplate.object(i));
587 }
588
589 // Copy over the groups
590 for(int i = 0; i < outTemplate.groups(); i++) {
591 if(!newTemp.hasGroup(outTemplate.group(i).name()))
592 newTemp.addGroup(outTemplate.group(i));
593 }
594
595 outTemplate = newTemp;
596
597 // Write out comments for this Object that were in the template
598 if(outTemplate.comments() > 0) {
599 for(int k = 0; k < outTemplate.comments(); k++) {
600 for(int l = 0; l < object.indent(); l++) os << " ";
601 os << outTemplate.comment(k) << object.format()->formatEOL();
602 }
603 //os << object.format()->FormatEOL();
604 }
605
606 // Output the object comments and name
607 os << object.nameKeyword() << object.format()->formatEOL();
608 object.setIndent(object.indent() + 2);
609
610 // Output the keywords in this Object
611 if(object.keywords() > 0) {
612 os << (Isis::PvlContainer &) object << object.format()->formatEOL();
613 }
614
615 // This number keeps track of the number of objects have been written
616 int numObjects = 0;
617
618 // Output the Objects within this Object using the format template
619 for(int i = 0; i < outTemplate.objects(); i++) {
620 for(int j = 0; j < object.objects(); j++) {
621 if(outTemplate.object(i).name() != object.object(j).name()) continue;
622 if(j == 0 && object.keywords() > 0)
623 os << object.format()->formatEOL();
624
625 object.object(j).setIndent(object.indent());
626 object.object(j).setFormatTemplate(outTemplate.object(i));
627 object.object(j).setFormat(object.format());
628 os << object.object(j) << object.format()->formatEOL();
629 object.object(j).setFormat(NULL);
630 object.object(j).setIndent(0);
631
632 if(++numObjects < object.objects())
633 os << object.format()->formatEOL();
634 }
635 }
636
637 // Output the Objects within this Object that were not included in the
638 // format template pvl
639 for(int i = 0; i < object.objects(); i++) {
640 if(outTemplate.hasObject(object.object(i).name())) continue;
641 if(i == 0 && object.keywords() > 0)
642 os << object.format()->formatEOL();
643
644 object.object(i).setIndent(object.indent());
645 object.object(i).setFormat(object.format());
646 os << object.object(i) << object.format()->formatEOL();
647 object.object(i).setFormat(NULL);
648 object.object(i).setIndent(0);
649
650 if(++numObjects < object.objects())
651 os << object.format()->formatEOL();
652
653 }
654
655 // This number keeps track of the number of groups that have been written
656 int numgroups = 0;
657
658 // Output the groups within this Object using the format template
659 for(int i = 0; i < outTemplate.groups(); i++) {
660 for(int j = 0; j < object.groups(); j++) {
661 if(outTemplate.group(i).name() != object.group(j).name()) continue;
662 if((numgroups == 0) &&
663 (object.objects() > 0 || object.keywords() > 0))
664 os << object.format()->formatEOL();
665
666 object.group(j).setIndent(object.indent());
667 object.group(j).setFormatTemplate(outTemplate.group(i));
668 object.group(j).setFormat(object.format());
669 os << object.group(j) << object.format()->formatEOL();
670 object.group(j).setFormat(NULL);
671 object.group(j).setIndent(0);
672 if(++numgroups < object.groups()) os << object.format()->formatEOL();
673 }
674 }
675
676 // Output the groups that were not in the format template
677 for(int i = 0; i < object.groups(); i++) {
678 if(outTemplate.hasGroup(object.group(i).name())) continue;
679 if((numgroups == 0) &&
680 (object.objects() > 0 || object.keywords() > 0))
681 os << object.format()->formatEOL();
682
683 object.group(i).setIndent(object.indent());
684 object.group(i).setFormat(object.format());
685 os << object.group(i) << object.format()->formatEOL();
686 object.group(i).setFormat(NULL);
687 object.group(i).setIndent(0);
688
689 if(++numgroups < object.groups())
690 os << object.format()->formatEOL();
691 }
692
693 // Output the end of the object
694 object.setIndent(object.indent() - 2);
695 for(int i = 0; i < object.indent(); i++) os << " ";
696 os << object.format()->formatEnd("End_Object", object.nameKeyword());
697
698 if(removeFormatter) {
699 delete object.format();
700 object.setFormat(NULL);
701 }
702
703 return os;
704 }
705
706
711 std::istream &operator>>(std::istream &is, PvlObject &result) {
712 PvlKeyword termination("EndObject");
713
714 PvlKeyword errorKeywords[] = {
715 PvlKeyword("EndGroup")
716 };
717
718 PvlKeyword readKeyword;
719
720 istream::pos_type beforeKeywordPos = is.tellg();
721 is >> readKeyword;
722
723 if(readKeyword != PvlKeyword("Object")) {
724 if(is.eof() && !is.bad()) {
725 is.clear();
726 }
727
728 is.seekg(beforeKeywordPos, ios::beg);
729
730 QString msg = "Expected PVL keyword named [Object], found keyword named [";
731 msg += readKeyword.name();
732 msg += "]";
733 throw IException(IException::Programmer, msg, _FILEINFO_);
734 }
735
736 if(readKeyword.size() == 1) {
737 result.setName(readKeyword[0]);
738 }
739 else {
740 is.seekg(beforeKeywordPos, ios::beg);
741
742 QString msg = "Expected a single value for PVL object name, found [(";
743
744 for(int i = 0; i < readKeyword.size(); i++) {
745 if(i != 0) msg += ", ";
746
747 msg += readKeyword[i];
748 }
749
750 msg += ")]";
751 throw IException(IException::Unknown, msg, _FILEINFO_);
752 }
753
754 for(int comment = 0; comment < readKeyword.comments(); comment++) {
755 result.addComment(readKeyword.comment(comment));
756 }
757
758 readKeyword = PvlKeyword();
759 beforeKeywordPos = is.tellg();
760
761 is >> readKeyword;
762 while(readKeyword != termination) {
763 for(unsigned int errorKey = 0;
764 errorKey < sizeof(errorKeywords) / sizeof(PvlKeyword);
765 errorKey++) {
766 if(readKeyword == errorKeywords[errorKey]) {
767 if(is.eof() && !is.bad()) {
768 is.clear();
769 }
770
771 is.seekg(beforeKeywordPos, ios::beg);
772
773 QString msg = "Unexpected [";
774 msg += readKeyword.name();
775 msg += "] in PVL Object [";
776 msg += result.name();
777 msg += "]";
778 throw IException(IException::Unknown, msg, _FILEINFO_);
779 }
780 }
781
782 if(readKeyword == PvlKeyword("Group")) {
783 is.seekg(beforeKeywordPos);
784 PvlGroup newGroup;
785 is >> newGroup;
786 result.addGroup(newGroup);
787 }
788 else if(readKeyword == PvlKeyword("Object")) {
789 is.seekg(beforeKeywordPos);
790 PvlObject newObject;
791 is >> newObject;
792 result.addObject(newObject);
793 }
794 else {
795 result.addKeyword(readKeyword);
796 }
797
798 readKeyword = PvlKeyword();
799 beforeKeywordPos = is.tellg();
800
801 if(is.good()) {
802 is >> readKeyword;
803 }
804 else {
805 // eof found
806 break;
807 }
808 }
809
810 if(readKeyword != termination) {
811 if(is.eof() && !is.bad()) {
812 is.clear();
813 }
814
815 is.seekg(beforeKeywordPos, ios::beg);
816
817 QString msg = "PVL Object [" + result.name();
818 msg += "] EndObject not found before end of file";
819 throw IException(IException::Unknown, msg, _FILEINFO_);
820 }
821
822 return is;
823 }
824
825
828 this->PvlContainer::operator=(other);
829
830 m_objects = other.m_objects;
831 m_groups = other.m_groups;
832
833 return *this;
834 }
835
848 {
849 // Validate the current object
850 int iObjSize = objects();
851
852 for(int i=0; i<iObjSize; i++) {
853 PvlObject & pvlTmplObj = object(i);
854
855 QString sObjName = pvlTmplObj.name();
856 bool bObjFound = false;
857
858 // Pvl contains the Object Name
859 if(pPvlObj.hasObject(sObjName)) {
860 PvlObject & pvlObj = pPvlObj.findObject(sObjName);
861 pvlTmplObj.validateObject(pvlObj);
862 if(pvlObj.objects()==0 && pvlObj.groups()==0 && pvlObj.keywords()==0) {
863 pPvlObj.deleteObject(pvlObj.name());
864 }
865 bObjFound = true;
866 }
867 else {
868 QString sOption = sObjName + "__Required";
869 bObjFound = true; // optional is the default
870 if(pvlTmplObj.hasKeyword(sOption)) {
871 PvlKeyword pvlKeyOption = pvlTmplObj.findKeyword(sOption);
872 if(pvlKeyOption[0] == "true") { // Required is true
873 bObjFound = false;
874 }
875 }
876 }
877 if (bObjFound == false) {
878 QString sErrMsg = "Object \"" + sObjName + "\" Not Found in the Template File\n";
879 throw IException(IException::User, sErrMsg, _FILEINFO_);
880 }
881 }
882
883 // Validate the groups in the current object
884 int iTmplGrpSize = groups();
885 for(int i=0; i<iTmplGrpSize; i++) {
886 PvlGroup & pvlTmplGrp = group(i);
887 bool bGrpFound = false;
888 QString sGrpName = pvlTmplGrp.name();
889
890 // Pvl contains the Object Name
891 if(pPvlObj.hasGroup(sGrpName)) {
892 PvlGroup & pvlGrp = pPvlObj.findGroup(sGrpName);
893 pvlTmplGrp.validateGroup(pvlGrp);
894 if(pvlGrp.keywords()==0) {
895 pPvlObj.deleteGroup(pvlGrp.name());
896 }
897 bGrpFound = true;
898 }
899 else {
900 bGrpFound = true;
901 QString sOption = sGrpName + "__Required";
902 if(pvlTmplGrp.hasKeyword(sOption)) {
903 PvlKeyword pvlKeyOption = pvlTmplGrp.findKeyword(sOption);
904 if(pvlKeyOption[0] == "true") { // Required is true
905 bGrpFound = false;
906 }
907 }
908 }
909 if (bGrpFound == false) {
910 QString sErrMsg = "Group \"" + sGrpName + "\" Not Found in the Template File\n";
911 throw IException(IException::User, sErrMsg, _FILEINFO_);
912 }
913 }
914
915 // Validate the Keywords in the current Object
917 }
918
919} // end namespace isis
static void Log(PvlGroup &results)
Writes Pvl results to sessionlog and printfile.
File name manipulation and expansion.
Definition FileName.h:100
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.
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.
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.
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
void setName(QString name)
Sets the keyword name.
void setJsonValue(nlohmann::json jsonobj, QString unit="")
Sets new value from Json.
void addJsonValue(nlohmann::json jsonobj, QString unit="")
Adds a value with units.
void clear()
Clears all values and units for this PvlKeyword object.
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
PvlObjectIterator beginObject()
Returns the index of the beginning object.
Definition PvlObject.h:237
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.
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:27
QList< PvlGroup > m_groups
A vector of PvlGroups contained in the current PvlObject.
Definition PvlObject.h:357
int groups() const
Returns the number of groups contained.
Definition PvlObject.h:75
void addLogGroup(Isis::PvlGroup &group)
Add a group to the object and report it to the log/terminal.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
Definition PvlObject.h:276
void deleteObject(const QString &name)
Remove an object from the current PvlObject.
int objects() const
Returns the number of objects.
Definition PvlObject.h:221
QList< PvlObject >::iterator PvlObjectIterator
The counter for objects.
Definition PvlObject.h:229
PvlObject & object(const int index)
Return the object at the specified index.
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:355
void addObject(const PvlObject &object)
Add a PvlObject.
Definition PvlObject.h:309
PvlObjectIterator endObject()
Returns the index of the ending object.
Definition PvlObject.h:255
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
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.