This file is indexed.

/usr/include/trilinos/Teuchos_StandardValidatorXMLConverters.hpp is in libtrilinos-teuchos-dev 12.10.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
// @HEADER
// ***********************************************************************
//
//                    Teuchos: Common Tools Package
//                 Copyright (2004) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
//
// ***********************************************************************
// @HEADER


#ifndef TEUCHOS_STANDARDVALIDATORXMLCONVERTERS_HPP
#define TEUCHOS_STANDARDVALIDATORXMLCONVERTERS_HPP

/*! \file Teuchos_StandardValidatorXMLConverters.hpp
    \brief A collection of standard ValidatorXMLConverters.
*/

#include "Teuchos_ValidatorXMLConverter.hpp"
#include "Teuchos_StandardParameterEntryValidators.hpp"
#include "Teuchos_ValidatorXMLConverterDB.hpp"
#include "Teuchos_XMLParameterListReader.hpp"
#include "Teuchos_DummyObjectGetter.hpp"


namespace Teuchos {


/** \brief Convert a StringToIntegralParameterEntryValidator to and from XML.

This class knows how to write a
StringToIntegralParameterEntryValidator to XML, and create an
StringToIntegralParameterEntryValidator from its XML representation.

Here is the XML representation of a StringToIntegralValidator:

\code
 <Validator
   type="StringToIntegralValidator(NumberType)"
   defaultParameterName="Name of default parameter"
   caseSensitive="[true|false]"
   validatorId="Validator id"
 >
   <String
     stringValue="Value 1"
     integralValue="int value 1"
     stringDoc="Documentation for Value 1"
   />
   <String
     stringValue="Value 2"
     integralValue="int value 2"
     stringDoc="Documentation for Value 2"
   />
   ...More String Values...
 </Validator>
\endcode

Here, "[true|false]" means the XML string representation of either
Boolean true, or Boolean false.

The "integralValue", "stringDoc", and "caseSensitive" XML attributes
are optional. However, if one of the "String" tags includes an
"integralValue" and/or a "stringDoc" XML attribute, all other "String"
tags must do so as well.

 */
template<class IntegralType>
class StringToIntegralValidatorXMLConverter :
  public ValidatorXMLConverter
{

public:

  /** \name Overridden from ValidatorXMLConverter */
  //@{

  /** \brief . */
  RCP<ParameterEntryValidator> convertXML(
    const XMLObject& xmlObj,
    const IDtoValidatorMap& validatorIDsMap) const;

  /** \brief . */
  void convertValidator(
    const RCP<const ParameterEntryValidator> validator,
    XMLObject& xmlObj,
    const ValidatortoIDMap& validatorIDsMap) const;

  #ifdef HAVE_TEUCHOS_DEBUG
  /** \brief . */
  RCP<const ParameterEntryValidator >
  getDummyValidator() const{
    return DummyObjectGetter<
    StringToIntegralParameterEntryValidator<IntegralType> >::getDummyObject();
  }
  #endif

  //@}

private:

  /** \name Private Members */
  //@{

  /** \brief . */
  static const std::string& getIntegralValueAttributeName() {
    static const std::string integralValueAttributeName_ = "integralValue";
    return integralValueAttributeName_;
  }

  /** \brief . */
  static const std::string& getStringTagName() {
    static const std::string stringTagName_ = "String";
    return stringTagName_;
  }

  /** \brief . */
  static const std::string& getStringValueAttributeName() {
    static const std::string stringValueAttributeName_ = "stringValue";
    return stringValueAttributeName_;
  }

  /** \brief . */
  static const std::string& getStringDocAttributeName() {
    static const std::string stringDocAttributeName_ = "stringDoc";
    return stringDocAttributeName_;
  }

  //! Name (tag) of the default parameter attribute.
  static const std::string& getDefaultParameterAttributeName() {
    static const std::string defaultParameterAttributeName_ =
      "defaultParameterName";
    return defaultParameterAttributeName_;
  }

  //! Name (tag) of the caseSensitive attribute.
  static const std::string& getCaseSensitiveAttributeName() {
    static const std::string caseSensitiveAttributeName_ =
      "caseSensitive";
    return caseSensitiveAttributeName_;
  }

  //@}

};


//
// Implementations
//


template<class IntegralType>
RCP<ParameterEntryValidator>
StringToIntegralValidatorXMLConverter<IntegralType>::convertXML(
  const XMLObject& xmlObj,
  const IDtoValidatorMap& /*validatorIDsMap*/) const
{
  Array<std::string> strings;
  Array<std::string> stringDocs;
  Array<IntegralType> integralValues;
  for (int i=0; i<xmlObj.numChildren(); ++i) {
    XMLObject currentChild = xmlObj.getChild(i);
    TEUCHOS_TEST_FOR_EXCEPTION(currentChild.getTag() != getStringTagName(),
      BadTagException,
      "Error converting xmlObject to "
      "StringToIntegralParameterEntryValidator." << std::endl <<
      "Unrecognized tag: " << currentChild.getTag());
    strings.append(currentChild.getRequired(getStringValueAttributeName()));
    if (currentChild.hasAttribute(getIntegralValueAttributeName())) {
      integralValues.append(
        currentChild.getRequired<IntegralType>(
          getIntegralValueAttributeName()));
    }
    if (currentChild.hasAttribute(getStringDocAttributeName())) {
      stringDocs.append(
        currentChild.getRequired<std::string>(getStringDocAttributeName()));
    }
  }
  std::string defaultParameterName =
    xmlObj.getRequired(getDefaultParameterAttributeName());

  // The "caseSensitive" attribute is not required.  It is true by default.
  const bool caseSensitive =
    xmlObj.getWithDefault<bool> (getCaseSensitiveAttributeName (), true);

  typedef StringToIntegralParameterEntryValidator<IntegralType> ret_type;
  if (stringDocs.size() != 0 && integralValues.size() != 0) {
    return rcp (new ret_type (strings, stringDocs, integralValues (), defaultParameterName, caseSensitive));
  }
  else if (integralValues.size() != 0) {
    return rcp (new ret_type (strings, integralValues(), defaultParameterName, caseSensitive));
  }
  else {
    return rcp (new ret_type (strings, defaultParameterName, caseSensitive));
  }
}


template<class IntegralType>
void StringToIntegralValidatorXMLConverter<IntegralType>::convertValidator(
  const RCP<const ParameterEntryValidator> validator,
  XMLObject& xmlObj,
  const ValidatortoIDMap& /*validatorIDsMap*/) const
{
  RCP<const StringToIntegralParameterEntryValidator<IntegralType> >
    castedValidator =
    rcp_dynamic_cast<
      const StringToIntegralParameterEntryValidator<IntegralType> >(
        validator, true);

  RCP<const Array<std::string> > stringValues =
    castedValidator->validStringValues();
  RCP<const Array<std::string> > stringDocValues =
    castedValidator->getStringDocs();

  bool hasStringDocs =
    !(stringDocValues.is_null()) && (stringDocValues->size() != 0);
  for (int i =0; i<stringValues->size(); ++i) {
    XMLObject stringTag(getStringTagName());
    stringTag.addAttribute(getStringValueAttributeName(), (*stringValues)[i]);
    stringTag.addAttribute(getIntegralValueAttributeName(),
      castedValidator->getIntegralValue((*stringValues)[i]));
    if (hasStringDocs) {
      stringTag.addAttribute(
        getStringDocAttributeName(), (*stringDocValues)[i]);
    }
    xmlObj.addChild(stringTag);
  }
  xmlObj.addAttribute(getDefaultParameterAttributeName(),
    castedValidator->getDefaultParameterName());

  // Add "caseSensitive" bool attribute here.
  const bool caseSensitive = castedValidator->isCaseSensitive ();
  xmlObj.addBool (getCaseSensitiveAttributeName (), caseSensitive);

  xmlObj.addAttribute(getIntegralValueAttributeName(),
    TypeNameTraits<IntegralType>::name());
}

/**
 * \brief Converts BoolParameterEntryValidators to and from XML.
 *
 * The valid XML representation for an BoolParameterEntryValidators is:
 * \code
  <Validator type="BoolValidator"
  />
  \endcode
 */
class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT BoolValidatorXMLConverter : public ValidatorXMLConverter
{

public:

