-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPDS_Metadata.hh
1166 lines (969 loc) · 36.2 KB
/
PDS_Metadata.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* PDS_Metadata
HiROC CVS ID: $Id: PDS_Metadata.hh,v 1.14 2013/06/25 17:24:23 guym Exp $
Copyright (C) 2011-2012 Arizona Board of Regents on behalf of the
Planetary Image Research Laboratory, Lunar and Planetary Laboratory at
the University of Arizona.
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License, version 2.1,
as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*******************************************************************************/
#ifndef PDS_Metadata_hh
#define PDS_Metadata_hh
//#include "Network_Status.hh"
#include <QThread>
#include <QUrl>
#include <QString>
//class QMutex;
class QNetworkAccessManager;
class QNetworkReply;
#include "Parameter.hh"
namespace idaeim {
namespace PVL {
class Lister;
}}
namespace UA
{
namespace HiRISE
{
/** A <i>PDS_Metadata</i> fetches PDS metadata from a URL source.
The PDS_Metadata is a fully thread safe QThread subclass, and a subclass
of Network_Status. When fetching an HTTP URL a thread is run that
uses a QNetworkAccessManager to fetch the URL file content. The URL
fetch may be done asynchronously or synchrously with a maximum wait
time for it to complete, and a fetch in progress may be canceled. A
local file URL may also be fetched; this is always done
synchronously. A signal is emitted whenever a fetch has been
completed.
The results of a URL fetch is the PDS metadata parameters in the form
of a PVL Aggregate.
A set of utility functions are provided to find parameters in PDS
metadata, and get and set parameter values.
@author Bradford Castalia, UA/HiROC
@version $Revision: 1.14 $
*/
class PDS_Metadata
: public QObject/*,
public Network_Status
*/
{
// Qt Object declaration.
Q_OBJECT
public:
/*==============================================================================
Constants
*/
//! Class identification name with source code version and date.
static const char* const
ID;
//! Name of the PDS metadata parameters group.
static const char* const
PDS_METADATA_GROUP;
// Structure definition parameters:
//! PDS ID.
static const char* const
PDS_ID_PARAMETER_NAME;
//! Type of metadata records.
static const char* const
RECORD_TYPE_PARAMETER_NAME;
//! The RECORD_TYPE_PARAMETER_NAME used to define byte count based records.
static const char* const
BYTE_RECORD_TYPE;
//! The RECORD_TYPE_PARAMETER_NAME used to define fixed length records.
static const char* const
FIXED_LENGTH_RECORD_TYPE;
//! Number of records in the metadata label.
static const char* const
LABEL_RECORDS_PARAMETER_NAME;
//! Number of bytes per record.
static const char* const
RECORD_BYTES_PARAMETER_NAME;
//! Number of records in the file.
static const char* const
FILE_RECORDS_PARAMETER_NAME;
//! Data format.
static const char* const
INTERCHANGE_FORMAT_PARAMETER_NAME;
//! Name of the Image data block parameter group.
static const char* const
IMAGE_DATA_BLOCK_NAME;
//! Units name for storage measured in bytes.
static const char* const
BYTES_UNITS;
/** Record pointer parameter prefix.
When this character is the first character of a parameter name it is
marked as a record pointer parameter for a data block. An associated
group of parameters having the same name, but without the initial
marker character, is expected to be present that describes the
content of the data block.
*/
static const char
RECORD_POINTER_PARAMETER_MARKER;
// Image map projection parameters:
//! Name of the parameter group containing projection parameters.
static const char* const
IMAGE_MAP_PROJECTION_GROUP_NAME;
//! Type of projection.
static const char* const
PROJECTION_TYPE_PARAMETER_NAME;
//! The PROJECTION_TYPE_PARAMETER_NAME for equirectangular projection.
static const char* const
EQUIRECTANGULAR_PROJECTION_NAME;
//! The PROJECTION_TYPE_PARAMETER_NAME for polar stereographic projection.
static const char* const
POLARSTEREOGRAPHIC_PROJECTION_NAME;
//! Type of coordinate system.
static const char* const
COORDINATE_SYSTEM_PARAMETER_NAME;
//! Type of coordinate system (alternative name).
static const char* const
LATITUDE_TYPE_PARAMETER_NAME;
//! Planeto-centric (non-geographic) type of coordinate system.
static const char* const
PLANETOCENTRIC_PROJECTION_NAME;
//! Planeto-graphic (geographic) type of coordinate system.
static const char* const
PLANETOGRAPHIC_PROJECTION_NAME;
//! Horizontal offset of the projection origin from the image origin.
static const char* const
HORIZONATAL_OFFSET_PARAMETER_NAME;
//! Vertical offset of the projection origin from the image origin.
static const char* const
VERTICAL_OFFSET_PARAMETER_NAME;
//! Number of image lines.
static const char* const
IMAGE_HEIGHT_PARAMETER_NAME;
//! Number of pixels per image line.
static const char* const
IMAGE_WIDTH_PARAMETER_NAME;
//! Number of pixels per world degree.
static const char* const
PIXELS_PER_DEGREE_PARAMETER_NAME;
//! Real world size of a pixel (km by default, may be m).
static const char* const
PIXEL_SIZE_PARAMETER_NAME;
//! Planet's semi-major (equitorial) axis radius.
static const char* const
EQUITORIAL_RADIUS_PARAMETER_NAME;
//! Planet's semi-minor (polar) axis radius.
static const char* const
POLAR_RADIUS_PARAMETER_NAME;
//! Projection first standard parallel.
static const char* const
FIRST_STANDARD_PARALLEL_PARAMETER_NAME;
//! Projection second standard parallel.
static const char* const
SECOND_STANDARD_PARALLEL_PARAMETER_NAME;
//! Projection center longitude.
static const char* const
CENTER_LONGITUDE_PARAMETER_NAME;
//! Projection center latitude.
static const char* const
CENTER_LATITUDE_PARAMETER_NAME;
//! Image minimum latitude.
static const char* const
MINIMUM_LATITUDE_PARAMETER_NAME;
//! Image maximum latitude.
static const char* const
MAXIMUM_LATITUDE_PARAMETER_NAME;
//! Image minimum longitude.
static const char* const
MINIMUM_LONGITUDE_PARAMETER_NAME;
//! Image maximum longitude.
static const char* const
MAXIMUM_LONGITUDE_PARAMETER_NAME;
//! Positive longitude direction.
static const char* const
POSITIVE_LONGITUDE_PARAMETER_NAME;
//! POSITIVE_LONGITUDE_PARAMETER_NAME for easterly positive longitude.
static const char* const
POSITIVE_LONGITUDE_EAST_NAME;
//! POSITIVE_LONGITUDE_PARAMETER_NAME for westerly positive longitude.
static const char* const
POSITIVE_LONGITUDE_WEST_NAME;
//! Projection rotation.
static const char* const
PROJECTION_ROTATION_PARAMETER_NAME;
//! Not-applicable constant.
static const char* const
NOT_APPLICABLE_CONSTANT_PARAMETER_NAME;
/*==============================================================================
Constructor
*/
/** Constructs a PDS_Metadata object.
@param parent A QObject that owns the constructed object and will
destroy it when the parent is destroyed.
*/
explicit PDS_Metadata (QObject* parent = NULL);
//! Destroys the PDS_Metadata.
virtual ~PDS_Metadata ();
/*==============================================================================
Accessors
*/
/** Get the most recently {@link fetch(const QUrl&, bool) fetched}
PDS metadata.
@return A pointer to an idaeim::PVL::Aggregate containing the PDS
metadata parameters. This will be NULL if no metadata is available.
*/
idaeim::PVL::Aggregate* metadata () const;
/** Test if a {@link fetch(const QUrl&, bool) URL fetch} is currently in
progress.
@return true if a fetch is in progress; false otherwise.
*/
bool fetching () const;
/** Reset this PDS_Metadata.
The {@link metadata() metadata parameters}, if any, are deleted and the
metadata is set to NULL. The network status values are also {@link
Network_Status::reset() reset}.
*/
bool reset ();
/*==============================================================================
Utilities
*/
/** Selects the class of parameter to {@link
find(const std::string&, bool, int, Parameter_Class_Selection) find} or
remove(const std::string&, bool, int, Parameter_Class_Selection) remove}.
*/
enum Parameter_Class_Selection
{
AGGREGATE_PARAMETER = -1,
ANY_PARAMETER = 0,
ASSIGNMENT_PARAMETER = 1
};
//! Flag values for case sensitivity.
enum
{
CASE_INSENSITIVE,
CASE_SENSITIVE
};
/** Find a named Parameter within a Parameter Aggregate.
The Parameter to be found may be specified by a simple name, a
relative pathname or an absolute pathname. A simple name is the
{@link idaeim::PVL::Parameter::name() name} of a Parameter itself. A
relative pathname is a simple name preceeded by the pathname of an
Aggregate Parameter that must contain the Parameter with the simple
name. An {@link absolute_pathname(const std::string) absolute
pathname} is a pathname that begins with a {@link
idaeim::PVL::Parameter::path_delimiter() path delimiter} character
('/' by default); i.e. it is a fully qualified pathname beginning at
the {@link idaeim::PVL::Parameter::root root} of the Aggregate
hierarchy, compared to a relative pathname that may begin at any
Aggregate in the hierarchy.
Since it is not necessary that the pathname to each Parameter be
unique, the number of matching pathnames to skip before selecting a
Parameter may need to be specified to get the desired Parameter.
Also, a specific type of Parameter - an Aggregate of Parameters or an
Assignment of Values - may be specified. When skipping parameters,
only the specified type are counted.
@param parameters The Aggregate within which to search.
@param pathname The pathname for the parameter to be found.
@param case_sensitive If true, the name search is case sensitive;
case insensitive otherwise.
@param skip The number of parameters that match the
name to skip before selecting a matching parameter.
@param parameter_class A PDS::Parameter_Class_Selection: If
PDS_Data::AGGREGATE_PARAMETER, only Aggregate parameters will be
selected; if PDS_Data::ASSIGNMENT_PARAMETER, only Assignment
parameters will be selected; otherwise any type of parameter
(PDS_Data::ANY_PARAMETER) is acceptable.
@return A pointer to the matching parameter, or NULL if it could not
be found.
@see find_parameter(const idaeim::PVL::Aggregate&, const QString&,
bool, int, Parameter_Class_Selection)
*/
inline static idaeim::PVL::Parameter*
find_parameter
(
const idaeim::PVL::Aggregate& parameters,
const std::string& pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
)
{
return parameters.find (pathname, case_sensitive, skip,
static_cast<idaeim::PVL::Parameter::Type>(
((parameter_class == ANY_PARAMETER) ?
idaeim::PVL::Parameter::ASSIGNMENT |
idaeim::PVL::Parameter::AGGREGATE :
((parameter_class == ASSIGNMENT_PARAMETER) ?
idaeim::PVL::Parameter::ASSIGNMENT :
idaeim::PVL::Parameter::AGGREGATE))));
}
/** Find a named Parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a char* pathname.
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline static idaeim::PVL::Parameter*
find_parameter
(
const idaeim::PVL::Aggregate& parameters,
const char* const pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
)
{return PDS_Metadata::find_parameter (parameters, std::string (pathname),
case_sensitive, skip, parameter_class);}
/** Find a named Parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a QString pathname.
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline static idaeim::PVL::Parameter*
find_parameter
(
const idaeim::PVL::Aggregate& parameters,
const QString& pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
)
{return PDS_Metadata::find_parameter (parameters, pathname.toStdString (),
case_sensitive, skip, parameter_class);}
/** Find a named Parameter within the metadata parameters.
This is a convenience method that overloads the equivalent function.
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline idaeim::PVL::Parameter*
find_parameter
(
const std::string& pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
) const
{return metadata () ?
find_parameter (*metadata (), pathname,
case_sensitive, skip, parameter_class) :
NULL;}
/** Find a named Parameter within the metadata parameters.
This is a convenience method that overloads the equivalent function.
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline idaeim::PVL::Parameter*
find_parameter
(
const char* const pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
) const
{return metadata () ?
find_parameter (*metadata (), std::string (pathname),
case_sensitive, skip, parameter_class) :
NULL;}
/** Find a named Parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a QString pathname.
@see find_parameter(const std::string&, bool, int,
Parameter_Class_Selection)
*/
inline idaeim::PVL::Parameter*
find_parameter
(
const QString& pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
) const
{return find_parameter (pathname.toStdString (),
case_sensitive, skip, parameter_class);}
/** Removes a named Parameter within a Parameter Aggregate.
@param parameters The Aggregate within which to search.
@param pathname The pathname for the parameter to be found.
@param case_sensitive If true, the name search is case sensitive;
case insensitive otherwise.
@param skip The number of parameters that match the name to skip
before selecting a matching parameter.
@param parameter_class A Parameter_Class_Selection: If
AGGREGATE_PARAMETER, only Aggregate parameters will be selected;
if ASSIGNMENT_PARAMETER, only Assignment parameters will be
selected; otherwise any type of parameter (ANY_PARAMETER) is
acceptable.
@return A pointer to the parameter that was removed, or NULL if it
could not be found.
@see remove_parameter(const idaeim::PVL::Aggregate&, const QString&,
bool, int, Parameter_Class_Selection)
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline static idaeim::PVL::Parameter*
remove_parameter
(
const idaeim::PVL::Aggregate& parameters,
const std::string& pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
)
{
idaeim::PVL::Parameter
*parameter (PDS_Metadata::find_parameter
(parameters, pathname, case_sensitive, skip, parameter_class));
if (parameter)
parameter = parameter->parent ()->remove (parameter);
return parameter;
}
/** Removes a named Parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a char* pathname.
@see remove_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline static idaeim::PVL::Parameter*
remove_parameter
(
const idaeim::PVL::Aggregate& parameters,
const char* const pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
)
{return PDS_Metadata::remove_parameter (parameters, std::string (pathname),
case_sensitive, skip, parameter_class);}
/** Removes a named Parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a QString pathname.
@see remove_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline static idaeim::PVL::Parameter*
remove_parameter
(
const idaeim::PVL::Aggregate& parameters,
const QString& pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
)
{return PDS_Metadata::remove_parameter (parameters, pathname.toStdString (),
case_sensitive, skip, parameter_class);}
/** Removes a named Parameter within the metadata parameters.
This is a convenience method that overloads the equivalent function.
@see remove_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline idaeim::PVL::Parameter*
remove_parameter
(
const std::string& pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
) const
{return metadata () ?
remove_parameter (*metadata (), pathname,
case_sensitive, skip, parameter_class) :
NULL;}
/** Removes a named Parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a char* pathname.
@see remove_parameter(const std::string&, bool, int,
Parameter_Class_Selection)
*/
inline idaeim::PVL::Parameter*
remove_parameter
(
const char* const pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
) const
{return remove_parameter (std::string (pathname),
case_sensitive, skip, parameter_class);}
/** Removes a named Parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a QString pathname.
@see remove_parameter(const std::string&, bool, int,
Parameter_Class_Selection)
*/
inline idaeim::PVL::Parameter*
remove_parameter
(
const QString& pathname,
bool case_sensitive = false,
int skip = 0,
Parameter_Class_Selection parameter_class = ANY_PARAMETER
) const
{return remove_parameter (pathname.toStdString (),
case_sensitive, skip, parameter_class);}
/** Get the numeric value of a named parameter within a Parameter Aggregate.
@param parameters The Aggregate within which to search.
@param pathname The pathname for the parameter to be found.
@param case_sensitive If true, the name search is case sensitive;
case insensitive otherwise.
@param skip The number of parameters that match the pathname to
skip before selecting the parameter to modify.
@return The value of the parameter as a double.
@throws idaeim::Invalid_Argument If an assignment parameter can
not be found at the pathname.
@throws idaeim::PVL::Invalid_Value If the Value is not Numeric.
@see numeric_value(const idaeim::PVL::Aggregate&, const QString&,
bool, int, Parameter_Class_Selection)
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
static double
numeric_value
(
const idaeim::PVL::Aggregate& parameters,
const std::string& pathname,
bool case_sensitive = false,
int skip = 0
);
/** Get the numeric value of a named parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a char* pathname.
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline static double
numeric_value
(
const idaeim::PVL::Aggregate& parameters,
const char* const pathname,
bool case_sensitive = false,
int skip = 0
)
{return PDS_Metadata::numeric_value (parameters, std::string (pathname),
case_sensitive, skip);}
/** Get the numeric value of a named parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a QString pathname.
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
inline static double
numeric_value
(
const idaeim::PVL::Aggregate& parameters,
const QString& pathname,
bool case_sensitive = false,
int skip = 0
)
{return PDS_Metadata::numeric_value (parameters, pathname.toStdString (),
case_sensitive, skip);}
/** Get the numeric value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent function.
@see numeric_value(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
double
numeric_value
(
const std::string& pathname,
bool case_sensitive = false,
int skip = 0
) const;
/** Get the numeric value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a char* pathname.
@see numeric_value(const std::string&, bool, int,
Parameter_Class_Selection)
*/
double
numeric_value
(
const char* const pathname,
bool case_sensitive = false,
int skip = 0
) const
{return numeric_value (std::string (pathname), case_sensitive, skip);}
/** Get the numeric value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a QString pathname.
@see numeric_value(const std::string&, bool, int,
Parameter_Class_Selection)
*/
double
numeric_value
(
const QString& pathname,
bool case_sensitive = false,
int skip = 0
) const
{return numeric_value (pathname.toStdString (), case_sensitive, skip);}
/** Get the numeric value of a parameter.
@param parameter The parameter from which to obtain a numeric value.
@return The value of the parameter as a double.
@throws idaeim::PVL::Invalid_Value If the Value is not Numeric.
*/
static double numeric_value (const idaeim::PVL::Parameter& parameter);
/** Get the string value of a named parameter within a Parameter Aggregate.
@param parameters The Aggregate within which to search.
@param pathname The pathname for the parameter to be found.
@param case_sensitive If true, the name search is case sensitive;
case insensitive otherwise.
@param skip The number of parameters that match the pathname to
skip before selecting the parameter to modify.
@return The string value of the parameter.
@throws idaeim::Invalid_Argument If an assignment parameter can
not be found at the pathname.
@throws idaeim::PVL::Invalid_Value If the Value is not a String.
@see string_value(const idaeim::PVL::Aggregate&, const QString&,
bool, int)
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
static std::string
string_value
(
const idaeim::PVL::Aggregate& parameters,
const std::string& pathname,
bool case_sensitive = false,
int skip = 0
);
/** Get the string value of a named parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a char* pathname.
@see string_value(const idaeim::PVL::Aggregate&, const std::string&,
bool, int)
*/
inline static std::string
string_value
(
const idaeim::PVL::Aggregate& parameters,
const char* const pathname,
bool case_sensitive = false,
int skip = 0
)
{return PDS_Metadata::string_value (parameters, std::string (pathname),
case_sensitive, skip);}
/** Get the string value of a named parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a QString pathname.
@see string_value(const idaeim::PVL::Aggregate&, const std::string&,
bool, int)
*/
inline static QString
string_value
(
const idaeim::PVL::Aggregate& parameters,
const QString& pathname,
bool case_sensitive = false,
int skip = 0
)
{return QString::fromStdString (PDS_Metadata::string_value
(parameters, pathname.toStdString (), case_sensitive, skip));}
/** Get the string value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent function.
@see find_parameter(const idaeim::PVL::Aggregate&, const std::string&,
bool, int, Parameter_Class_Selection)
*/
std::string
string_value
(
const std::string& pathname,
bool case_sensitive = false,
int skip = 0
) const;
/** Get the string value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a char* pathname.
@see string_value(const idaeim::PVL::Aggregate&, const std::string&,
bool, int)
*/
inline std::string
string_value
(
const char* const pathname,
bool case_sensitive = false,
int skip = 0
)
{return string_value (std::string (pathname), case_sensitive, skip);}
/** Get the string value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a QString pathname.
@see string_value(const idaeim::PVL::Aggregate&, const std::string&,
bool, int)
*/
inline QString
string_value
(
const QString& pathname,
bool case_sensitive = false,
int skip = 0
)
{return QString::fromStdString (string_value
(pathname.toStdString (), case_sensitive, skip));}
/** Get the string value of a parameter.
@param parameter The parameter from which to obtain a string value.
@return The value of the parameter as a string.
*/
static std::string string_value (const idaeim::PVL::Parameter& parameter);
/** Get the string value of a parameter.
This is a convenience function that overloads the string_value function,
but returns a QString value.
@param parameter The parameter from which to obtain a string value.
@return The value of the parameter as a string.
@see string_value(const idaeim::PVL::Parameter&)
*/
inline static QString QString_value (const idaeim::PVL::Parameter& parameter)
{return QString::fromStdString (PDS_Metadata::string_value (parameter));}
/** Set the value of a named parameter within a Parameter Aggregate.
Only Assignment Parameters with a Value that is not an Array will be
modified. However, the search for a matching name does not make this
distinction.
@param parameters The Aggregate within which to search.
@param pathname The pathname for the parameter to be found.
@param value The value to assign to the parameter.
@param case_sensitive If true, the name search is case sensitive;
case insensitive otherwise.
@param skip The number of parameters that match the pathname to
skip before selecting the parameter to modify.
@return true if the parameter was found; false otherwise.
@see find_parameter(const std::string&, bool, int,
Parameter_Class_Selection)
*/
template <typename T>
bool
parameter_value
(
const idaeim::PVL::Aggregate& parameters,
const std::string& pathname,
T& value,
bool case_sensitive = false,
int skip = 0
)
{
idaeim::PVL::Parameter
*parameter (parameters.find
(pathname, case_sensitive, skip, idaeim::PVL::Parameter::ASSIGNMENT));
if (! parameter ||
parameter->value ().is_Array ())
return false;
parameter->value () = value;
return true;
}
/** Set the value of a named parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a char* pathname.
@see parameter_value(const idaeim::PVL::Aggregate&, const std::string&,
T&, bool, int)
*/
template <typename T>
bool
parameter_value
(
const idaeim::PVL::Aggregate& parameters,
const char* const pathname,
T& value,
bool case_sensitive = false,
int skip = 0
)
{return PDS_Metadata::parameter_value (parameters, std::string (pathname),
value, case_sensitive, skip);}
/** Set the value of a named parameter within a Parameter Aggregate.
This is a convenience function that overloads the equivalent function,
but for use with a QString pathname.
@see parameter_value(const idaeim::PVL::Aggregate&, const std::string&,
T&, bool, int)
*/
template <typename T>
bool
parameter_value
(
const idaeim::PVL::Aggregate& parameters,
const QString& pathname,
T& value,
bool case_sensitive = false,
int skip = 0
)
{return PDS_Metadata::parameter_value (parameters, pathname.toStdString (),
value, case_sensitive, skip);}
/** Set the value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent function.
@see parameter_value(const idaeim::PVL::Aggregate&, const std::string&,
T&, bool, int)
*/
template <typename T>
bool
parameter_value
(
const std::string& pathname,
T& value,
bool case_sensitive = false,
int skip = 0
) const
{return metadata () ?
parameter_value (*metadata (), pathname, value, case_sensitive, skip) :
false;}
/** Set the value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a char* pathname.
@see parameter_value(const std::string&, T&, bool, int)
*/
template <typename T>
bool
parameter_value
(
const char* const pathname,
T& value,
bool case_sensitive = false,
int skip = 0
) const
{return parameter_value (std::string (pathname), value, case_sensitive, skip);}
/** Set the value of a named parameter within the metadata parameters.
This is a convenience method that overloads the equivalent method,
but for use with a QString pathname.
@see parameter_value(const std::string&, T&, bool, int)
*/
template <typename T>
bool
parameter_value
(
const QString& pathname,
T& value,
bool case_sensitive = false,
int skip = 0
) const
{return parameter_value (pathname.toStdString (), value, case_sensitive, skip);}
/** Provide an absolute pathname.
If the pathname does not begin with a {@link
idaeim::PVL::Parameter::path_delimiter() Parameter pathname delimiter}
one is prepended. An empty pathname results in an empty string.
@param pathname A Parameter pathname string.
@return The pathname in absolute form.
*/
static std::string absolute_pathname (const std::string& pathname);