00001 // ========== This file is under LGPL, the GNU Lesser General Public Licence 00002 // ========== Dialing Structural Dictionary (www.aot.ru) 00003 // ========== Copyright by Alexey Sokirko (1998-2002) 00004 00005 #ifndef ItemsContainer 00006 #define ItemsContainer 00007 00008 #include "../common/utilit.h" 00009 #include "Domen.h" 00010 #include "Field.h" 00011 #include "../common/cortege.h" 00012 #include "../common/bserialize.h" 00013 00014 00015 00016 00017 struct TDomNoItemStr { 00018 char ItemStr[100]; 00019 BYTE DomNo; 00020 }; 00021 00022 00023 struct TDomItem 00024 { 00025 DWORD m_Data; 00026 BYTE m_DomNo; 00027 00028 DWORD GetItemStrNo() const 00029 { 00030 return m_Data & ~(0xff<<24); 00031 }; 00032 void SetItemStrNo(DWORD Value) 00033 { 00034 m_Data &= (0xff<<24); 00035 m_Data |= Value; 00036 }; 00037 BYTE GetItemStrLen() const 00038 { 00039 return m_Data>>24; 00040 }; 00041 void SetItemStrLen(BYTE Value) 00042 { 00043 m_Data &= ~(0xff<<24); 00044 m_Data |= ((size_t)Value<<24); 00045 }; 00046 00047 BYTE GetDomNo() const 00048 { 00049 return m_DomNo; 00050 }; 00051 void SetDomNo(BYTE Value) 00052 { 00053 m_DomNo = Value; 00054 }; 00055 }; 00056 00057 00058 00059 00060 class TItemContainer 00061 { 00062 public : 00063 MorphLanguageEnum m_Language; 00064 char RossPath[_MAX_PATH]; 00065 vector<TDomItem> m_DomItems; 00066 char DomItemsFile[_MAX_PATH]; 00067 char DomItemsTextFile[_MAX_PATH]; 00068 char ItemsFile[_MAX_PATH]; 00069 vector <CDomen> m_Domens; 00070 char DomensFile[_MAX_PATH]; 00071 vector<CField> Fields; 00072 char FieldsFile[_MAX_PATH]; 00073 bool m_bDontLoadExamples; 00074 bool m_bRussianFields; 00075 map<string,string> m_Russian2EnglishFields; 00076 00077 00078 //константы доменов 00079 BYTE ActantsDomNo; 00080 BYTE LexDomNo; 00081 BYTE LexPlusDomNo; 00082 BYTE TitleDomNo; 00083 BYTE CollocDomNo; 00084 BYTE AbbrDomNo; 00085 BYTE FieldDomNo; 00086 BYTE EmptyDomNo; 00087 BYTE IllDomNo; 00088 BYTE IntegerDomNo; 00089 int WildCardDomItemNo; 00090 string m_LastError; 00091 00092 00093 TItemContainer(); 00094 00095 const char* GetDomItemStr(const TDomItem& Item) const 00096 { 00097 assert (!m_Domens[Item.GetDomNo()].m_bFreed); 00098 return m_Domens[Item.GetDomNo()].m_Items+Item.GetItemStrNo(); 00099 }; 00100 00101 void ErrorMessage (string s ) const; 00102 bool InitDomensConsts(); 00103 int GetItemNoByItemStr (const char* ItemStr, BYTE DomNo) const; 00104 int GetItemNoByItemStr (const char* ItemStr, const char* DomStr) const; 00105 BYTE GetDomenNoByDomStr (const char* DomStr) const; 00106 bool AreEqualDomItems(const TDomItem& Item1, const TDomNoItemStr& Item2) const; 00107 00108 void UpdateConstDomens(); 00109 bool BuildDomens (char* LastReadLine); 00110 bool BuildDomItems (); 00111 BYTE GetDomNoForLePlus ( const char* s) const; 00112 bool IsStandardRusLexeme (const char* s) const; 00113 00114 bool CanBeRusAbbr (const char* s) const; 00115 bool CanBeRusColloc (const char* s) const; 00116 BYTE GetFieldNoByFieldStrInner (const char* FieldStr) const; 00117 bool ClearFields (); 00118 bool BuildFields(BYTE MaxNumDom); 00119 bool WriteFields() const; 00120 bool BuildFormats(BYTE MaxNumDom); 00121 bool BuildOneFieldFormat (CSignat& Sgn, char* Frmt, char* Name, BYTE MaxNumDom); 00122 virtual bool UpdateSignatsOfTheFieldInCorteges (BYTE FieldNo, vector<CSignat>& Signats)= 0; 00123 bool WriteDomens () const; 00124 size_t GetDomItemsSize() const {return m_DomItems.size();}; 00125 bool WriteDomItems() const ; 00126 00127 00128 00129 }; 00130 00131 00132 00133 #endif