30 #ifndef _GENICAM_PERSISTENCE_H 31 #define _GENICAM_PERSISTENCE_H 70 bool LoadFromBag(
INodeMap *pNodeMap,
bool Verify =
true, GENICAM_NAMESPACE::gcstring_vector *pErrorList = NULL);
78 int64_t StoreToBag(
INodeMap *pNodeMap,
const int MaxNumPersistSkriptEntries = -1, GENICAM_NAMESPACE::gcstring_vector *pFeatureFilter = NULL);
85 virtual void Destroy();
99 GENICAM_NAMESPACE::gcstring_vector
m_Names;
105 bool LoadFromBagInternal(
INodeMap *pNodeMap,
bool Verify , GENICAM_NAMESPACE::gcstring_vector *pErrorList = NULL);
106 int64_t StoreToBagInternal(
INodeMap *pNodeMap,
const int MaxNumPersistSkriptEntries = -1, GENICAM_NAMESPACE::gcstring_vector *pFeatureFilter = NULL);
112 #define GENAPI_PERSISTENCE_MAGIC "{05D8C294-F295-4dfb-9D01-096BD04049F4}" 115 #define GENAPI_PERSISTENCE_MAGIC_FEATUREBAGGER "{4709CB3C-7322-4460-84C3-DA11DDA09939}" 126 char FirstCharacter =
static_cast<char>(is.peek());
127 while( FirstCharacter ==
'#' )
129 is.ignore(1024,
'\n');
130 FirstCharacter =
static_cast<char>(is.peek());
135 #ifndef GENAPI_DONT_USE_DEFAULT_PERSISTENCE_FILE_FORMAT 149 const int BufferSize = 1024;
150 char Buffer[BufferSize] = {0};
153 is.getline(Buffer, BufferSize,
'\n');
161 throw RUNTIME_EXCEPTION(
"The stream is not a GenApi feature stream since it is missing the magic GUID in the first line");
163 throw RUNTIME_EXCEPTION(
"The stream has been created using the CFeatureBagger class thus must be restored using the CFeatureBagger class as well");
167 char Name[BufferSize] = {0};
171 is.getline(Name, BufferSize,
'\t');
181 FeatureBag.
m_Names.push_back(Name);
182 FeatureBag.
m_Values.push_back(Value);
200 os <<
"# " << FeatureBag.
m_Info <<
"\n";
206 GENICAM_NAMESPACE::gcstring_vector::const_iterator pName = FeatureBag.
m_Names.begin();
207 GENICAM_NAMESPACE::gcstring_vector::const_iterator pValue = FeatureBag.
m_Values.begin();
208 const GENICAM_NAMESPACE::gcstring_vector::const_iterator endNames = FeatureBag.
m_Names.end();
209 for( ; pName != endNames; ++pName, ++pValue )
213 os << Name <<
"\t" << Value <<
"\n";
218 #endif // #ifndef GENAPI_DONT_USE_DEFAULT_PERSISTENCE_FILE_FORMAT 260 size_t Bag(
INodeMap *pNodeMap,
bool handleDefaultNodeMap =
true,
bool handleUserSets =
false,
bool handleSequencerSets =
false,
const int MaxNumPersistSkriptEntries = -1);
269 bool UnBag(
INodeMap *pNodeMap,
bool Verify =
true, GENICAM_NAMESPACE::gcstring_vector *pErrorList = NULL);
278 virtual const CFeatureBag& at(
size_t uiIndex)
const;
279 virtual size_t size(
void)
const;
289 void DeleteAllBags(
void );
297 #ifndef GENAPI_DONT_USE_DEFAULT_PERSISTENCE_FILE_FORMAT 307 os <<
"# " << featureBagger.
m_Info <<
"\n";
311 for (it = featureBagger.
begin(); it != featureBagger.
end(); it++)
313 os <<
"[" << (*it).GetBagName() <<
"]\n";
331 const int BufferSize = 1024;
332 char Buffer[BufferSize] = { 0 };
333 is.getline(Buffer, BufferSize,
'\n');
336 bool boCFeatureBagFormatDetected =
false;
342 throw RUNTIME_EXCEPTION(
"The stream is not a GenApi feature stream since it is missing the magic GUID in the first line");
344 boCFeatureBagFormatDetected =
true;
347 std::stringstream currentBagData;
348 if (boCFeatureBagFormatDetected)
350 currentBagData << FirstLine;
359 CFeatureBag *pBag = boCFeatureBagFormatDetected ? &featureBagger.
AddBag(
"All") : NULL;
369 if (!line.
empty() && (line[0] ==
'['))
371 if (!currentBagData.str().empty())
375 currentBagData >> (*pBag);
377 currentBagData.str(
"");
378 currentBagData.clear();
384 if( !bagName.empty() )
386 pBag = &featureBagger.
AddBag(bagName);
391 currentBagData << line <<
"\n";
394 if (!currentBagData.str().empty() && pBag)
396 currentBagData >> (*pBag);
400 #endif // #ifndef GENAPI_DONT_USE_DEFAULT_PERSISTENCE_FILE_FORMAT 403 #endif //_GENICAM_PERSISTENCE_H #define GENICAM_INTERFACE
virtual const_iterator begin(void) const
Common types used in the public GenApi interface.
CFeatureBag & AddBag(const GENICAM_NAMESPACE::gcstring &bagName)
bool operator!=(const MyAlloc< T1 > &, const MyAlloc< T2 > &)
Bag holding streamable features of a nodetree.
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
std::istream & getline(std::istream &is, GENICAM_NAMESPACE::gcstring &str)
STL getline.
static size_t _npos(void)
virtual size_t find_first_of(const gcstring &str, size_t offset=0) const
virtual bool empty(void) const
std::istream & operator>>(std::istream &is, CFeatureBag &FeatureBag)
reads in persistent data from a stream
GENICAM_NAMESPACE::gcstring m_BagName
The name of the feature bag.
GENICAM_NAMESPACE::gcstring m_Info
String describing the node map.
bool operator==(const MyAlloc< T1 > &, const MyAlloc< T2 > &)
GENICAM_NAMESPACE::gcstring m_Info
String describing the node map.
virtual size_t find(char ch, size_t offset=0) const
virtual gcstring substr(size_t offset=0, size_t count=GCSTRING_NPOS) const
GENICAM_INTERFACE INodeMap
Interface to access the node map.
virtual const_iterator end(void) const
#define GENAPI_PERSISTENCE_MAGIC_FEATUREBAGGER
the magic GUID which indicates that the file is a GenApi stream file created by the CFeatureBagger cl...
#define RUNTIME_EXCEPTION
Fires a runtime exception, e.g. throw RUNTIME_EXCEPTION("buh!")
#define GENAPI_VERSION_MAJOR
GENICAM_NAMESPACE::gcstring_vector m_Names
GENICAM_NAMESPACE::gcstring_vector m_Values
virtual GENICAM_NAMESPACE::gcstring ToString()=0
Returns a string representation of the digit.
Encapsulates a GenApi pointer dealing with the dynamic_cast automatically.
std::istream & EatComments(std::istream &is)
Helper function ignoring lines starting with comment character '#'.
#define GENAPI_VERSION_SUBMINOR
Class use to bag features.
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IPersistScript
Basic interface to persist values to.
Definition of template CPointer.
virtual GENICAM_NAMESPACE::gcstring operator*()=0
Get string node value.
A string class which is a clone of std::string.
declspec's to be used for GenApi Windows dll
std::ostream & operator<<(std::ostream &os, const CFeatureBag &FeatureBag)
writes out persistent data to a stream
#define GENAPI_VERSION_MINOR
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IValue
Interface for value properties.
virtual void PersistFeature(IValue &item)=0
Stores a feature.
Lexical analyzer for CIntSwissKnife.
#define GENAPI_PERSISTENCE_MAGIC
the magic GUID which indicates that the file or buffer is a GenApi stream created by the CFeatureBag ...