  /** \name Overridden from ValidatorXMLConverter */
  //@{

  /** \brief . */
  RCP<ParameterEntryValidator> convertXML(
    const XMLObject& xmlObj,
    const IDtoValidatorMap& validatorIDsMap) const;

  /** \brief . */
  void convertValidator(
    const RCP<const ParameterEntryValidator> validator,
    XMLObject& xmlObj,
    const ValidatortoIDMap& validatorIDsMap) const;

  #ifdef HAVE_TEUCHOS_DEBUG
  /** \brief . */
  RCP<const ParameterEntryValidator> getDummyValidator() const;
  #endif

  //@}

private:

  /** \name Private Members */
  //@{

  // currently empty

  //@}

};

/**
 * \brief Converts AnyNumberParameterEntryValidators to and from XML.
 *
 * The valid XML representation for an AnyNumberParameterEntryValidator is:
 * \code
  <Validator type="AnyNumberValidator"
   allowInt="True or False"
   allowDouble="True or False"
   allowString="True or False"
   prefferedType="Prefered type"
  />
  \endcode
 */
class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT AnyNumberValidatorXMLConverter : public ValidatorXMLConverter
{

public:

  /** \name Overridden from ValidatorXMLConverter */
  //@{

  /** \brief . */
  RCP<ParameterEntryValidator> convertXML(
    const XMLObject& xmlObj,
    const IDtoValidatorMap& validatorIDsMap) const;

  /** \brief . */
  void convertValidator(
    const RCP<const ParameterEntryValidator> validator,
    XMLObject& xmlObj,
    const ValidatortoIDMap& validatorIDsMap) const;

  #ifdef HAVE_TEUCHOS_DEBUG
  /** \brief . */
  RCP<const ParameterEntryValidator> getDummyValidator() const;
  #endif

  //@}

private:

  /** \name Private Members */
  //@{

  /** \brief . */
  static const std::string& getAllowIntAttributeName() {
    static const std::string allowIntAttributeName_ = "allowInt";
    return allowIntAttributeName_;
  }

  /** \brief . */
  static const std::string& getAllowDoubleAttributeName() {
    static const std::string allowDoubleAttributeName_ = "allowDouble";
    return allowDoubleAttributeName_;
  }

  /** \brief . */
  static const std::string& getAllowStringAttributeName() {
    static const std::string allowStringAttributeName_ = "allowString";
    return allowStringAttributeName_;
  }

  /** \brief . */
  static const std::string& getPrefferedTypeAttributeName() {
    static const std::string prefferedTypeAttributeName_ = "prefferedType";
    return prefferedTypeAttributeName_;
  }

  //@}

};


/** \brief Converts EnhancedNumberValidators to and from XML.
 *
 * The valid XML representation of an EnhancedNumberValidator is:
 * \code
  <Validator type="EnhancedNumberValidator(numbertype)"
   min="Minimum Value"
   max="Maximum Value"
   step="Step Value"
   precision="Precision Value"
   validatorId="Validator Id"
  />
  \endcode
 * The "min", "max", "step", and "precision" XML attributes are all optional.
 */
template<class T>
class EnhancedNumberValidatorXMLConverter : public ValidatorXMLConverter
{

public:

  /** \name Overridden from ValidatorXMLConverter */
  //@{

  /** \brief . */
  RCP<ParameterEntryValidator> convertXML(
    const XMLObject& xmlObj,
    const IDtoValidatorMap& validatorIDsMap) const;

  /** \brief . */
  void convertValidator(
    const RCP<const ParameterEntryValidator> validator,
    XMLObject& xmlObj,
    const ValidatortoIDMap& validatorIDsMap) const;

#ifdef HAVE_TEUCHOS_DEBUG
  /** \brief . */
  RCP<const ParameterEntryValidator> getDummyValidator() const{
    return DummyObjectGetter<EnhancedNumberValidator<T> >::getDummyObject();
  }
#endif

  //@}

private:

  /** \name Private Members */
  //@{

  /** \brief . */
  static const std::string& getMinAttributeName() {
    static const std::string minAttributeName = "min";
    return minAttributeName;
  }

