53 mat_fp_ = Mat_Open(file_name.c_str(), MAT_ACC_RDONLY);
60 if (!
IsOpen())
return false;
63 if (!value)
return false;
66 matvar_t* variable = Mat_VarRead(
mat_fp_, field_name.c_str());
67 if (!variable || variable->data_type != MAT_T_DOUBLE)
return false;
69 *value = *
static_cast<double*
>(variable->data);
72 Mat_VarFree(variable);
79 if (!
IsOpen())
return false;
82 if (!value)
return false;
85 matvar_t* variable = Mat_VarRead(
mat_fp_, field_name.c_str());
86 if (!variable)
return false;
88 value->assign(static_cast<char*>(variable->data));
91 Mat_VarFree(variable);
98 if (!
IsOpen())
return false;
101 if (!value)
return false;
104 matvar_t* variable = Mat_VarRead(
mat_fp_, field_name.c_str());
105 if (!variable || variable->data_type != MAT_T_UINT64)
return false;
107 *value = *
static_cast<size_t*
>(variable->data);
110 Mat_VarFree(variable);
116 std::vector<double>* values) {
117 if (!
IsOpen())
return false;
120 if (!values)
return false;
124 matvar_t* variable = Mat_VarRead(
mat_fp_, field_name.c_str());
125 if (!variable || variable->data_type != MAT_T_DOUBLE)
return false;
127 size_t num_elements = variable->nbytes / variable->data_size;
128 for (
size_t ii = 0; ii < num_elements; ii++)
129 values->emplace_back(static_cast<double*>(variable->data)[ii]);
132 Mat_VarFree(variable);
138 std::vector<size_t>* values) {
139 if (!
IsOpen())
return false;
142 if (!values)
return false;
146 matvar_t* variable = Mat_VarRead(
mat_fp_, field_name.c_str());
147 if (!variable || variable->data_type != MAT_T_UINT64)
return false;
149 size_t num_elements = variable->nbytes / variable->data_size;
150 for (
size_t ii = 0; ii < num_elements; ii++)
151 values->emplace_back(static_cast<size_t*>(variable->data)[ii]);
154 Mat_VarFree(variable);
bool ReadString(const std::string &field_name, std::string *value)
bool ReadVector(const std::string &field_name, std::vector< double > *values)
bool ReadScalar(const std::string &field_name, double *value)
bool Open(const std::string &file_name)