Go to the documentation of this file.00001 #ifndef GramInfo_h
00002 #define GramInfo_h
00003
00004
00006 struct CGramInfo
00007 {
00009 MorphLanguageEnum m_Language;
00011 DWORD m_PartOfSpeechMask;
00013 QWORD m_Grammems;
00014
00015 CGramInfo () {
00016 m_PartOfSpeechMask = 0;
00017 m_Grammems = 0;;
00018 m_Language = morphUnknown;
00019
00020 };
00021 CGramInfo (MorphLanguageEnum Language, DWORD PartOfSpeechMask, QWORD Grammems)
00022 {
00023 m_PartOfSpeechMask = PartOfSpeechMask;
00024 m_Grammems = Grammems;
00025 m_Language = Language;
00026
00027 };
00028
00029
00030 bool EqualOrLess (const CGramInfo& X) const
00031 {
00032 return
00033 (X.m_Language == m_Language )
00034 && ( (m_PartOfSpeechMask & X.m_PartOfSpeechMask) > 0)
00035 && ( (m_Grammems & X.m_Grammems) == X.m_Grammems)
00036 ;
00037 };
00038
00039 bool operator == (const CGramInfo& X) const
00040 {
00041 return (m_PartOfSpeechMask == X.m_PartOfSpeechMask)
00042 && (X.m_Language == m_Language )
00043 && (m_Grammems == X.m_Grammems);
00044 };
00045
00046 bool operator < (const CGramInfo& X) const
00047 {
00048 if (m_Language != X.m_Language)
00049 return m_Language < X.m_Language;
00050
00051 if (m_PartOfSpeechMask != X.m_PartOfSpeechMask)
00052 return m_PartOfSpeechMask < X.m_PartOfSpeechMask;
00053
00054 return m_Grammems < X.m_Grammems;
00055 };
00056
00057 void AddGramInfo (const CGramInfo& X)
00058 {
00059 m_PartOfSpeechMask |= X.m_PartOfSpeechMask;
00060 m_Grammems |= X.m_Grammems;
00061 };
00062
00063 };
00064
00065 inline size_t get_size_in_bytes (const CGramInfo& i)
00066 {
00067 return 1
00068 + get_size_in_bytes(i.m_PartOfSpeechMask)
00069 + get_size_in_bytes(i.m_Grammems);
00070
00071 };
00072
00073 inline size_t save_to_bytes(const CGramInfo& i, BYTE* buf)
00074 {
00075 BYTE t = i.m_Language;
00076 buf += save_to_bytes(t, buf);
00077 buf += save_to_bytes(i.m_PartOfSpeechMask, buf);
00078 buf += save_to_bytes(i.m_Grammems, buf);
00079 return get_size_in_bytes(i);
00080 }
00081
00082 inline size_t restore_from_bytes(CGramInfo& i, const BYTE* buf)
00083 {
00084 BYTE t;
00085 buf += restore_from_bytes(t, buf);
00086 i.m_Language = (MorphLanguageEnum)t;
00087 buf += restore_from_bytes(i.m_PartOfSpeechMask, buf);
00088 buf += restore_from_bytes(i.m_Grammems, buf);
00089 return get_size_in_bytes(i);
00090 }
00091
00092
00093 struct CGramInfoAndGraphemUnitOffset
00094 {
00095 CGramInfo m_GramInfo;
00096 int m_UnitOffset;
00097 bool operator < (const CGramInfoAndGraphemUnitOffset& X) const
00098 {
00099 return m_UnitOffset< X.m_UnitOffset;
00100 };
00101 };
00102
00103 inline size_t get_size_in_bytes (const CGramInfoAndGraphemUnitOffset& i)
00104 {
00105 return get_size_in_bytes(i.m_GramInfo) + get_size_in_bytes(i.m_UnitOffset);
00106
00107 };
00108
00109 inline size_t save_to_bytes(const CGramInfoAndGraphemUnitOffset& i, BYTE* buf)
00110 {
00111 buf += save_to_bytes(i.m_GramInfo, buf);
00112 buf += save_to_bytes(i.m_UnitOffset, buf);
00113 return get_size_in_bytes(i);
00114 }
00115
00116 inline size_t restore_from_bytes(CGramInfoAndGraphemUnitOffset& i, const BYTE* buf)
00117 {
00118 buf += restore_from_bytes(i.m_GramInfo, buf);
00119 buf += restore_from_bytes(i.m_UnitOffset, buf);
00120 return get_size_in_bytes(i);
00121 }
00122
00123 #endif