return ret.retn();
}
+std::vector<std::string> MEDFileFieldRepresentationTree::SplitFieldNameIntoParts(const std::string& fullFieldName, char sep)
+{
+ std::vector<std::string> ret;
+ std::size_t pos(0);
+ while(pos!=std::string::npos)
+ {
+ std::size_t curPos(fullFieldName.find_first_of(sep,pos));
+ std::string elt(fullFieldName.substr(pos,curPos!=std::string::npos?curPos-pos:std::string::npos));
+ ret.push_back(elt);
+ pos=fullFieldName.find_first_not_of(sep,curPos);
+ }
+ return ret;
+}
+
+/*!
+ * Here the non regression tests.
+ * const char inp0[]="";
+ * const char exp0[]="";
+ * const char inp1[]="field";
+ * const char exp1[]="field";
+ * const char inp2[]="_________";
+ * const char exp2[]="_________";
+ * const char inp3[]="field_p";
+ * const char exp3[]="field_p";
+ * const char inp4[]="field__p";
+ * const char exp4[]="field_p";
+ * const char inp5[]="field_p__";
+ * const char exp5[]="field_p";
+ * const char inp6[]="field_p_";
+ * const char exp6[]="field_p";
+ * const char inp7[]="field_____EDFGEG//sdkjf_____PP_______________";
+ * const char exp7[]="field_EDFGEG//sdkjf_PP";
+ * const char inp8[]="field_____EDFGEG//sdkjf_____PP";
+ * const char exp8[]="field_EDFGEG//sdkjf_PP";
+ * const char inp9[]="_field_____EDFGEG//sdkjf_____PP_______________";
+ * const char exp9[]="field_EDFGEG//sdkjf_PP";
+ * const char inp10[]="___field_____EDFGEG//sdkjf_____PP_______________";
+ * const char exp10[]="field_EDFGEG//sdkjf_PP";
+*/
+std::string MEDFileFieldRepresentationTree::PostProcessFieldName(const std::string& fullFieldName)
+{
+ static const char SEP('_');
+ std::vector<std::string> v(SplitFieldNameIntoParts(fullFieldName,SEP));
+ if(v.empty())
+ return fullFieldName;//should never happen
+ if(v.size()==1)
+ {
+ if(v[0].empty())
+ return fullFieldName;
+ else
+ return v[0];
+ }
+ std::string ret(v[0]);
+ for(std::size_t i=1;i<v.size();i++)
+ {
+ if(!v[i].empty())
+ {
+ if(!ret.empty())
+ { ret+=SEP; ret+=v[i]; }
+ else
+ ret=v[i];
+ }
+ }
+ if(ret.empty())
+ return fullFieldName;
+ return ret;
+}
+
///////////
TimeKeeper::TimeKeeper(int policy):_policy(policy)
void removeEmptyLeaves();
// static methods
static bool IsFieldMeshRegardingInfo(const std::vector<std::string>& compInfos);
+ static std::string PostProcessFieldName(const std::string& fullFieldName);
public:
static const char ROOT_OF_GRPS_IN_TREE[];
static const char ROOT_OF_FAM_IDS_IN_TREE[];
const MEDFileFieldRepresentationLeaves& getTheSingleActivated(int& lev0, int& lev1, int& lev2) const;
static ParaMEDMEM::MEDFileFields *BuildFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms);
static void AppendFieldFromMeshes(const ParaMEDMEM::MEDFileMeshes *ms, ParaMEDMEM::MEDFileFields *ret);
+ static std::vector<std::string> SplitFieldNameIntoParts(const std::string& fullFieldName, char sep);
private:
// 1st : timesteps, 2nd : meshName, 3rd : common support
std::vector< std::vector< std::vector< MEDFileFieldRepresentationLeaves > > > _data_structure;