hdf5_name.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au)
  2. // Copyright 2008-2016 National ICT Australia (NICTA)
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // ------------------------------------------------------------------------
  15. //! \addtogroup diskio
  16. //! @{
  17. namespace hdf5_opts
  18. {
  19. typedef unsigned int flag_type;
  20. struct opts
  21. {
  22. const flag_type flags;
  23. inline explicit opts(const flag_type in_flags);
  24. inline const opts operator+(const opts& rhs) const;
  25. };
  26. inline
  27. opts::opts(const flag_type in_flags)
  28. : flags(in_flags)
  29. {}
  30. inline
  31. const opts
  32. opts::operator+(const opts& rhs) const
  33. {
  34. const opts result( flags | rhs.flags );
  35. return result;
  36. }
  37. // The values below (eg. 1u << 0) are for internal Armadillo use only.
  38. // The values can change without notice.
  39. static const flag_type flag_none = flag_type(0 );
  40. static const flag_type flag_trans = flag_type(1u << 0);
  41. static const flag_type flag_append = flag_type(1u << 1);
  42. static const flag_type flag_replace = flag_type(1u << 2);
  43. struct opts_none : public opts { inline opts_none() : opts(flag_none ) {} };
  44. struct opts_trans : public opts { inline opts_trans() : opts(flag_trans ) {} };
  45. struct opts_append : public opts { inline opts_append() : opts(flag_append ) {} };
  46. struct opts_replace : public opts { inline opts_replace() : opts(flag_replace) {} };
  47. static const opts_none none;
  48. static const opts_trans trans;
  49. static const opts_append append;
  50. static const opts_replace replace;
  51. }
  52. struct hdf5_name
  53. {
  54. const std::string filename;
  55. const std::string dsname;
  56. const hdf5_opts::opts opts;
  57. inline
  58. hdf5_name(const std::string& in_filename)
  59. : filename(in_filename )
  60. , dsname (std::string() )
  61. , opts (hdf5_opts::none)
  62. {}
  63. inline
  64. hdf5_name(const std::string& in_filename, const std::string& in_dsname, const hdf5_opts::opts& in_opts = hdf5_opts::none)
  65. : filename(in_filename)
  66. , dsname (in_dsname )
  67. , opts (in_opts )
  68. {}
  69. };
  70. //! @}