1 #define EZC3D_API_EXPORTS 15 _description(description),
23 std::cout <<
"groupName = " << name() << std::endl;
24 std::cout <<
"isLocked = " << isLocked() << std::endl;
25 std::cout <<
"desc = " << description() << std::endl;
27 for (
size_t i=0; i < nbParameters(); ++i){
28 std::cout <<
"Parameter " << i << std::endl;
35 int nCharName(static_cast<int>(name().size()));
38 f.write(reinterpret_cast<const char*>(&nCharName), 1*ezc3d::DATA_TYPE::BYTE);
41 f.write(reinterpret_cast<const char*>(&groupIdx), 1*ezc3d::DATA_TYPE::BYTE);
42 f.write(
ezc3d::toUpper(name()).c_str(), nCharName*ezc3d::DATA_TYPE::BYTE);
46 std::streampos pos(f.tellg());
47 f.write(reinterpret_cast<const char*>(&blank), 2*ezc3d::DATA_TYPE::BYTE);
49 int nCharGroupDescription(static_cast<int>(description().size()));
50 f.write(reinterpret_cast<const char*>(&nCharGroupDescription), 1*ezc3d::DATA_TYPE::BYTE);
51 f.write(description().c_str(), nCharGroupDescription*ezc3d::DATA_TYPE::BYTE);
53 std::streampos currentPos(f.tellg());
56 int nCharToNext = int(currentPos - pos);
57 f.write(reinterpret_cast<const char*>(&nCharToNext), 2*ezc3d::DATA_TYPE::BYTE);
60 for (
size_t i=0; i < nbParameters(); ++i)
61 parameter(i).write(f, -groupIdx, dataStartPosition);
66 std::fstream &file,
int nbCharInName)
74 _name.assign(
c3d.
readString(file, static_cast<unsigned int>(abs(nbCharInName) * ezc3d::DATA_TYPE::BYTE)));
79 int nextParamByteInFile;
81 nextParamByteInFile = 0;
83 nextParamByteInFile =
static_cast<int>(
static_cast<size_t>(file.tellg()) + offsetNext - ezc3d::DATA_TYPE::WORD);
89 _description =
c3d.
readString(file, static_cast<unsigned int>(nbCharInDesc));
92 return nextParamByteInFile;
112 _description = description;
131 return _parameters.size();
136 for (
size_t i = 0; i < nbParameters(); ++i)
137 if (!parameter(i).name().compare(parameterName))
139 throw std::invalid_argument(
"Group::parameterIdx could not find " + parameterName +
140 " in the group " + name());
146 return _parameters.at(idx);
147 }
catch(std::out_of_range) {
148 throw std::out_of_range(
"Groups::parameter method is trying to access the parameter " 149 + std::to_string(idx) +
150 " while the maximum number of parameter is " 151 + std::to_string(nbParameters()) +
" in the group " + name() +
".");
158 return _parameters.at(idx);
159 }
catch(std::out_of_range) {
160 throw std::out_of_range(
"Groups::parameter method is trying to access the parameter " 161 + std::to_string(idx) +
162 " while the maximum number of parameters is " 163 + std::to_string(nbParameters()) +
" in the group " + name() +
".");
169 return parameter(parameterIdx(parameterName));
174 return parameter_nonConst(parameterIdx(parameterName));
180 int nextParamByteInFile = p.
read(
c3d, params, file, nbCharInName);
182 return nextParamByteInFile;
187 if (p.
type() == ezc3d::DATA_TYPE::NO_DATA_TYPE)
188 throw std::runtime_error(
"Data type is not set");
190 size_t alreadyExistIdx(SIZE_MAX);
191 for (
size_t i=0; i < _parameters.size(); ++i)
192 if (!parameter(i).name().compare(p.
name())){
196 if (alreadyExistIdx == SIZE_MAX)
197 _parameters.push_back(p);
199 _parameters[alreadyExistIdx] = p;
Group holder of C3D parameters.
size_t readUint(PROCESSOR_TYPE processorType, std::fstream &file, unsigned int nByteToRead, int nByteFromPrevious=0, const std::ios_base::seekdir &pos=std::ios::cur)
Read a unsigned integer of nByteToRead bytes at the position current + nByteFromPrevious from a file...
Declaration of Group class.
void unlock()
Set the locking status of the group to false.
size_t nbParameters() const
Get the number of parameters.
ezc3d::DATA_TYPE type() const
Return the type of the data.
size_t parameterIdx(std::string parameterName) const
Get the index of a parameter in the group.
const std::string & description() const
Get the description of the group.
PROCESSOR_TYPE processorType() const
Get the processor type the file was writen on.
void print() const
Print the group by calling the print method of all the parameters.
const ezc3d::ParametersNS::GroupNS::Parameter & parameter(size_t idx) const
Get a particular parameter of index idx from the group.
const std::string & name() const
Get the name of the parameter.
void write(std::fstream &f, int groupIdx, std::streampos &dataStartPosition) const
Write the group to an opened file by calling the write method of all the parameters.
Main class for C3D holder.
const std::string & name() const
Get the name of the group.
const std::vector< ezc3d::ParametersNS::GroupNS::Parameter > & parameters() const
Get all the parameter from the group.
Group(const std::string &name="", const std::string &description="")
Create an empty group of parameter.
bool isLocked() const
Get the locking status of the group.
std::string toUpper(const std::string &str)
Swap all characters of a string to capital letters.
int readInt(PROCESSOR_TYPE processorType, std::fstream &file, unsigned int nByteToRead, int nByteFromPrevious=0, const std::ios_base::seekdir &pos=std::ios::cur)
Read an integer of nByteToRead bytes at the position current + nByteFromPrevious from a file...
int read(c3d &c3d, const Parameters ¶ms, std::fstream &file, int nbCharInName)
Read and store a parameter from an opened C3D file.
std::string readString(std::fstream &file, unsigned int nByteToRead, int nByteFromPrevious=0, const std::ios_base::seekdir &pos=std::ios::cur)
Read a string (array of char of nByteToRead bytes) at the position current + nByteFromPrevious from a...
ezc3d::ParametersNS::GroupNS::Parameter & parameter_nonConst(size_t idx)
Get a particular parameter of index idx from the group in order to be modified by the caller...
int read(ezc3d::c3d &c3d, const Parameters ¶ms, std::fstream &file, int nbCharInName)
Read and store a group of parameter from an opened C3D file.
void lock()
Set the locking status of the group to true.
Declaration of Parameters class.