SchemaFractionDigits.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "XMLTags.h"
  14. #include "jptree.hpp"
  15. #include <cstdlib>
  16. #include "SchemaFractionDigits.hpp"
  17. using namespace CONFIGURATOR;
  18. #define IPropertyTree ::IPropertyTree
  19. CFractionDigits* CFractionDigits::load(CXSDNodeBase* pParentNode, const IPropertyTree *pSchemaRoot, const char* xpath)
  20. {
  21. assert(pSchemaRoot != NULL);
  22. if (pSchemaRoot == NULL)
  23. return NULL;
  24. CFractionDigits *pFractionDigits = new CFractionDigits(pParentNode);
  25. pFractionDigits->setXSDXPath(xpath);
  26. if (xpath != NULL && *xpath != 0)
  27. {
  28. IPropertyTree* pTree = pSchemaRoot->queryPropTree(xpath);
  29. if (pTree == NULL)
  30. return pFractionDigits;
  31. const char* pValue = pTree->queryProp(XML_ATTR_VALUE);
  32. if (pValue != NULL && *pValue != 0)
  33. {
  34. pFractionDigits->setFractionDigits(pValue);
  35. pFractionDigits->setValue(pValue);
  36. }
  37. if (pFractionDigits->getFractionDigits() < 0) // not set or bad length value
  38. {
  39. delete pFractionDigits;
  40. pFractionDigits = NULL;
  41. //throw MakeExceptionFromMap(EX_STR_LENGTH_VALUE_MUST_BE_GREATER_THAN_OR_EQUAL_TO_ZERO, EACTION_FRACTION_DIGITS_HAS_BAD_LENGTH);
  42. assert(false);
  43. }
  44. }
  45. return pFractionDigits;
  46. }
  47. void CFractionDigits::dump(::std::ostream& cout, unsigned int offset) const
  48. {
  49. offset+= STANDARD_OFFSET_1;
  50. quickOutHeader(cout, XSD_FRACTION_DIGITS_STR, offset);
  51. QUICK_OUT(cout, XSDXPath, offset);
  52. QUICK_OUT(cout, EnvXPath, offset);
  53. QUICK_OUT(cout, Value, offset);
  54. QUICK_OUT(cout, FractionDigits, offset);
  55. quickOutFooter(cout, XSD_FRACTION_DIGITS_STR, offset);
  56. }