jprop.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 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. #ifndef JPROP_INCL
  14. #define JPROP_INCL
  15. #include "jiface.hpp"
  16. #include "jhash.hpp"
  17. #include "jstring.hpp"
  18. // Property tables
  19. template <class PTYPE>
  20. interface jlib_decl IPropertyIteratorOf : extends IInterface
  21. {
  22. virtual bool first() = 0;
  23. virtual bool next() = 0;
  24. virtual bool isValid() = 0;
  25. virtual PTYPE getPropKey() = 0;
  26. };
  27. template <class PTYPE, class PITER>
  28. interface jlib_decl IPropertiesOf : extends serializable
  29. {
  30. virtual int getPropInt(PTYPE propname, int dft=0) const = 0;
  31. virtual bool getProp(PTYPE propname, StringBuffer &ret) const = 0;
  32. virtual const char *queryProp(PTYPE propname) const = 0;
  33. virtual void setProp(PTYPE propname, int val) = 0;
  34. virtual void setProp(PTYPE propname, const char *val) = 0;
  35. virtual void appendProp(PTYPE propname, const char *val) = 0;
  36. virtual bool hasProp(PTYPE propname) const = 0;
  37. virtual PITER *getIterator() const = 0;
  38. virtual void loadFile(const char *filename) = 0;
  39. virtual void loadProps(const char *text) = 0;
  40. virtual void loadProp(const char *text) = 0;
  41. virtual void loadProp(const char *text, int dft) = 0;
  42. virtual void loadProp(const char *text, bool dft) = 0;
  43. virtual void loadProp(const char *text, const char * dft) = 0;
  44. virtual void saveFile(const char *filename) const = 0;
  45. virtual bool removeProp(PTYPE propname) = 0;
  46. virtual bool getPropBool(PTYPE propname, bool dft=false) const = 0;
  47. };
  48. #ifdef _MSC_VER
  49. #pragma warning( push )
  50. #pragma warning( disable : 4275 ) // hope this warning not significant! (may get link errors I guess)
  51. #endif
  52. interface IPropertyIterator : public IPropertyIteratorOf<char_ptr> { };
  53. interface IAtomPropertyIterator : public IPropertyIteratorOf<IAtom *> { };
  54. interface IProperties : public IPropertiesOf<char_ptr, IPropertyIterator> { };
  55. #ifdef _MSC_VER
  56. #pragma warning( pop )
  57. #endif
  58. extern jlib_decl IProperties *createProperties(bool nocase = false);
  59. extern jlib_decl IProperties *createProperties(const char *filename, bool nocase = false);
  60. extern jlib_decl IProperties *querySystemProperties();
  61. extern jlib_decl IProperties *getSystemProperties();
  62. #endif