  /** \brief . */
  static const std::string& getMaxAttributeName() {
    static const std::string maxAttributeName = "max";
    return maxAttributeName;
  }

  /** \brief . */
  static const std::string& getStepAttributeName() {
    static const std::string stepAttributeName = "step";
    return stepAttributeName;
  }

  /** \brief . */
  static const std::string& getPrecisionAttributeName() {
    static const std::string precisionAttributeName = "precision";
    return precisionAttributeName;
  }

  //@}

};


template<class T>
RCP<ParameterEntryValidator>
EnhancedNumberValidatorXMLConverter<T>::convertXML(
  const XMLObject& xmlObj,
  const IDtoValidatorMap& /*validatorIDsMap*/) const
{
  RCP<EnhancedNumberValidator<T> > toReturn =
    rcp(new EnhancedNumberValidator<T>);
  T step = xmlObj.getWithDefault(
    getStepAttributeName(), EnhancedNumberTraits<T>::defaultStep());
  toReturn->setStep(step);
  unsigned short int precision = xmlObj.getWithDefault(
   getPrecisionAttributeName(),
   EnhancedNumberTraits<T>::defaultPrecision());
  toReturn->setPrecision(precision);
  if (xmlObj.hasAttribute(getMinAttributeName())) {
    toReturn->setMin(xmlObj.getRequired<T>(getMinAttributeName()));
  }
  if (xmlObj.hasAttribute(getMaxAttributeName())) {
    toReturn->setMax(xmlObj.getRequired<T>(getMaxAttributeName()));
  }
  return toReturn;
}


template<class T>
void EnhancedNumberValidatorXMLConverter<T>::convertValidator(
  const RCP<const ParameterEntryValidator > validator,
  XMLObject& xmlObj,
  const ValidatortoIDMap& /*validatorIDsMap*/) const
{
  RCP<const EnhancedNumberValidator<T> > castedValidator =
    rcp_dynamic_cast<const EnhancedNumberValidator<T> >(validator, true);
  if (castedValidator->hasMin()) {
    xmlObj.addAttribute<T>(getMinAttributeName(), castedValidator->getMin());
  }
  if (castedValidator->hasMax()) {
    xmlObj.addAttribute<T>(getMaxAttributeName(), castedValidator->getMax());
  }
  xmlObj.addAttribute<T>(getStepAttributeName(), castedValidator->getStep());
  xmlObj.addAttribute<short unsigned int>(
    getPrecisionAttributeName(), castedValidator->getPrecision());
}


/**
 * \brief Converts FileNameValidators to and from XML.
 *
 * The valid XML representation of a FileNameValidator is:
 *
 * \code
  <Validator type="FilenameValidator"
   fileMustExist="Bool Value"
   validatorId="Validator Id"
  />
  \endcode
 *
 * The "fileMustExist" XML attribute is optional.
 */
class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT FileNameValidatorXMLConverter : public ValidatorXMLConverter
{

public:

  /** \name Overridden from ValidatorXMLConverter */
  //@{

  /** \brief . */
  RCP<ParameterEntryValidator> convertXML(
    const XMLObject& xmlObj,
    const IDtoValidatorMap& validatorIDsMap) const;

  /** \brief . */
  void convertValidator(
    const RCP<const ParameterEntryValidator> validator,
    XMLObject& xmlObj,
    const ValidatortoIDMap& validatorIDsMap) const;

  #ifdef HAVE_TEUCHOS_DEBUG
  /** \brief . */
  RCP<const ParameterEntryValidator> getDummyValidator() const;
  #endif

  //@}

private:

  /** \name Private Members */
  //@{

  /** \brief . */
  static const std::string& getFileMustExistAttributeName() {
    static const std::string fileMustExistAttributeName = "fileMustExist";
    return fileMustExistAttributeName;
  }

  //@}

};


/**
 * \brief Converts StringValidators to and from XML.
 *
 * The valid XML represenation of a StringValidator is:
 * \code
  <Validator type="StringValidator"
   validatorId="Validator id"
  >
    <String value="Value 1"/>
    <String value="Value 2"/>
    ...Other String Values...
  </Validator>
 \endcode
 */
class TEUCHOSPARAMETERLIST_LIB_DLL_EXPORT StringValidatorXMLConverter : public ValidatorXMLConverter
{

public:

