#ifndef RADIX_RADIXIO_ARLDATASTREAM_HH_ #define RADIX_RADIXIO_ARLDATASTREAM_HH_ #include #include #include #include #include #include #include #include "radixcore/visibility.hh" namespace radix { // // Forward declare ARLRecordHeader and ARLIndexHeader struct ARLIndexHeader; struct ARLRecordHeader; class RADIX_PUBLIC ARLDataStream { // forward declare private implementation class PImpl; // unique pointer to private implmentation std::unique_ptr p; private: static const int indexHeaderLength = 50, recordHeaderLength = 108; /** * @brief expand Expands string of 50 characters to an ARLIndexHeader * @param val String for expansion * @param index ARLIndexHeader */ static void expand(const std::string& val, ARLIndexHeader& index); /** * @brief expand Expands string of 108 characters to ARLHeader * @param val String for expansion * @param index ALRIndexHeader required for determining grid domain extending * beyond 3 digits * @param header ARLHeader */ static void expand(const std::string& val, const ARLIndexHeader& index, ARLRecordHeader& header); public: ARLDataStream() = delete; ARLDataStream(const std::string& file); /** * @brief read_index_header Reads a single index header from the stream * @param iheader ARLIndexHeader& * @return */ bool read_index_header(ARLIndexHeader& iheader); bool write_index_header(const ARLIndexHeader& iheader); /** * @brief read_next_index_header Sets the stream position to that of the next * index header and reads that header * @return */ bool read_next_index_header(ARLIndexHeader& iheader); bool read_record_header(const ARLIndexHeader& iheader, ARLRecordHeader& rheader); bool write_record_header(const ARLIndexHeader& iheader, const ARLRecordHeader& rheader); /** * @brief read_record Reads a single record from the stream * @param ARLRecord& record * * @return bool on if inventory was populated */ bool read_record(const ARLIndexHeader& iheader, const ARLRecordHeader& rheader, std::vector >& record); // TODO bool write_record(const ARLIndexHeader& iheader, const ARLRecordHeader& rheader, const std::vector >& record); }; // class ARLDataStream struct RADIX_PUBLIC ARLRecordHeader { public: bool prime; bool latlon; bool gbldat; bool global; int icx; int mn; float pole_lat; float pole_lon; float ref_lon; float ref_lat; float size; float orient; float tang_lat; float sync_xp; float sync_yp; float sync_lat; float sync_lon; float dummy; int nx; int ny; int nz; int z_flag; int lenh; std::string model_id; }; // ARLHeader struct RADIX_PUBLIC ARLIndexHeader { public: int year; int month; int day; int hour; int ic; int il; int nexp; float prec; float var1; std::string cgrid; std::string kvar; }; } // namespace radix //#include "arldatastream.i.hh" #endif /** RADIX_RADIXIO_ARLDATASTREAM_HH_ */