mootBinHeader.h
Go to the documentation of this file.
1 /* -*- Mode: C++ -*- */
2 
3 /*
4  libmoot : moocow's part-of-speech tagging library
5  Copyright (C) 2003-2011 by Bryan Jurish <moocow@cpan.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 3 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 
22 /*--------------------------------------------------------------------------
23  * File: mootBinHeader.h
24  * Author: Bryan Jurish <moocow@cpan.org>
25  * Description:
26  * + moot PoS tagger : abstract binary headers
27  *--------------------------------------------------------------------------*/
28 
33 #ifndef _MOOT_BINHEADER_H
34 #define _MOOT_BINHEADER_H
35 
36 namespace mootBinIO {
37 
38  /*------------------------------------------------------------
39  * public typedefs: Generic header information
40  */
42  class HeaderInfo {
43  public:
45  typedef BinUInt VersionT;
46 
48  typedef BinUInt MagicT;
49 
51  typedef BinULong FlagsT;
52 
53  public:
54  MagicT magic;
55  VersionT version;
56  VersionT revision;
57  VersionT minver;
58  VersionT minrev;
59  FlagsT flags;
61  public:
63  HeaderInfo(MagicT mag=0,
64  VersionT ver=0, VersionT rev=0,
65  VersionT mver=0, VersionT mrev=0,
66  FlagsT f=0)
67  : magic(mag),
68  version(ver),
69  revision(rev),
70  minver(mver),
71  minrev(mrev),
72  flags(f)
73  {};
74 
76  HeaderInfo(const string &IDstring,
77  VersionT ver=0, VersionT rev=0,
78  VersionT mver=0, VersionT mrev=0,
79  FlagsT f=0)
80  : version(ver),
81  revision(rev),
82  minver(mver),
83  minrev(mrev),
84  flags(f)
85  {
86  magic = 0;
87  for (string::const_iterator si = IDstring.begin(); si != IDstring.end(); si++) {
88  magic = (magic<<5)-magic + static_cast<MagicT>(*si);
89  }
90  };
91  };
92 
93 }; //-- mootBinIO
94 
95 
96 #endif /* _MOOT_BINHEADER_H */
VersionT version
Definition: mootBinHeader.h:56
MagicT magic
Definition: mootBinHeader.h:55
Namespace for structured binary stream I/O.
Definition: mootBinHeader.h:37
VersionT minrev
Definition: mootBinHeader.h:59
VersionT revision
Definition: mootBinHeader.h:57
BinULong FlagsT
Definition: mootBinHeader.h:52
uint32_t BinUInt
Definition: mootTypes.h:79
HeaderInfo(MagicT mag=0, VersionT ver=0, VersionT rev=0, VersionT mver=0, VersionT mrev=0, FlagsT f=0)
Definition: mootBinHeader.h:64
uint32_t BinULong
Definition: mootTypes.h:81
Header information structure, used for binary HMM model files.
Definition: mootBinHeader.h:43
FlagsT flags
Definition: mootBinHeader.h:60
BinUInt MagicT
Definition: mootBinHeader.h:49
BinUInt VersionT
Definition: mootBinHeader.h:46
VersionT minver
Definition: mootBinHeader.h:58