• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.12
  • kdelibs
  • kdecore
  • localization
  • probers
nsCodingStateMachine.h
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* -*- C++ -*-
3 * Copyright (C) 1998 <developer@mozilla.org>
4 *
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25 
26 #ifndef nsCodingStateMachine_h__
27 #define nsCodingStateMachine_h__
28 
29 #include "kencodingprober.h"
30 
31 #include "kdemacros.h"
32 
33 #include "nsPkgInt.h"
34 namespace kencodingprober {
35 typedef enum {
36  eStart = 0,
37  eError = 1,
38  eItsMe = 2
39 } nsSMState;
40 
41 #define GETCLASS(c) GETFROMPCK(((unsigned char)(c)), mModel->classTable)
42 
43 //state machine model
44 typedef struct
45 {
46  nsPkgInt classTable;
47  unsigned int classFactor;
48  nsPkgInt stateTable;
49  const unsigned int* charLenTable;
50  const char* name;
51 } SMModel;
52 
53 class KDE_NO_EXPORT nsCodingStateMachine {
54 public:
55  nsCodingStateMachine(SMModel* sm){
56  mCurrentState = eStart;
57  mModel = sm;
58  };
59  nsSMState NextState(char c){
60  //for each byte we get its class KDE_NO_EXPORT , if it is first byte, we also get byte length
61  unsigned int byteCls = GETCLASS(c);
62  if (mCurrentState == eStart)
63  {
64  mCurrentBytePos = 0;
65  mCurrentCharLen = mModel->charLenTable[byteCls];
66  }
67  //from byte's class KDE_NO_EXPORT and stateTable, we get its next state
68  mCurrentState=(nsSMState)GETFROMPCK(mCurrentState*(mModel->classFactor)+byteCls,
69  mModel->stateTable);
70  mCurrentBytePos++;
71  return mCurrentState;
72  };
73  unsigned int GetCurrentCharLen(void) {return mCurrentCharLen;};
74  void Reset(void) {mCurrentState = eStart;};
75  const char * GetCodingStateMachine() {return mModel->name;};
76 #ifdef DEBUG_PROBE
77  const char * DumpCurrentState(){
78  switch (mCurrentState) {
79  case eStart:
80  return "eStart";
81  case eError:
82  return "eError";
83  case eItsMe:
84  return "eItsMe";
85  default:
86  return "OK";
87  }
88  }
89 #endif
90 
91 protected:
92  nsSMState mCurrentState;
93  unsigned int mCurrentCharLen;
94  unsigned int mCurrentBytePos;
95 
96  SMModel *mModel;
97 };
98 
99 extern KDE_NO_EXPORT SMModel UTF8SMModel;
100 extern KDE_NO_EXPORT SMModel Big5SMModel;
101 extern KDE_NO_EXPORT SMModel EUCJPSMModel;
102 extern KDE_NO_EXPORT SMModel EUCKRSMModel;
103 extern KDE_NO_EXPORT SMModel EUCTWSMModel;
104 extern KDE_NO_EXPORT SMModel GB18030SMModel;
105 extern KDE_NO_EXPORT SMModel SJISSMModel;
106 extern KDE_NO_EXPORT SMModel UCS2LESMModel;
107 extern KDE_NO_EXPORT SMModel UCS2BESMModel;
108 
109 
110 extern KDE_NO_EXPORT SMModel HZSMModel;
111 extern KDE_NO_EXPORT SMModel ISO2022CNSMModel;
112 extern KDE_NO_EXPORT SMModel ISO2022JPSMModel;
113 extern KDE_NO_EXPORT SMModel ISO2022KRSMModel;
114 }
115 #endif /* nsCodingStateMachine_h__ */
116 
kencodingprober::nsCodingStateMachine::mCurrentCharLen
unsigned int mCurrentCharLen
Definition: nsCodingStateMachine.h:93
kencodingprober::SMModel
Definition: nsCodingStateMachine.h:44
kencodingprober::EUCKRSMModel
KDE_NO_EXPORT SMModel EUCKRSMModel
Definition: nsMBCSSM.cpp:189
kencodingprober::EUCJPSMModel
KDE_NO_EXPORT SMModel EUCJPSMModel
Definition: nsMBCSSM.cpp:137
kencodingprober::UCS2LESMModel
KDE_NO_EXPORT SMModel UCS2LESMModel
Definition: nsMBCSSM.cpp:531
kencodingprober::ISO2022KRSMModel
KDE_NO_EXPORT SMModel ISO2022KRSMModel
Definition: nsEscSM.cpp:246
kencodingprober::UCS2BESMModel
KDE_NO_EXPORT SMModel UCS2BESMModel
Definition: nsMBCSSM.cpp:475
KDE_NO_EXPORT
#define KDE_NO_EXPORT
The KDE_NO_EXPORT macro marks the symbol of the given variable to be hidden.
Definition: kdemacros.h.cmake:73
kencodingprober::SMModel::classTable
nsPkgInt classTable
Definition: nsCodingStateMachine.h:46
kencodingprober::nsCodingStateMachine::NextState
nsSMState NextState(char c)
Definition: nsCodingStateMachine.h:59
kencodingprober::HZSMModel
KDE_NO_EXPORT SMModel HZSMModel
Definition: nsEscSM.cpp:76
kencodingprober::nsCodingStateMachine::mModel
SMModel * mModel
Definition: nsCodingStateMachine.h:96
GETFROMPCK
#define GETFROMPCK(i, c)
Definition: nsPkgInt.h:73
kencodingprober::EUCTWSMModel
KDE_NO_EXPORT SMModel EUCTWSMModel
Definition: nsMBCSSM.cpp:245
kencodingprober::nsCodingStateMachine::nsCodingStateMachine
nsCodingStateMachine(SMModel *sm)
Definition: nsCodingStateMachine.h:55
kencodingprober::eError
Definition: nsCodingStateMachine.h:37
kencodingprober::nsCodingStateMachine::Reset
void Reset(void)
Definition: nsCodingStateMachine.h:74
kencodingprober.h
kencodingprober::ISO2022JPSMModel
KDE_NO_EXPORT SMModel ISO2022JPSMModel
Definition: nsEscSM.cpp:192
kencodingprober::nsCodingStateMachine::GetCurrentCharLen
unsigned int GetCurrentCharLen(void)
Definition: nsCodingStateMachine.h:73
GETCLASS
#define GETCLASS(c)
Definition: nsCodingStateMachine.h:41
kencodingprober::ISO2022CNSMModel
KDE_NO_EXPORT SMModel ISO2022CNSMModel
Definition: nsEscSM.cpp:134
kencodingprober::nsPkgInt
Definition: nsPkgInt.h:54
nsPkgInt.h
kencodingprober::nsCodingStateMachine::mCurrentBytePos
unsigned int mCurrentBytePos
Definition: nsCodingStateMachine.h:94
kencodingprober::Big5SMModel
KDE_NO_EXPORT SMModel Big5SMModel
Definition: nsMBCSSM.cpp:82
kencodingprober::nsCodingStateMachine
Definition: nsCodingStateMachine.h:53
kencodingprober::SMModel::stateTable
nsPkgInt stateTable
Definition: nsCodingStateMachine.h:48
kencodingprober::eItsMe
Definition: nsCodingStateMachine.h:38
kencodingprober::SJISSMModel
KDE_NO_EXPORT SMModel SJISSMModel
Definition: nsMBCSSM.cpp:418
kencodingprober::eStart
Definition: nsCodingStateMachine.h:36
kencodingprober::UTF8SMModel
KDE_NO_EXPORT SMModel UTF8SMModel
Definition: nsMBCSSM.cpp:609
kencodingprober::SMModel::classFactor
unsigned int classFactor
Definition: nsCodingStateMachine.h:47
kencodingprober::SMModel::charLenTable
const unsigned int * charLenTable
Definition: nsCodingStateMachine.h:49
kencodingprober::SMModel::name
const char * name
Definition: nsCodingStateMachine.h:50
kencodingprober::nsSMState
nsSMState
Definition: nsCodingStateMachine.h:35
kencodingprober::GB18030SMModel
KDE_NO_EXPORT SMModel GB18030SMModel
Definition: nsMBCSSM.cpp:361
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:47:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal