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