  /** \name Overridden from ValidatorXMLConverter */
  //@{

  /** \brief . */
  RCP<ParameterEntryValidator> convertXML(
    const XMLObject& xmlObj,
    const IDtoValidatorMap& validatorIDsMap) const;

  /** \brief . */
  void convertValidator(
    const RCP<const ParameterEntryValidator> validator,
    XMLObject& xmlObj,
    const ValidatortoIDMap& validatorIDsMap) const;

  #ifdef HAVE_TEUCHOS_DEBUG
  /** \brief . */
  RCP<const ParameterEntryValidator> getDummyValidator() const;
  #endif

  //@}

private:

  /** \name Private Members */
  //@{

  /** \brief . */
  static const std::string& getStringTagName() {
    static const std::string stringTagName = "String";
    return stringTagName;
  }

  /** \brief . */
  static const std::string& getStringValueAttributeName() {
    static const std::string stringValueAttributeName = "value";
    return stringValueAttributeName;
  }

  //@}

};

template<class ValidatorType, class EntryType>
class AbstractArrayValidatorXMLConverter : public ValidatorXMLConverter{
public:

  /** \name Overridden from ValidatorXMLConverter */
  //@{

  /** \brief . */
  RCP<ParameterEntryValidator> convertXML(
    const XMLObject& xmlObj,
    const IDtoValidatorMap& validatorIDsMap) const;

  /** \brief . */
  void convertValidator(
    const RCP<const ParameterEntryValidator> validator,
    XMLObject& xmlObj,
    const ValidatortoIDMap& validatorIDsMap) const;

  //@}

  /** \name Pure Virtual Fuctions */
  //@{

  /** \brief Returns a concrete validator that has
   * AbstractArrayValidator as it's parent class.
   */
  virtual RCP<AbstractArrayValidator<ValidatorType, EntryType> >
    getConcreteValidator(RCP<ValidatorType> prototypeValidator) const = 0;

