SDDS ToolKit Programs and Libraries for C and Python
Loading...
Searching...
No Matches
SDDSFile::Impl Struct Reference

Public Member Functions

int fail (const std::exception &error)
 
sdds::Page & page (std::uint32_t number)
 
const sdds::Page & page (std::uint32_t number) const
 
void requireMutableLayout () const
 
template<class T >
int setParameter (std::uint32_t pageNumber, std::size_t index, const T &value)
 
template<class T >
int setColumn (std::size_t index, std::uint32_t pageNumber, std::uint32_t startRow, const T *values, std::uint32_t rows)
 

Public Attributes

std::string filename
 
std::shared_ptr< sdds::Layout > layout = std::make_shared<sdds::Layout>()
 
std::vector< sdds::Page > pages
 
std::vector< std::string > errors
 
std::size_t readCursor = 0
 
sdds::RecoveryMode recovery = sdds::RecoveryMode::Automatic
 
std::vector< std::int32_t > int32Scratch
 
std::vector< std::uint32_t > uint32Scratch
 
std::vector< double > doubleScratch
 
std::string stringScratch
 
std::vector< std::string > stringsScratch
 
std::vector< char * > stringPointers
 

Detailed Description

Definition at line 149 of file SDDSLegacy.cc.

Member Function Documentation

◆ fail()

int SDDSFile::Impl::fail ( const std::exception & error)
inline

Definition at line 163 of file SDDSLegacy.cc.

163 {
164 errors.emplace_back(error.what());
165 return 0;
166 }

◆ page() [1/2]

sdds::Page & SDDSFile::Impl::page ( std::uint32_t number)
inline

Definition at line 168 of file SDDSLegacy.cc.

168 {
169 if (!number)
170 throw sdds::StateError(sdds::ErrorKind::State, "legacy page numbers start at one");
171 while (pages.size() < number)
172 pages.emplace_back(layout);
173 return pages[number - 1];
174 }

◆ page() [2/2]

const sdds::Page & SDDSFile::Impl::page ( std::uint32_t number) const
inline

Definition at line 176 of file SDDSLegacy.cc.

176 {
177 if (!number || number > pages.size())
178 throw sdds::StateError(sdds::ErrorKind::State, "invalid legacy page number");
179 return pages[number - 1];
180 }

◆ requireMutableLayout()

void SDDSFile::Impl::requireMutableLayout ( ) const
inline

Definition at line 182 of file SDDSLegacy.cc.

182 {
183 if (!pages.empty())
184 throw sdds::StateError(sdds::ErrorKind::State,
185 "definitions cannot be changed after page data is allocated");
186 }

◆ setColumn()

template<class T >
int SDDSFile::Impl::setColumn ( std::size_t index,
std::uint32_t pageNumber,
std::uint32_t startRow,
const T * values,
std::uint32_t rows )
inline

Definition at line 200 of file SDDSLegacy.cc.

201 {
202 try {
203 auto &targetPage = page(pageNumber);
204 sdds::Values incoming = convertedValues(layout->columns.at(index).type, values, rows);
205 if (!startRow) {
206 targetPage.setColumn(index, std::move(incoming));
207 } else {
208 sdds::Values merged = targetPage.column(index);
209 std::visit([&](auto &destination) {
210 using Vector = std::decay_t<decltype(destination)>;
211 const auto &source = std::get<Vector>(incoming);
212 if (destination.size() < startRow)
213 destination.resize(startRow);
214 if (destination.size() < static_cast<std::size_t>(startRow) + source.size())
215 destination.resize(static_cast<std::size_t>(startRow) + source.size());
216 std::copy(source.begin(), source.end(), destination.begin() + startRow);
217 }, merged);
218 targetPage.setColumn(index, std::move(merged));
219 }
220 return 1;
221 } catch (const std::exception &error) {
222 return fail(error);
223 }
224 }

◆ setParameter()

template<class T >
int SDDSFile::Impl::setParameter ( std::uint32_t pageNumber,
std::size_t index,
const T & value )
inline

Definition at line 189 of file SDDSLegacy.cc.

189 {
190 try {
191 page(pageNumber).setParameter(index,
192 convertedScalar(layout->parameters.at(index).type, value));
193 return 1;
194 } catch (const std::exception &error) {
195 return fail(error);
196 }
197 }

Member Data Documentation

◆ doubleScratch

std::vector<double> SDDSFile::Impl::doubleScratch

Definition at line 158 of file SDDSLegacy.cc.

◆ errors

std::vector<std::string> SDDSFile::Impl::errors

Definition at line 153 of file SDDSLegacy.cc.

◆ filename

std::string SDDSFile::Impl::filename

Definition at line 150 of file SDDSLegacy.cc.

◆ int32Scratch

std::vector<std::int32_t> SDDSFile::Impl::int32Scratch

Definition at line 156 of file SDDSLegacy.cc.

◆ layout

std::shared_ptr<sdds::Layout> SDDSFile::Impl::layout = std::make_shared<sdds::Layout>()

Definition at line 151 of file SDDSLegacy.cc.

◆ pages

std::vector<sdds::Page> SDDSFile::Impl::pages

Definition at line 152 of file SDDSLegacy.cc.

◆ readCursor

std::size_t SDDSFile::Impl::readCursor = 0

Definition at line 154 of file SDDSLegacy.cc.

◆ recovery

sdds::RecoveryMode SDDSFile::Impl::recovery = sdds::RecoveryMode::Automatic

Definition at line 155 of file SDDSLegacy.cc.

◆ stringPointers

std::vector<char *> SDDSFile::Impl::stringPointers

Definition at line 161 of file SDDSLegacy.cc.

◆ stringScratch

std::string SDDSFile::Impl::stringScratch

Definition at line 159 of file SDDSLegacy.cc.

◆ stringsScratch

std::vector<std::string> SDDSFile::Impl::stringsScratch

Definition at line 160 of file SDDSLegacy.cc.

◆ uint32Scratch

std::vector<std::uint32_t> SDDSFile::Impl::uint32Scratch

Definition at line 157 of file SDDSLegacy.cc.


The documentation for this struct was generated from the following file: