00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef NCL_NXSSETREADER_H
00021 #define NCL_NXSSETREADER_H
00022 #include <sstream>
00023 #include "ncl/nxstoken.h"
00024 #include "ncl/nxsblock.h"
00049 class NxsSetReader
00050 {
00051 static unsigned InterpretTokenAsIndices(NxsToken &t,
00052 const NxsLabelToIndicesMapper &,
00053 const char * setType,
00054 const char * cmd,
00055 NxsUnsignedSet * destination);
00056 static void AddRangeToSet(unsigned first, unsigned last, unsigned stride, NxsUnsignedSet * destination, const NxsUnsignedSet * taboo, NxsToken &t);
00057 public:
00058 static void ReadSetDefinition(NxsToken &t,
00059 const NxsLabelToIndicesMapper &,
00060 const char * setType,
00061 const char * cmd,
00062 NxsUnsignedSet * destination,
00063 const NxsUnsignedSet * taboo = NULL);
00064 static void WriteSetAsNexusValue(const NxsUnsignedSet &, std::ostream & out);
00065 static std::string GetSetAsNexusString(const NxsUnsignedSet &s)
00066 {
00067 std::stringstream os;
00068 NxsSetReader::WriteSetAsNexusValue(s, os);
00069
00070 return os.str();
00071 }
00072 static std::vector<unsigned> GetSetAsVector(const NxsUnsignedSet &s);
00073 enum NxsSetReaderEnum
00074 {
00075 generic = 1,
00076 charset,
00077 taxset
00078 };
00079
00080 NxsSetReader(NxsToken &t, unsigned maxValue, NxsUnsignedSet &iset, NxsBlock &nxsblk, unsigned type);
00081
00082 bool Run();
00083 void WriteAsNexusValue(std::ostream & out) const
00084 {
00085 WriteSetAsNexusValue(nxsset, out);
00086 }
00087 protected:
00088
00089 bool AddRange(unsigned first, unsigned last, unsigned modulus = 0);
00090
00091 private:
00092
00093 unsigned GetTokenValue();
00094
00095 NxsBlock █
00096 NxsToken &token;
00097 NxsUnsignedSet &nxsset;
00098 unsigned max;
00099 unsigned settype;
00100 };
00101
00102 typedef NxsSetReader SetReader;
00103
00104 #endif