  //@}
};


template<class ValidatorType, class EntryType>
RCP<ParameterEntryValidator>
AbstractArrayValidatorXMLConverter<ValidatorType, EntryType>::convertXML(
    const XMLObject& xmlObj,
    const IDtoValidatorMap& validatorIDsMap) const
{
  RCP<ValidatorType> prototypeValidator;
  if(xmlObj.hasAttribute(
    ValidatorXMLConverter::getPrototypeIdAttributeName()))
  {
    IDtoValidatorMap::const_iterator result =
      validatorIDsMap.find(
        xmlObj.getRequired<ParameterEntryValidator::ValidatorID>(
          getPrototypeIdAttributeName()));
    if (result != validatorIDsMap.end() ) {
      prototypeValidator =
        rcp_dynamic_cast<ValidatorType>(result->second, true);
    }
    else {
      TEUCHOS_TEST_FOR_EXCEPTION(true,
        MissingValidatorDefinitionException,
        "Could not find prototype validator with id: "
        << xmlObj.getRequired<ParameterEntryValidator::ValidatorID>(
          getPrototypeIdAttributeName()) << std::endl<< std::endl);
    }
  }
  else {
    prototypeValidator = rcp_dynamic_cast<ValidatorType>(
      ValidatorXMLConverterDB::convertXML(
        xmlObj.getChild(0), validatorIDsMap), true);
  }
  return getConcreteValidator(prototypeValidator);
}

template<class ValidatorType, class EntryType>
void
AbstractArrayValidatorXMLConverter<ValidatorType, EntryType>::convertValidator(
  const RCP<const ParameterEntryValidator> validator,
  XMLObject& xmlObj,
  const ValidatortoIDMap& validatorIDsMap) const
{
  RCP<const AbstractArrayValidator<ValidatorType, EntryType> > castedValidator =
    rcp_dynamic_cast<const AbstractArrayValidator<ValidatorType, EntryType> >(
      validator, true);
  if(validatorIDsMap.find(castedValidator->getPrototype())
    == validatorIDsMap.end())
  {
    xmlObj.addChild(ValidatorXMLConverterDB::convertValidator(
      castedValidator->getPrototype(), validatorIDsMap, false));
  }
  else{
    ParameterEntryValidator::ValidatorID prototypeID =
      validatorIDsMap.find(castedValidator->getPrototype())->second;

    xmlObj.addAttribute<ParameterEntryValidator::ValidatorID>(
      getPrototypeIdAttributeName(), prototypeID);
  }
}

/**
 * \brief Converts ArrayValidators to and from XML.
 *
 * ArrayValidators can be represented in XML one of two ways.
 * The first just creates the prototype validator as a child of
 * the ArrayValidator. In this case, the prototype validator does
 * NOT use a validatorId.
 *\code
  <Validator
   type="ArrayValidator(PrototypeValidatorType,ParameterArrayType)"
   validatorId="Validator id"
  >
     ...Prototype Validator Goes Here...
  </Validator>
 \endcode
 *
 * The second way to define an ArrayValidator in XML is to just use
 * the "prototypeId" attribute to specify the prototype validator as
 * some other validator you've already defined.
 * \code
   <Validator
     type="ArrayValidator(PrototypeValidatorType,ParameterArrayType)"
     validatorId="Validator id"
     prototypeId="Prototype Validator Id"
   />
 * \endcode
 */
template<class ValidatorType, class EntryType>
class ArrayValidatorXMLConverter :
  public AbstractArrayValidatorXMLConverter<ValidatorType, EntryType>
{
  /** @name Overridden from AbstractArrayValidatorXMLConverter */
  //@{

  virtual RCP<AbstractArrayValidator<ValidatorType, EntryType> > getConcreteValidator(
    RCP<ValidatorType> prototypeValidator) const
  {
    return rcp(new ArrayValidator<ValidatorType, EntryType>(prototypeValidator));
  }

#ifdef HAVE_TEUCHOS_DEBUG
  /** @name Overridden ValidatorXMLConverter*/
  //@{
  /** \brief . */
  RCP<const ParameterEntryValidator> getDummyValidator() const{
    return DummyObjectGetter<ArrayValidator<ValidatorType, EntryType> >::
      getDummyObject();
  }
  //@}
#endif
};

/**
 * \brief Converts TwoDArrayValidators to and from XML.
 *
 * TwoDArrayValidators can be represented in XML one of two ways.
 * The first just creates the prototype validator as a child of
 * the ArrayValidator. In this case, the prototype validator does
 * NOT use a validatorId.
 *\code
  <Validator
   type="TwoDArrayValidator(PrototypeValidatorType,ParameterArrayType)"
   validatorId="Validator id"
  >
     ...Prototype Validator Goes Here...
  </Validator>
 \endcode
 *
 * The second way to define an TwoDArrayValidator in XML is to just use
 * the "prototypeId" attribute to specify the prototype validator as
 * some other validator you've already defined.
 * \code
   <Validator
     type="TwoDArrayValidator(PrototypeValidatorType,ParameterArrayType)"
     validatorId="Validator id"
     prototypeId="Prototype Validator Id"
   />
 * \endcode
 */
template<class ValidatorType, class EntryType>
class TwoDArrayValidatorXMLConverter :
  public AbstractArrayValidatorXMLConverter<ValidatorType, EntryType>
{
  /** @name Overridden from AbstractArrayValidatorXMLConverter */
  //@{

  virtual RCP<AbstractArrayValidator<ValidatorType, EntryType> > getConcreteValidator(
    RCP<ValidatorType> prototypeValidator) const
  {
    return rcp(new TwoDArrayValidator<ValidatorType, EntryType>(prototypeValidator));
  }

  //@}

#ifdef HAVE_TEUCHOS_DEBUG
  /** @name Overridden ValidatorXMLConverter*/
  //@{
  /** \brief . */
  RCP<const ParameterEntryValidator> getDummyValidator() const{
    return DummyObjectGetter<TwoDArrayValidator<ValidatorType, EntryType> >::
      getDummyObject();
  }
  //@}
#endif

};



} // namespace Teuchos


#endif  // TEUCHOS_STANDARDVALIDATORXMLCONVERTERS_HPP