private void EncodeNormal(PERIntegerEffectiveConstraint cn, StreamWriterLevel c, string var, int lev) { if (!cn.m_rootRange.m_minIsInfinite && !cn.m_rootRange.m_maxIsInfinite) { c.P(lev); if (cn.m_rootRange.m_min == cn.m_rootRange.m_max) c.WriteLine("/* No need to encode value since it will always be {0}*/", cn.m_rootRange.m_min); else c.WriteLine("BitStream_EncodeConstraintWholeNumber(pBitStrm, {0}, {1}, {2});", var, C.L(cn.m_rootRange.m_min), C.L(cn.m_rootRange.m_max)); } else if (!cn.m_rootRange.m_minIsInfinite && cn.m_rootRange.m_maxIsInfinite) { c.P(lev); c.WriteLine("BitStream_EncodeSemiConstraintWholeNumber(pBitStrm, {0}, {1});", var, C.L(cn.m_rootRange.m_min)); } else { c.P(lev); c.WriteLine("BitStream_EncodeUnConstraintWholeNumber(pBitStrm, {0});", var); } }
private void DecodeNormal(PERIntegerEffectiveConstraint cn, StreamWriterLevel c, string var, int lev) { if (!cn.m_rootRange.m_minIsInfinite && !cn.m_rootRange.m_maxIsInfinite && (cn.m_rootRange.m_max == cn.m_rootRange.m_min)) { c.P(lev); c.WriteLine("{0} = {1};", var.Replace("&", ""), C.L(cn.m_rootRange.m_min)); } else { if (!cn.m_rootRange.m_minIsInfinite && !cn.m_rootRange.m_maxIsInfinite) { c.P(lev); c.WriteLine("if (!BitStream_DecodeConstraintWholeNumber(pBitStrm, {0}, {1}, {2})) {{", var, C.L(cn.m_rootRange.m_min), C.L(cn.m_rootRange.m_max)); } else if (!cn.m_rootRange.m_minIsInfinite && cn.m_rootRange.m_maxIsInfinite) { c.P(lev); c.WriteLine("if (!BitStream_DecodeSemiConstraintWholeNumber(pBitStrm, {0}, {1})) {{", var, C.L(cn.m_rootRange.m_min)); } else { c.P(lev); c.WriteLine("if (!BitStream_DecodeUnConstraintWholeNumber(pBitStrm, {0})) {{", var); } c.P(lev + 1); c.WriteLine("*pErrCode = ERR_INSUFFICIENT_DATA;"); c.P(lev + 1); c.WriteLine("return FALSE;"); c.P(lev); c.WriteLine("}"); } }
public PERSizeEffectiveConstraint() { m_size = PERIntegerEffectiveConstraint.UncostraintPosInteger; }
public PERSizeEffectiveConstraint(PERIntegerEffectiveConstraint size) { m_size = size; }
public static PERIntegerEffectiveConstraint Union(PERIntegerEffectiveConstraint a, PERIntegerEffectiveConstraint b) { PERIntegerEffectiveConstraint c = DefaultBackend.Instance.Factory.CreatePERIntegerEffectiveConstraint(); c.m_rootRange = IntegerRange.Union(a.m_rootRange, b.m_rootRange); c.m_isExtended = a.m_isExtended || b.m_isExtended; if (a.m_extRange!=null && b.m_extRange==null) c.m_extRange = a.m_extRange.Clone(); else if (a.m_extRange==null && b.m_extRange!=null) c.m_extRange = b.m_extRange.Clone(); else if (a.m_extRange != null && b.m_extRange != null) c.m_extRange = IntegerRange.Union(a.m_extRange, b.m_extRange); return c; }
public PERAlphabetAndSizeEffectiveConstraint(PERIntegerEffectiveConstraint size) { m_size = size; }