text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/translate/v3/translation_service.proto

package com.google.cloud.translate.v3;

public interface TranslateTextResponseOrBuilder
    extends
    // @@protoc_insertion_point(interface_extends:google.cloud.translation.v3.TranslateTextResponse)
    com.google.protobuf.MessageOrBuilder {

  /**
   *
   *
   *

   * Text translation responses with no glossary applied.
   * This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation translations = 1;
   */
  java.util.List<com.google.cloud.translate.v3.Translation> getTranslationsList();
  /**
   *
   *
   *

   * Text translation responses with no glossary applied.
   * This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation translations = 1;
   */
  com.google.cloud.translate.v3.Translation getTranslations(int index);
  /**
   *
   *
   *

   * Text translation responses with no glossary applied.
   * This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation translations = 1;
   */
  int getTranslationsCount();
  /**
   *
   *
   *

   * Text translation responses with no glossary applied.
   * This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation translations = 1;
   */
  java.util.List<? extends com.google.cloud.translate.v3.TranslationOrBuilder>
      getTranslationsOrBuilderList();
  /**
   *
   *
   *

   * Text translation responses with no glossary applied.
   * This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation translations = 1;
   */
  com.google.cloud.translate.v3.TranslationOrBuilder getTranslationsOrBuilder(int index);

  /**
   *
   *
   *

   * Text translation responses if a glossary is provided in the request.
   * This can be the same as
   * [`translations`][google.cloud.translation.v3.TranslateTextResponse.translations]
   * if no terms apply. This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation glossary_translations = 3;
   */
  java.util.List<com.google.cloud.translate.v3.Translation> getGlossaryTranslationsList();
  /**
   *
   *
   *

   * Text translation responses if a glossary is provided in the request.
   * This can be the same as
   * [`translations`][google.cloud.translation.v3.TranslateTextResponse.translations]
   * if no terms apply. This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation glossary_translations = 3;
   */
  com.google.cloud.translate.v3.Translation getGlossaryTranslations(int index);
  /**
   *
   *
   *

   * Text translation responses if a glossary is provided in the request.
   * This can be the same as
   * [`translations`][google.cloud.translation.v3.TranslateTextResponse.translations]
   * if no terms apply. This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation glossary_translations = 3;
   */
  int getGlossaryTranslationsCount();
  /**
   *
   *
   *

   * Text translation responses if a glossary is provided in the request.
   * This can be the same as
   * [`translations`][google.cloud.translation.v3.TranslateTextResponse.translations]
   * if no terms apply. This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation glossary_translations = 3;
   */
  java.util.List<? extends com.google.cloud.translate.v3.TranslationOrBuilder>
      getGlossaryTranslationsOrBuilderList();
  /**
   *
   *
   *

   * Text translation responses if a glossary is provided in the request.
   * This can be the same as
   * [`translations`][google.cloud.translation.v3.TranslateTextResponse.translations]
   * if no terms apply. This field has the same length as
   * [`contents`][google.cloud.translation.v3.TranslateTextRequest.contents].
   *

   *
   * repeated .google.cloud.translation.v3.Translation glossary_translations = 3;
   */
  com.google.cloud.translate.v3.TranslationOrBuilder getGlossaryTranslationsOrBuilder(int index);
}

redpajama_set_name: RedPajamaGithub


text:
Another implementation of amqp client and server.

[![Build Status](https://travis-ci.org/akayunov/amqpsfw.svg?branch=master)](https://travis-ci.org/akayunov/amqpsfw)

[![Coverage Status](https://coveralls.io/repos/github/akayunov/amqpsfw/badge.svg?branch=master)](https://coveralls.io/github/akayunov/amqpsfw?branch=master)

python implementation of amqp server and client. See tests for usage example.


text:
package privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.dagger.context.config.product;

import dagger.Module;
import dagger.Provides;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.dagger.context.config.shoppingList.ShoppingListModule;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.framework.context.AppModule;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.logic.product.business.ProductService;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.logic.product.business.impl.ProductServiceImpl;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.logic.product.business.impl.converter.ProductConverterService;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.logic.product.business.impl.converter.impl.ProductConverterServiceImpl;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.logic.product.persistence.ProductItemDao;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.logic.product.persistence.impl.ProductItemDaoImpl;
import privacyfriendlyshoppinglist.secuso.org.privacyfriendlyshoppinglist.logic.shoppingList.business.ShoppingListService;

import javax.inject.Singleton;

/**
 * Description:
 * Author: Grebiel Jose Ifill Brito
 * Created: 17.05.16 creation date
 */
@Module(
        includes = {
                ShoppingListModule.class
        },
        injects = {
                ProductService.class,
                ProductItemDao.class,
                ProductConverterService.class,
        }
)
public class ProductModule implements AppModule
{
    @Provides
    @Singleton
    ProductItemDao provideProductItemDao()
    {
        return new ProductItemDaoImpl();
    }

    @Provides
    @Singleton
    ProductConverterService provideProductConverterService()
    {
        return new ProductConverterServiceImpl();
    }

    @Provides
    @Singleton
    ProductService provideProductService(
            ProductItemDao productItemDao,
            ProductConverterService converterService,
            ShoppingListService shoppingListService
    )
    {
        return new ProductServiceImpl(
                productItemDao,
                converterService,
                shoppingListService
        );
    }
}


text:
{-# LANGUAGE QuasiQuotes #-}
module Main where
import           Control.DeepSeq
import           Control.Parallel.Strategies
import           Criterion
import           Data.Type.Natural
import qualified Data.Vector.Sized           as V
import           Progression.Main
import           System.Environment

main :: IO ()
main = do
  name : rest <- getArgs
  v10 <- return $!! ((V.replicate [snat|10|] ()) `using` rdeepseq)
  v100 <- return $!! ((V.replicate [snat|100|] ()) `using` rdeepseq)
  v200 <- return $!! ((V.replicate [snat|200|] ()) `using` rdeepseq)
  withArgs (("-n"++name) : rest) $
    defaultMain $
    bgroup "bench" [ bgroup "reverse"
                     [ bench "10" $ nf V.reverse v10
                     , bench "100" $ nf V.reverse v100
                     , bench "1000" $ nf V.reverse v200
                     ]
                   , bgroup "intersperse"
                     [ bench "10" $ nf (V.intersperse ()) v10
                     , bench "100" $ nf (V.intersperse ()) v100
                     , bench "200" $ nf (V.intersperse ()) v200
                     ]
                   ]


text:
namespace System.Xml
{
    using System;
    using System.Text;
    using System.IO;
    using System.Diagnostics;
    using System.Collections;
    using System.Collections.Generic;
    using System.Xml.Schema;
    using System.Globalization;

    internal class XmlNodeReaderNavigator
    {
        private XmlNode _curNode;
        private XmlNode _elemNode;
        private XmlNode _logNode;
        private int _attrIndex;
        private int _logAttrIndex;

        //presave these 2 variables since they shouldn't change.
        private XmlNameTable _nameTable;
        private XmlDocument _doc;

        private int _nAttrInd; //used to identify virtual attributes of DocumentType node and XmlDeclaration node

        private const String strPublicID = "PUBLIC";
        private const String strSystemID = "SYSTEM";
        private const String strVersion = "version";
        private const String strStandalone = "standalone";
        private const String strEncoding = "encoding";

        //caching variables for perf reasons
        private int _nDeclarationAttrCount;
        private int _nDocTypeAttrCount;

        //variables for roll back the moves
        private int _nLogLevel;
        private int _nLogAttrInd;
        private bool _bLogOnAttrVal;
        private bool _bCreatedOnAttribute;

        internal struct VirtualAttribute
        {
            internal String name;
            internal String value;

            internal VirtualAttribute(String name, String value)
            {
                this.name = name;
                this.value = value;
            }
        };

        internal VirtualAttribute[] decNodeAttributes = {
                new VirtualAttribute( null, null ),
                new VirtualAttribute( null, null ),
                new VirtualAttribute( null, null )
            };

        internal VirtualAttribute[] docTypeNodeAttributes = {
                new VirtualAttribute( null, null ),
                new VirtualAttribute( null, null )
            };

        private bool _bOnAttrVal;

        public XmlNodeReaderNavigator(XmlNode node)
        {
            _curNode = node;
            _logNode = node;
            XmlNodeType nt = _curNode.NodeType;
            if (nt == XmlNodeType.Attribute)
            {
                _elemNode = null;
                _attrIndex = -1;
                _bCreatedOnAttribute = true;
            }
            else
            {
                _elemNode = node;
                _attrIndex = -1;
                _bCreatedOnAttribute = false;
            }
            //presave this for pref reason since it shouldn't change.
            if (nt == XmlNodeType.Document)
                _doc = (XmlDocument)_curNode;
            else
                _doc = node.OwnerDocument;
            _nameTable = _doc.NameTable;
            _nAttrInd = -1;
            //initialize the caching variables
            _nDeclarationAttrCount = -1;
            _nDocTypeAttrCount = -1;
            _bOnAttrVal = false;
            _bLogOnAttrVal = false;
        }

        public XmlNodeType NodeType
        {
            get
            {
                XmlNodeType nt = _curNode.NodeType;
                if (_nAttrInd != -1)
                {
                    Debug.Assert(nt == XmlNodeType.XmlDeclaration || nt == XmlNodeType.DocumentType);
                    if (_bOnAttrVal)
                        return XmlNodeType.Text;
                    else
                        return XmlNodeType.Attribute;
                }
                return nt;
            }
        }

        public String NamespaceURI
        {
            get { return _curNode.NamespaceURI; }
        }

        public String Name
        {
            get
            {
                if (_nAttrInd != -1)
                {
                    Debug.Assert(_curNode.NodeType == XmlNodeType.XmlDeclaration || _curNode.NodeType == XmlNodeType.DocumentType);
                    if (_bOnAttrVal)
                        return String.Empty; //Text node's name is String.Empty
                    else
                    {
                        Debug.Assert(_nAttrInd >= 0 && _nAttrInd < AttributeCount);
                        if (_curNode.NodeType == XmlNodeType.XmlDeclaration)
                            return decNodeAttributes[_nAttrInd].name;
                        else
                            return docTypeNodeAttributes[_nAttrInd].name;
                    }
                }
                if (IsLocalNameEmpty(_curNode.NodeType))
                    return String.Empty;
                return _curNode.Name;
            }
        }

        public String LocalName
        {
            get
            {
                if (_nAttrInd != -1)
                    //for the nodes in this case, their LocalName should be the same as their name
                    return Name;
                if (IsLocalNameEmpty(_curNode.NodeType))
                    return String.Empty;
                return _curNode.LocalName;
            }
        }

        internal bool IsOnAttrVal
        {
            get
            {
                return _bOnAttrVal;
            }
        }

        internal XmlNode OwnerElementNode
        {
            get
            {
                if (_bCreatedOnAttribute)
                    return null;
                return _elemNode;
            }
        }

        internal bool CreatedOnAttribute
        {
            get
            {
                return _bCreatedOnAttribute;
            }
        }

        private bool IsLocalNameEmpty(XmlNodeType nt)
        {
            switch (nt)
            {
                case XmlNodeType.None:
                case XmlNodeType.Text:
                case XmlNodeType.CDATA:
                case XmlNodeType.Comment:
                case XmlNodeType.Document:
                case XmlNodeType.DocumentFragment:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                case XmlNodeType.EndElement:
                case XmlNodeType.EndEntity:
                    return true;
                case XmlNodeType.Element:
                case XmlNodeType.Attribute:
                case XmlNodeType.EntityReference:
                case XmlNodeType.Entity:
                case XmlNodeType.ProcessingInstruction:
                case XmlNodeType.DocumentType:
                case XmlNodeType.Notation:
                case XmlNodeType.XmlDeclaration:
                    return false;
                default:
                    return true;
            }
        }

        public String Prefix
        {
            get { return _curNode.Prefix; }
        }

        public bool HasValue
        {
            //In DOM, DocumentType node and XmlDeclaration node doesn't value
            //In XPathNavigator, XmlDeclaration node's value is its InnerText; DocumentType doesn't have value
            //In XmlReader, DocumentType node's value is its InternalSubset which is never null ( at least String.Empty )
            get
            {
                if (_nAttrInd != -1)
                {
                    //Pointing at the one of virtual attributes of Declaration or DocumentType nodes
                    Debug.Assert(_curNode.NodeType == XmlNodeType.XmlDeclaration || _curNode.NodeType == XmlNodeType.DocumentType);
                    Debug.Assert(_nAttrInd >= 0 && _nAttrInd < AttributeCount);
                    return true;
                }
                if (_curNode.Value != null || _curNode.NodeType == XmlNodeType.DocumentType)
                    return true;
                return false;
            }
        }

        public String Value
        {
            //See comments in HasValue
            get
            {
                String retValue = null;
                XmlNodeType nt = _curNode.NodeType;
                if (_nAttrInd != -1)
                {
                    //Pointing at the one of virtual attributes of Declaration or DocumentType nodes
                    Debug.Assert(nt == XmlNodeType.XmlDeclaration || nt == XmlNodeType.DocumentType);
                    Debug.Assert(_nAttrInd >= 0 && _nAttrInd < AttributeCount);
                    if (_curNode.NodeType == XmlNodeType.XmlDeclaration)
                        return decNodeAttributes[_nAttrInd].value;
                    else
                        return docTypeNodeAttributes[_nAttrInd].value;
                }
                if (nt == XmlNodeType.DocumentType)
                    retValue = ((XmlDocumentType)_curNode).InternalSubset; //in this case nav.Value will be null
                else if (nt == XmlNodeType.XmlDeclaration)
                {
                    StringBuilder strb = new StringBuilder(String.Empty);
                    if (_nDeclarationAttrCount == -1)
                        InitDecAttr();
                    for (int i = 0; i < _nDeclarationAttrCount; i++)
                    {
                        strb.Append(decNodeAttributes[i].name + "=\"" + decNodeAttributes[i].value + "\"");
                        if (i != (_nDeclarationAttrCount - 1))
                            strb.Append(" ");
                    }
                    retValue = strb.ToString();
                }
                else
                    retValue = _curNode.Value;
                return (retValue == null) ? String.Empty : retValue;
            }
        }

        public String BaseURI
        {
            get { return _curNode.BaseURI; }
        }

        public XmlSpace XmlSpace
        {
            get { return _curNode.XmlSpace; }
        }

        public String XmlLang
        {
            get { return _curNode.XmlLang; }
        }

        public bool IsEmptyElement
        {
            get
            {
                if (_curNode.NodeType == XmlNodeType.Element)
                {
                    return ((XmlElement)_curNode).IsEmpty;
                }
                return false;
            }
        }

        public bool IsDefault
        {
            get
            {
                if (_curNode.NodeType == XmlNodeType.Attribute)
                {
                    return !((XmlAttribute)_curNode).Specified;
                }
                return false;
            }
        }

        public IXmlSchemaInfo SchemaInfo
        {
            get
            {
                return _curNode.SchemaInfo;
            }
        }

        public XmlNameTable NameTable
        {
            get { return _nameTable; }
        }

        public int AttributeCount
        {
            get
            {
                if (_bCreatedOnAttribute)
                    return 0;
                XmlNodeType nt = _curNode.NodeType;
                if (nt == XmlNodeType.Element)
                    return ((XmlElement)_curNode).Attributes.Count;
                else if (nt == XmlNodeType.Attribute
                        || (_bOnAttrVal && nt != XmlNodeType.XmlDeclaration && nt != XmlNodeType.DocumentType))
                    return _elemNode.Attributes.Count;
                else if (nt == XmlNodeType.XmlDeclaration)
                {
                    if (_nDeclarationAttrCount != -1)
                        return _nDeclarationAttrCount;
                    InitDecAttr();
                    return _nDeclarationAttrCount;
                }
                else if (nt == XmlNodeType.DocumentType)
                {
                    if (_nDocTypeAttrCount != -1)
                        return _nDocTypeAttrCount;
                    InitDocTypeAttr();
                    return _nDocTypeAttrCount;
                }
                return 0;
            }
        }

        private void CheckIndexCondition(int attributeIndex)
        {
            if (attributeIndex < 0 || attributeIndex >= AttributeCount)
            {
                throw new ArgumentOutOfRangeException(nameof(attributeIndex));
            }
        }

        //8 functions below are the helper functions to deal with virtual attributes of XmlDeclaration nodes and DocumentType nodes.
        private void InitDecAttr()
        {
            int i = 0;
            String strTemp = _doc.Version;
            if (strTemp != null && strTemp.Length != 0)
            {
                decNodeAttributes[i].name = strVersion;
                decNodeAttributes[i].value = strTemp;
                i++;
            }
            strTemp = _doc.Encoding;
            if (strTemp != null && strTemp.Length != 0)
            {
                decNodeAttributes[i].name = strEncoding;
                decNodeAttributes[i].value = strTemp;
                i++;
            }
            strTemp = _doc.Standalone;
            if (strTemp != null && strTemp.Length != 0)
            {
                decNodeAttributes[i].name = strStandalone;
                decNodeAttributes[i].value = strTemp;
                i++;
            }
            _nDeclarationAttrCount = i;
        }

        public String GetDeclarationAttr(XmlDeclaration decl, String name)
        {
            //PreCondition: curNode is pointing at Declaration node or one of its virtual attributes
            if (name == strVersion)
                return decl.Version;
            if (name == strEncoding)
                return decl.Encoding;
            if (name == strStandalone)
                return decl.Standalone;
            return null;
        }

        public String GetDeclarationAttr(int i)
        {
            if (_nDeclarationAttrCount == -1)
                InitDecAttr();
            return decNodeAttributes[i].value;
        }

        public int GetDecAttrInd(String name)
        {
            if (_nDeclarationAttrCount == -1)
                InitDecAttr();
            for (int i = 0; i < _nDeclarationAttrCount; i++)
            {
                if (decNodeAttributes[i].name == name)
                    return i;
            }
            return -1;
        }

        private void InitDocTypeAttr()
        {
            int i = 0;
            XmlDocumentType docType = _doc.DocumentType;
            if (docType == null)
            {
                _nDocTypeAttrCount = 0;
                return;
            }
            String strTemp = docType.PublicId;
            if (strTemp != null)
            {
                docTypeNodeAttributes[i].name = strPublicID;
                docTypeNodeAttributes[i].value = strTemp;
                i++;
            }
            strTemp = docType.SystemId;
            if (strTemp != null)
            {
                docTypeNodeAttributes[i].name = strSystemID;
                docTypeNodeAttributes[i].value = strTemp;
                i++;
            }
            _nDocTypeAttrCount = i;
        }

        public String GetDocumentTypeAttr(XmlDocumentType docType, String name)
        {
            //PreCondition: nav is pointing at DocumentType node or one of its virtual attributes
            if (name == strPublicID)
                return docType.PublicId;
            if (name == strSystemID)
                return docType.SystemId;
            return null;
        }

        public String GetDocumentTypeAttr(int i)
        {
            if (_nDocTypeAttrCount == -1)
                InitDocTypeAttr();
            return docTypeNodeAttributes[i].value;
        }

        public int GetDocTypeAttrInd(String name)
        {
            if (_nDocTypeAttrCount == -1)
                InitDocTypeAttr();
            for (int i = 0; i < _nDocTypeAttrCount; i++)
            {
                if (docTypeNodeAttributes[i].name == name)
                    return i;
            }
            return -1;
        }

        private String GetAttributeFromElement(XmlElement elem, String name)
        {
            XmlAttribute attr = elem.GetAttributeNode(name);
            if (attr != null)
                return attr.Value;
            return null;
        }

        public String GetAttribute(String name)
        {
            if (_bCreatedOnAttribute)
                return null;
            switch (_curNode.NodeType)
            {
                case XmlNodeType.Element:
                    return GetAttributeFromElement((XmlElement)_curNode, name);
                case XmlNodeType.Attribute:
                    return GetAttributeFromElement((XmlElement)_elemNode, name);
                case XmlNodeType.XmlDeclaration:
                    return GetDeclarationAttr((XmlDeclaration)_curNode, name);
                case XmlNodeType.DocumentType:
                    return GetDocumentTypeAttr((XmlDocumentType)_curNode, name);
            }
            return null;
        }

        private String GetAttributeFromElement(XmlElement elem, String name, String ns)
        {
            XmlAttribute attr = elem.GetAttributeNode(name, ns);
            if (attr != null)
                return attr.Value;
            return null;
        }
        public String GetAttribute(String name, String ns)
        {
            if (_bCreatedOnAttribute)
                return null;
            switch (_curNode.NodeType)
            {
                case XmlNodeType.Element:
                    return GetAttributeFromElement((XmlElement)_curNode, name, ns);
                case XmlNodeType.Attribute:
                    return GetAttributeFromElement((XmlElement)_elemNode, name, ns);
                case XmlNodeType.XmlDeclaration:
                    return (ns.Length == 0) ? GetDeclarationAttr((XmlDeclaration)_curNode, name) : null;
                case XmlNodeType.DocumentType:
                    return (ns.Length == 0) ? GetDocumentTypeAttr((XmlDocumentType)_curNode, name) : null;
            }
            return null;
        }

        public String GetAttribute(int attributeIndex)
        {
            if (_bCreatedOnAttribute)
                return null;
            switch (_curNode.NodeType)
            {
                case XmlNodeType.Element:
                    CheckIndexCondition(attributeIndex);
                    return ((XmlElement)_curNode).Attributes[attributeIndex].Value;
                case XmlNodeType.Attribute:
                    CheckIndexCondition(attributeIndex);
                    return ((XmlElement)_elemNode).Attributes[attributeIndex].Value;
                case XmlNodeType.XmlDeclaration:
                    {
                        CheckIndexCondition(attributeIndex);
                        return GetDeclarationAttr(attributeIndex);
                    }
                case XmlNodeType.DocumentType:
                    {
                        CheckIndexCondition(attributeIndex);
                        return GetDocumentTypeAttr(attributeIndex);
                    }
            }
            throw new ArgumentOutOfRangeException(nameof(attributeIndex)); //for other senario, AttributeCount is 0, i has to be out of range
        }

        public void LogMove(int level)
        {
            _logNode = _curNode;
            _nLogLevel = level;
            _nLogAttrInd = _nAttrInd;
            _logAttrIndex = _attrIndex;
            _bLogOnAttrVal = _bOnAttrVal;
        }

        //The function has to be used in pair with ResetMove when the operation fails after LogMove() is
        //    called because it relies on the values of nOrigLevel, logNav and nOrigAttrInd to be acurate.
        public void RollBackMove(ref int level)
        {
            _curNode = _logNode;
            level = _nLogLevel;
            _nAttrInd = _nLogAttrInd;
            _attrIndex = _logAttrIndex;
            _bOnAttrVal = _bLogOnAttrVal;
        }

        private bool IsOnDeclOrDocType
        {
            get
            {
                XmlNodeType nt = _curNode.NodeType;
                return (nt == XmlNodeType.XmlDeclaration || nt == XmlNodeType.DocumentType);
            }
        }

        public void ResetToAttribute(ref int level)
        {
            //the current cursor is pointing at one of the attribute children -- this could be caused by
            //  the calls to ReadAttributeValue(..)
            if (_bCreatedOnAttribute)
                return;
            if (_bOnAttrVal)
            {
                if (IsOnDeclOrDocType)
                {
                    level -= 2;
                }
                else
                {
                    while (_curNode.NodeType != XmlNodeType.Attribute && ((_curNode = _curNode.ParentNode) != null))
                        level--;
                }
                _bOnAttrVal = false;
            }
        }

        public void ResetMove(ref int level, ref XmlNodeType nt)
        {
            LogMove(level);
            if (_bCreatedOnAttribute)
                return;
            if (_nAttrInd != -1)
            {
                Debug.Assert(IsOnDeclOrDocType);
                if (_bOnAttrVal)
                {
                    level--;
                    _bOnAttrVal = false;
                }
                _nLogAttrInd = _nAttrInd;
                level--;
                _nAttrInd = -1;
                nt = _curNode.NodeType;
                return;
            }
            if (_bOnAttrVal && _curNode.NodeType != XmlNodeType.Attribute)
                ResetToAttribute(ref level);
            if (_curNode.NodeType == XmlNodeType.Attribute)
            {
                _curNode = ((XmlAttribute)_curNode).OwnerElement;
                _attrIndex = -1;
                level--;
                nt = XmlNodeType.Element;
            }
            if (_curNode.NodeType == XmlNodeType.Element)
                _elemNode = _curNode;
        }

        public bool MoveToAttribute(string name)
        {
            return MoveToAttribute(name, string.Empty);
        }
        private bool MoveToAttributeFromElement(XmlElement elem, String name, String ns)
        {
            XmlAttribute attr = null;
            if (ns.Length == 0)
                attr = elem.GetAttributeNode(name);
            else
                attr = elem.GetAttributeNode(name, ns);
            if (attr != null)
            {
                _bOnAttrVal = false;
                _elemNode = elem;
                _curNode = attr;
                _attrIndex = elem.Attributes.FindNodeOffsetNS(attr);
                if (_attrIndex != -1)
                {
                    return true;
                }
            }
            return false;
        }

        public bool MoveToAttribute(string name, string namespaceURI)
        {
            if (_bCreatedOnAttribute)
                return false;
            XmlNodeType nt = _curNode.NodeType;
            if (nt == XmlNodeType.Element)
                return MoveToAttributeFromElement((XmlElement)_curNode, name, namespaceURI);
            else if (nt == XmlNodeType.Attribute)
                return MoveToAttributeFromElement((XmlElement)_elemNode, name, namespaceURI);
            else if (nt == XmlNodeType.XmlDeclaration && namespaceURI.Length == 0)
            {
                if ((_nAttrInd = GetDecAttrInd(name)) != -1)
                {
                    _bOnAttrVal = false;
                    return true;
                }
            }
            else if (nt == XmlNodeType.DocumentType && namespaceURI.Length == 0)
            {
                if ((_nAttrInd = GetDocTypeAttrInd(name)) != -1)
                {
                    _bOnAttrVal = false;
                    return true;
                }
            }
            return false;
        }

        public void MoveToAttribute(int attributeIndex)
        {
            if (_bCreatedOnAttribute)
                return;
            XmlAttribute attr = null;
            switch (_curNode.NodeType)
            {
                case XmlNodeType.Element:
                    CheckIndexCondition(attributeIndex);
                    attr = ((XmlElement)_curNode).Attributes[attributeIndex];
                    if (attr != null)
                    {
                        _elemNode = _curNode;
                        _curNode = (XmlNode)attr;
                        _attrIndex = attributeIndex;
                    }
                    break;
                case XmlNodeType.Attribute:
                    CheckIndexCondition(attributeIndex);
                    attr = ((XmlElement)_elemNode).Attributes[attributeIndex];
                    if (attr != null)
                    {
                        _curNode = (XmlNode)attr;
                        _attrIndex = attributeIndex;
                    }
                    break;
                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.DocumentType:
                    CheckIndexCondition(attributeIndex);
                    _nAttrInd = attributeIndex;
                    break;
            }
        }

        public bool MoveToNextAttribute(ref int level)
        {
            if (_bCreatedOnAttribute)
                return false;
            XmlNodeType nt = _curNode.NodeType;
            if (nt == XmlNodeType.Attribute)
            {
                if (_attrIndex >= (_elemNode.Attributes.Count - 1))
                    return false;
                else
                {
                    _curNode = _elemNode.Attributes[++_attrIndex];
                    return true;
                }
            }
            else if (nt == XmlNodeType.Element)
            {
                if (_curNode.Attributes.Count > 0)
                {
                    level++;
                    _elemNode = _curNode;
                    _curNode = _curNode.Attributes[0];
                    _attrIndex = 0;
                    return true;
                }
            }
            else if (nt == XmlNodeType.XmlDeclaration)
            {
                if (_nDeclarationAttrCount == -1)
                    InitDecAttr();
                _nAttrInd++;
                if (_nAttrInd < _nDeclarationAttrCount)
                {
                    if (_nAttrInd == 0) level++;
                    _bOnAttrVal = false;
                    return true;
                }
                _nAttrInd--;
            }
            else if (nt == XmlNodeType.DocumentType)
            {
                if (_nDocTypeAttrCount == -1)
                    InitDocTypeAttr();
                _nAttrInd++;
                if (_nAttrInd < _nDocTypeAttrCount)
                {
                    if (_nAttrInd == 0) level++;
                    _bOnAttrVal = false;
                    return true;
                }
                _nAttrInd--;
            }
            return false;
        }

        public bool MoveToParent()
        {
            XmlNode parent = _curNode.ParentNode;
            if (parent != null)
            {
                _curNode = parent;
                if (!_bOnAttrVal)
                    _attrIndex = 0;
                return true;
            }
            return false;
        }

        public bool MoveToFirstChild()
        {
            XmlNode firstChild = _curNode.FirstChild;
            if (firstChild != null)
            {
                _curNode = firstChild;
                if (!_bOnAttrVal)
                    _attrIndex = -1;
                return true;
            }
            return false;
        }

        private bool MoveToNextSibling(XmlNode node)
        {
            XmlNode nextSibling = node.NextSibling;
            if (nextSibling != null)
            {
                _curNode = nextSibling;
                if (!_bOnAttrVal)
                    _attrIndex = -1;
                return true;
            }
            return false;
        }

        public bool MoveToNext()
        {
            if (_curNode.NodeType != XmlNodeType.Attribute)
                return MoveToNextSibling(_curNode);
            else
                return MoveToNextSibling(_elemNode);
        }

        public bool MoveToElement()
        {
            if (_bCreatedOnAttribute)
                return false;
            switch (_curNode.NodeType)
            {
                case XmlNodeType.Attribute:
                    if (_elemNode != null)
                    {
                        _curNode = _elemNode;
                        _attrIndex = -1;
                        return true;
                    }
                    break;
                case XmlNodeType.XmlDeclaration:
                case XmlNodeType.DocumentType:
                    {
                        if (_nAttrInd != -1)
                        {
                            _nAttrInd = -1;
                            return true;
                        }
                        break;
                    }
            }
            return false;
        }

        public String LookupNamespace(string prefix)
        {
            if (_bCreatedOnAttribute)
                return null;
            if (prefix == "xmlns")
            {
                return _nameTable.Add(XmlReservedNs.NsXmlNs);
            }
            if (prefix == "xml")
            {
                return _nameTable.Add(XmlReservedNs.NsXml);
            }

            // construct the name of the xmlns attribute
            string attrName;
            if (prefix == null)
                prefix = string.Empty;
            if (prefix.Length == 0)
                attrName = "xmlns";
            else
                attrName = "xmlns:" + prefix;

            // walk up the XmlNode parent chain, looking for the xmlns attribute
            XmlNode node = _curNode;
            while (node != null)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    XmlElement elem = (XmlElement)node;
                    if (elem.HasAttributes)
                    {
                        XmlAttribute attr = elem.GetAttributeNode(attrName);
                        if (attr != null)
                        {
                            return attr.Value;
                        }
                    }
                }
                else if (node.NodeType == XmlNodeType.Attribute)
                {
                    node = ((XmlAttribute)node).OwnerElement;
                    continue;
                }
                node = node.ParentNode;
            }
            if (prefix.Length == 0)
            {
                return string.Empty;
            }
            return null;
        }

        internal string DefaultLookupNamespace(string prefix)
        {
            if (!_bCreatedOnAttribute)
            {
                if (prefix == "xmlns")
                {
                    return _nameTable.Add(XmlReservedNs.NsXmlNs);
                }
                if (prefix == "xml")
                {
                    return _nameTable.Add(XmlReservedNs.NsXml);
                }
                if (prefix == string.Empty)
                {
                    return _nameTable.Add(string.Empty);
                }
            }
            return null;
        }

        internal String LookupPrefix(string namespaceName)
        {
            if (_bCreatedOnAttribute || namespaceName == null)
            {
                return null;
            }
            if (namespaceName == XmlReservedNs.NsXmlNs)
            {
                return _nameTable.Add("xmlns");
            }
            if (namespaceName == XmlReservedNs.NsXml)
            {
                return _nameTable.Add("xml");
            }
            if (namespaceName == string.Empty)
            {
                return string.Empty;
            }
            // walk up the XmlNode parent chain, looking for the xmlns attribute with namespaceName value
            XmlNode node = _curNode;
            while (node != null)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    XmlElement elem = (XmlElement)node;
                    if (elem.HasAttributes)
                    {
                        XmlAttributeCollection attrs = elem.Attributes;
                        for (int i = 0; i < attrs.Count; i++)
                        {
                            XmlAttribute a = attrs[i];
                            if (a.Value == namespaceName)
                            {
                                if (a.Prefix.Length == 0 && a.LocalName == "xmlns")
                                {
                                    if (LookupNamespace(string.Empty) == namespaceName)
                                    {
                                        return string.Empty;
                                    }
                                }
                                else if (a.Prefix == "xmlns")
                                {
                                    string pref = a.LocalName;
                                    if (LookupNamespace(pref) == namespaceName)
                                    {
                                        return _nameTable.Add(pref);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (node.NodeType == XmlNodeType.Attribute)
                {
                    node = ((XmlAttribute)node).OwnerElement;
                    continue;
                }
                node = node.ParentNode;
            }
            return null;
        }

        internal IDictionary<string, string> GetNamespacesInScope(XmlNamespaceScope scope)
        {
            Dictionary<string, string> dict = new Dictionary<string, string>();
            if (_bCreatedOnAttribute)
                return dict;

            // walk up the XmlNode parent chain and add all namespace declarations to the dictionary
            XmlNode node = _curNode;
            while (node != null)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    XmlElement elem = (XmlElement)node;
                    if (elem.HasAttributes)
                    {
                        XmlAttributeCollection attrs = elem.Attributes;
                        for (int i = 0; i < attrs.Count; i++)
                        {
                            XmlAttribute a = attrs[i];
                            if (a.LocalName == "xmlns" && a.Prefix.Length == 0)
                            {
                                if (!dict.ContainsKey(string.Empty))
                                {
                                    dict.Add(_nameTable.Add(string.Empty), _nameTable.Add(a.Value));
                                }
                            }
                            else if (a.Prefix == "xmlns")
                            {
                                string localName = a.LocalName;
                                if (!dict.ContainsKey(localName))
                                {
                                    dict.Add(_nameTable.Add(localName), _nameTable.Add(a.Value));
                                }
                            }
                        }
                    }
                    if (scope == XmlNamespaceScope.Local)
                    {
                        break;
                    }
                }
                else if (node.NodeType == XmlNodeType.Attribute)
                {
                    node = ((XmlAttribute)node).OwnerElement;
                    continue;
                }
                node = node.ParentNode;
            };

            if (scope != XmlNamespaceScope.Local)
            {
                if (dict.ContainsKey(string.Empty) && dict[string.Empty] == string.Empty)
                {
                    dict.Remove(string.Empty);
                }
                if (scope == XmlNamespaceScope.All)
                {
                    dict.Add(_nameTable.Add("xml"), _nameTable.Add(XmlReservedNs.NsXml));
                }
            }
            return dict;
        }

        public bool ReadAttributeValue(ref int level, ref bool bResolveEntity, ref XmlNodeType nt)
        {
            if (_nAttrInd != -1)
            {
                Debug.Assert(_curNode.NodeType == XmlNodeType.XmlDeclaration || _curNode.NodeType == XmlNodeType.DocumentType);
                if (!_bOnAttrVal)
                {
                    _bOnAttrVal = true;
                    level++;
                    nt = XmlNodeType.Text;
                    return true;
                }
                return false;
            }
            if (_curNode.NodeType == XmlNodeType.Attribute)
            {
                XmlNode firstChild = _curNode.FirstChild;
                if (firstChild != null)
                {
                    _curNode = firstChild;
                    nt = _curNode.NodeType;
                    level++;
                    _bOnAttrVal = true;
                    return true;
                }
            }
            else if (_bOnAttrVal)
            {
                XmlNode nextSibling = null;
                if (_curNode.NodeType == XmlNodeType.EntityReference && bResolveEntity)
                {
                    //going down to ent ref node
                    _curNode = _curNode.FirstChild;
                    nt = _curNode.NodeType;
                    Debug.Assert(_curNode != null);
                    level++;
                    bResolveEntity = false;
                    return true;
                }
                else
                    nextSibling = _curNode.NextSibling;
                if (nextSibling == null)
                {
                    XmlNode parentNode = _curNode.ParentNode;
                    //Check if its parent is entity ref node is sufficient, because in this senario, ent ref node can't have more than 1 level of children that are not other ent ref nodes
                    if (parentNode != null && parentNode.NodeType == XmlNodeType.EntityReference)
                    {
                        //come back from ent ref node
                        _curNode = parentNode;
                        nt = XmlNodeType.EndEntity;
                        level--;
                        return true;
                    }
                }
                if (nextSibling != null)
                {
                    _curNode = nextSibling;
                    nt = _curNode.NodeType;
                    return true;
                }
                else
                    return false;
            }
            return false;
        }

        public XmlDocument Document
        {
            get
            {
                return _doc;
            }
        }
    }

    // Represents a reader that provides fast, non-cached forward only stream access
    // to XML data in an XmlDocument or a specific XmlNode within an XmlDocument.
    public class XmlNodeReader : XmlReader, IXmlNamespaceResolver
    {
        private XmlNodeReaderNavigator _readerNav;

        private XmlNodeType _nodeType;   // nodeType of the node that the reader is currently positioned on
        private int _curDepth;   // depth of attrNav ( also functions as reader's depth )
        private ReadState _readState;  // current reader's state
        private bool _fEOF;       // flag to show if reaches the end of file
        //mark to the state that EntityReference node is supposed to be resolved
        private bool _bResolveEntity;
        private bool _bStartFromDocument;

        private bool _bInReadBinary;
        private ReadContentAsBinaryHelper _readBinaryHelper;

        // Creates an instance of the XmlNodeReader class using the specified XmlNode.
        public XmlNodeReader(XmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }
            _readerNav = new XmlNodeReaderNavigator(node);
            _curDepth = 0;

            _readState = ReadState.Initial;
            _fEOF = false;
            _nodeType = XmlNodeType.None;
            _bResolveEntity = false;
            _bStartFromDocument = false;
        }

        //function returns if the reader currently in valid reading states
        internal bool IsInReadingStates()
        {
            return (_readState == ReadState.Interactive); // || readState == ReadState.EndOfFile
        }

        //
        // Node Properties
        //

        // Gets the type of the current node.
        public override XmlNodeType NodeType
        {
            get { return (IsInReadingStates()) ? _nodeType : XmlNodeType.None; }
        }

        // Gets the name of
        // the current node, including the namespace prefix.
        public override string Name
        {
            get
            {
                if (!IsInReadingStates())
                    return String.Empty;
                return _readerNav.Name;
            }
        }

        // Gets the name of the current node without the namespace prefix.
        public override string LocalName
        {
            get
            {
                if (!IsInReadingStates())
                    return String.Empty;
                return _readerNav.LocalName;
            }
        }

        // Gets the namespace URN (as defined in the W3C Namespace Specification)
        // of the current namespace scope.
        public override string NamespaceURI
        {
            get
            {
                if (!IsInReadingStates())
                    return String.Empty;
                return _readerNav.NamespaceURI;
            }
        }

        // Gets the namespace prefix associated with the current node.
        public override string Prefix
        {
            get
            {
                if (!IsInReadingStates())
                    return String.Empty;
                return _readerNav.Prefix;
            }
        }

        // Gets a value indicating whether
        // XmlNodeReader.Value has a value to return.
        public override bool HasValue
        {
            get
            {
                if (!IsInReadingStates())
                    return false;
                return _readerNav.HasValue;
            }
        }

        // Gets the text value of the current node.
        public override string Value
        {
            get
            {
                if (!IsInReadingStates())
                    return String.Empty;
                return _readerNav.Value;
            }
        }

        // Gets the depth of the
        // current node in the XML element stack.
        public override int Depth
        {
            get { return _curDepth; }
        }

        // Gets the base URI of the current node.
        public override String BaseURI
        {
            get { return _readerNav.BaseURI; }
        }

        public override bool CanResolveEntity
        {
            get { return true; }
        }

        // Gets a value indicating whether the current
        // node is an empty element (for example, <MyElement/>.
        public override bool IsEmptyElement
        {
            get
            {
                if (!IsInReadingStates())
                    return false;
                return _readerNav.IsEmptyElement;
            }
        }

        // Gets a value indicating whether the current node is an
        // attribute that was generated from the default value defined
        // in the DTD or schema.
        public override bool IsDefault
        {
            get
            {
                if (!IsInReadingStates())
                    return false;
                return _readerNav.IsDefault;
            }
        }

        // Gets the current xml:space scope.
        public override XmlSpace XmlSpace
        {
            get
            {
                if (!IsInReadingStates())
                    return XmlSpace.None;
                return _readerNav.XmlSpace;
            }
        }

        // Gets the current xml:lang scope.
        public override string XmlLang
        {
            // Assume everything is in Unicode
            get
            {
                if (!IsInReadingStates())
                    return String.Empty;
                return _readerNav.XmlLang;
            }
        }

        public override IXmlSchemaInfo SchemaInfo
        {
            get
            {
                if (!IsInReadingStates())
                {
                    return null;
                }
                return _readerNav.SchemaInfo;
            }
        }

        //
        // Attribute Accessors
        //

        // Gets the number of attributes on the current node.
        public override int AttributeCount
        {
            get
            {
                if (!IsInReadingStates() || _nodeType == XmlNodeType.EndElement)
                    return 0;
                return _readerNav.AttributeCount;
            }
        }

        // Gets the value of the attribute with the specified name.
        public override string GetAttribute(string name)
        {
            //if not on Attribute, only element node could have attributes
            if (!IsInReadingStates())
                return null;
            return _readerNav.GetAttribute(name);
        }

        // Gets the value of the attribute with the specified name and namespace.
        public override string GetAttribute(string name, string namespaceURI)
        {
            //if not on Attribute, only element node could have attributes
            if (!IsInReadingStates())
                return null;
            String ns = (namespaceURI == null) ? String.Empty : namespaceURI;
            return _readerNav.GetAttribute(name, ns);
        }

        // Gets the value of the attribute with the specified index.
        public override string GetAttribute(int attributeIndex)
        {
            if (!IsInReadingStates())
                throw new ArgumentOutOfRangeException(nameof(attributeIndex));
            //CheckIndexCondition( i );
            //Debug.Assert( nav.NodeType == XmlNodeType.Element );
            return _readerNav.GetAttribute(attributeIndex);
        }

        // Moves to the attribute with the specified name.
        public override bool MoveToAttribute(string name)
        {
            if (!IsInReadingStates())
                return false;
            _readerNav.ResetMove(ref _curDepth, ref _nodeType);
            if (_readerNav.MoveToAttribute(name))
            { //, ref curDepth ) ) {
                _curDepth++;
                _nodeType = _readerNav.NodeType;
                if (_bInReadBinary)
                {
                    FinishReadBinary();
                }
                return true;
            }
            _readerNav.RollBackMove(ref _curDepth);
            return false;
        }

        // Moves to the attribute with the specified name and namespace.
        public override bool MoveToAttribute(string name, string namespaceURI)
        {
            if (!IsInReadingStates())
                return false;
            _readerNav.ResetMove(ref _curDepth, ref _nodeType);
            String ns = (namespaceURI == null) ? String.Empty : namespaceURI;
            if (_readerNav.MoveToAttribute(name, ns))
            { //, ref curDepth ) ) {
                _curDepth++;
                _nodeType = _readerNav.NodeType;
                if (_bInReadBinary)
                {
                    FinishReadBinary();
                }
                return true;
            }
            _readerNav.RollBackMove(ref _curDepth);
            return false;
        }

        // Moves to the attribute with the specified index.
        public override void MoveToAttribute(int attributeIndex)
        {
            if (!IsInReadingStates())
                throw new ArgumentOutOfRangeException(nameof(attributeIndex));
            _readerNav.ResetMove(ref _curDepth, ref _nodeType);
            try
            {
                if (AttributeCount > 0)
                {
                    _readerNav.MoveToAttribute(attributeIndex);
                    if (_bInReadBinary)
                    {
                        FinishReadBinary();
                    }
                }
                else
                    throw new ArgumentOutOfRangeException(nameof(attributeIndex));
            }
            catch
            {
                _readerNav.RollBackMove(ref _curDepth);
                throw;
            }
            _curDepth++;
            _nodeType = _readerNav.NodeType;
        }

        // Moves to the first attribute.
        public override bool MoveToFirstAttribute()
        {
            if (!IsInReadingStates())
                return false;
            _readerNav.ResetMove(ref _curDepth, ref _nodeType);
            if (AttributeCount > 0)
            {
                _readerNav.MoveToAttribute(0);
                _curDepth++;
                _nodeType = _readerNav.NodeType;
                if (_bInReadBinary)
                {
                    FinishReadBinary();
                }
                return true;
            }
            _readerNav.RollBackMove(ref _curDepth);
            return false;
        }

        // Moves to the next attribute.
        public override bool MoveToNextAttribute()
        {
            if (!IsInReadingStates() || _nodeType == XmlNodeType.EndElement)
                return false;
            _readerNav.LogMove(_curDepth);
            _readerNav.ResetToAttribute(ref _curDepth);
            if (_readerNav.MoveToNextAttribute(ref _curDepth))
            {
                _nodeType = _readerNav.NodeType;
                if (_bInReadBinary)
                {
                    FinishReadBinary();
                }
                return true;
            }
            _readerNav.RollBackMove(ref _curDepth);
            return false;
        }

        // Moves to the element that contains the current attribute node.
        public override bool MoveToElement()
        {
            if (!IsInReadingStates())
                return false;
            _readerNav.LogMove(_curDepth);
            _readerNav.ResetToAttribute(ref _curDepth);
            if (_readerNav.MoveToElement())
            {
                _curDepth--;
                _nodeType = _readerNav.NodeType;
                if (_bInReadBinary)
                {
                    FinishReadBinary();
                }
                return true;
            }
            _readerNav.RollBackMove(ref _curDepth);
            return false;
        }

        //
        // Moving through the Stream
        //

        // Reads the next node from the stream.
        public override bool Read()
        {
            return Read(false);
        }
        private bool Read(bool fSkipChildren)
        {
            if (_fEOF)
                return false;

            if (_readState == ReadState.Initial)
            {
                // if nav is pointing at the document node, start with its children
                // otherwise,start with the node.
                if ((_readerNav.NodeType == XmlNodeType.Document) || (_readerNav.NodeType == XmlNodeType.DocumentFragment))
                {
                    _bStartFromDocument = true;
                    if (!ReadNextNode(fSkipChildren))
                    {
                        _readState = ReadState.Error;
                        return false;
                    }
                }
                ReSetReadingMarks();
                _readState = ReadState.Interactive;
                _nodeType = _readerNav.NodeType;
                //_depth = 0;
                _curDepth = 0;
                return true;
            }

            if (_bInReadBinary)
            {
                FinishReadBinary();
            }

            bool bRead = false;
            if ((_readerNav.CreatedOnAttribute))
                return false;
            ReSetReadingMarks();
            bRead = ReadNextNode(fSkipChildren);
            if (bRead)
            {
                return true;
            }
            else
            {
                if (_readState == ReadState.Initial || _readState == ReadState.Interactive)
                    _readState = ReadState.Error;
                if (_readState == ReadState.EndOfFile)
                    _nodeType = XmlNodeType.None;
                return false;
            }
        }

        private bool ReadNextNode(bool fSkipChildren)
        {
            if (_readState != ReadState.Interactive && _readState != ReadState.Initial)
            {
                _nodeType = XmlNodeType.None;
                return false;
            }

            bool bDrillDown = !fSkipChildren;
            XmlNodeType nt = _readerNav.NodeType;
            //only goes down when nav.NodeType is of element or of document at the initial state, other nav.NodeType will not be parsed down
            //if nav.NodeType is of EntityReference, ResolveEntity() could be called to get the content parsed;
            bDrillDown = bDrillDown
                        && (_nodeType != XmlNodeType.EndElement)
                        && (_nodeType != XmlNodeType.EndEntity)
                        && (nt == XmlNodeType.Element || (nt == XmlNodeType.EntityReference && _bResolveEntity) ||
                            (((_readerNav.NodeType == XmlNodeType.Document) || (_readerNav.NodeType == XmlNodeType.DocumentFragment)) && _readState == ReadState.Initial));
            //first see if there are children of current node, so to move down
            if (bDrillDown)
            {
                if (_readerNav.MoveToFirstChild())
                {
                    _nodeType = _readerNav.NodeType;
                    _curDepth++;
                    if (_bResolveEntity)
                        _bResolveEntity = false;
                    return true;
                }
                else if (_readerNav.NodeType == XmlNodeType.Element
                          && !_readerNav.IsEmptyElement)
                {
                    _nodeType = XmlNodeType.EndElement;
                    return true;
                }
                else if (_readerNav.NodeType == XmlNodeType.EntityReference && _bResolveEntity)
                {
                    _bResolveEntity = false;
                    _nodeType = XmlNodeType.EndEntity;
                    return true;
                }
                // if fails to move to it 1st Child, try to move to next below
                return ReadForward(fSkipChildren);
            }
            else
            {
                if (_readerNav.NodeType == XmlNodeType.EntityReference && _bResolveEntity)
                {
                    //The only way to get to here is because Skip() is called directly after ResolveEntity()
                    // in this case, user wants to skip the first Child of EntityRef node and fSkipChildren is true
                    // We want to pointing to the first child node.
                    if (_readerNav.MoveToFirstChild())
                    {
                        _nodeType = _readerNav.NodeType;
                        _curDepth++;
                    }
                    else
                    {
                        _nodeType = XmlNodeType.EndEntity;
                    }
                    _bResolveEntity = false;
                    return true;
                }
            }
            return ReadForward(fSkipChildren);  //has to get the next node by moving forward
        }

        private void SetEndOfFile()
        {
            _fEOF = true;
            _readState = ReadState.EndOfFile;
            _nodeType = XmlNodeType.None;
        }

        private bool ReadAtZeroLevel(bool fSkipChildren)
        {
            Debug.Assert(_curDepth == 0);
            if (!fSkipChildren
                && _nodeType != XmlNodeType.EndElement
                && _readerNav.NodeType == XmlNodeType.Element
                && !_readerNav.IsEmptyElement)
            {
                _nodeType = XmlNodeType.EndElement;
                return true;
            }
            else
            {
                SetEndOfFile();
                return false;
            }
        }

        private bool ReadForward(bool fSkipChildren)
        {
            if (_readState == ReadState.Error)
                return false;

            if (!_bStartFromDocument && _curDepth == 0)
            {
                //already on top most node and we shouldn't move to next
                return ReadAtZeroLevel(fSkipChildren);
            }
            //else either we are not on top level or we are starting from the document at the very beginning in which case
            //  we will need to read all the "top" most nodes
            if (_readerNav.MoveToNext())
            {
                _nodeType = _readerNav.NodeType;
                return true;
            }
            else
            {
                //need to check its parent
                if (_curDepth == 0)
                    return ReadAtZeroLevel(fSkipChildren);
                if (_readerNav.MoveToParent())
                {
                    if (_readerNav.NodeType == XmlNodeType.Element)
                    {
                        _curDepth--;
                        _nodeType = XmlNodeType.EndElement;
                        return true;
                    }
                    else if (_readerNav.NodeType == XmlNodeType.EntityReference)
                    {
                        //coming back from entity reference node -- must be getting down through call ResolveEntity()
                        _curDepth--;
                        _nodeType = XmlNodeType.EndEntity;
                        return true;
                    }
                    return true;
                }
            }
            return false;
        }

        //the function reset the marks used for ReadChars() and MoveToAttribute(...), ReadAttributeValue(...)
        private void ReSetReadingMarks()
        {
            //_attrValInd = -1;
            _readerNav.ResetMove(ref _curDepth, ref _nodeType);
            //attrNav.MoveTo( nav );
            //curDepth = _depth;
        }

        // Gets a value indicating whether the reader is positioned at the
        // end of the stream.
        public override bool EOF
        {
            get { return (_readState != ReadState.Closed) && _fEOF; }
        }

        // Closes the stream, changes the XmlNodeReader.ReadState
        // to Closed, and sets all the properties back to zero.
        public override void Close()
        {
            _readState = ReadState.Closed;
        }

        // Gets the read state of the stream.
        public override ReadState ReadState
        {
            get { return _readState; }
        }

        // Skips to the end tag of the current element.
        public override void Skip()
        {
            Read(true);
        }

        // Reads the contents of an element as a string.
        public override string ReadString()
        {
            if ((this.NodeType == XmlNodeType.EntityReference) && _bResolveEntity)
            {
                if (!this.Read())
                {
                    throw new InvalidOperationException(SR.Xml_InvalidOperation);
                }
            }
            return base.ReadString();
        }

        //
        // Partial Content Read Methods
        //

        // Gets a value indicating whether the current node
        // has any attributes.
        public override bool HasAttributes
        {
            get
            {
                return (AttributeCount > 0);
            }
        }

        //
        // Nametable and Namespace Helpers
        //

        // Gets the XmlNameTable associated with this implementation.
        public override XmlNameTable NameTable
        {
            get { return _readerNav.NameTable; }
        }

        // Resolves a namespace prefix in the current element's scope.
        public override String LookupNamespace(string prefix)
        {
            if (!IsInReadingStates())
                return null;
            string ns = _readerNav.LookupNamespace(prefix);
            if (ns != null && ns.Length == 0)
            {
                return null;
            }
            return ns;
        }

        // Resolves the entity reference for nodes of NodeType EntityReference.
        public override void ResolveEntity()
        {
            if (!IsInReadingStates() || (_nodeType != XmlNodeType.EntityReference))
                throw new InvalidOperationException(SR.Xnr_ResolveEntity);
            _bResolveEntity = true; ;
        }

        // Parses the attribute value into one or more Text and/or
        // EntityReference node types.
        public override bool ReadAttributeValue()
        {
            if (!IsInReadingStates())
                return false;
            if (_readerNav.ReadAttributeValue(ref _curDepth, ref _bResolveEntity, ref _nodeType))
            {
                _bInReadBinary = false;
                return true;
            }
            return false;
        }

        public override bool CanReadBinaryContent
        {
            get
            {
                return true;
            }
        }

        public override int ReadContentAsBase64(byte[] buffer, int index, int count)
        {
            if (_readState != ReadState.Interactive)
            {
                return 0;
            }

            // init ReadContentAsBinaryHelper when called first time
            if (!_bInReadBinary)
            {
                _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
            }

            // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper
            _bInReadBinary = false;

            // call to the helper
            int readCount = _readBinaryHelper.ReadContentAsBase64(buffer, index, count);

            // turn on bInReadBinary in again and return
            _bInReadBinary = true;
            return readCount;
        }

        public override int ReadContentAsBinHex(byte[] buffer, int index, int count)
        {
            if (_readState != ReadState.Interactive)
            {
                return 0;
            }

            // init ReadContentAsBinaryHelper when called first time
            if (!_bInReadBinary)
            {
                _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
            }

            // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper
            _bInReadBinary = false;

            // call to the helper
            int readCount = _readBinaryHelper.ReadContentAsBinHex(buffer, index, count);

            // turn on bInReadBinary in again and return
            _bInReadBinary = true;
            return readCount;
        }

        public override int ReadElementContentAsBase64(byte[] buffer, int index, int count)
        {
            if (_readState != ReadState.Interactive)
            {
                return 0;
            }

            // init ReadContentAsBinaryHelper when called first time
            if (!_bInReadBinary)
            {
                _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
            }

            // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper
            _bInReadBinary = false;

            // call to the helper
            int readCount = _readBinaryHelper.ReadElementContentAsBase64(buffer, index, count);

            // turn on bInReadBinary in again and return
            _bInReadBinary = true;
            return readCount;
        }

        public override int ReadElementContentAsBinHex(byte[] buffer, int index, int count)
        {
            if (_readState != ReadState.Interactive)
            {
                return 0;
            }

            // init ReadContentAsBinaryHelper when called first time
            if (!_bInReadBinary)
            {
                _readBinaryHelper = ReadContentAsBinaryHelper.CreateOrReset(_readBinaryHelper, this);
            }

            // turn off bInReadBinary in order to have a normal Read() behavior when called from readBinaryHelper
            _bInReadBinary = false;

            // call to the helper
            int readCount = _readBinaryHelper.ReadElementContentAsBinHex(buffer, index, count);

            // turn on bInReadBinary in again and return
            _bInReadBinary = true;
            return readCount;
        }

        private void FinishReadBinary()
        {
            _bInReadBinary = false;
            _readBinaryHelper.Finish();
        }

        //
        // IXmlNamespaceResolver
        //

        IDictionary<string, string> IXmlNamespaceResolver.GetNamespacesInScope(XmlNamespaceScope scope)
        {
            return _readerNav.GetNamespacesInScope(scope);
        }

        string IXmlNamespaceResolver.LookupPrefix(string namespaceName)
        {
            return _readerNav.LookupPrefix(namespaceName);
        }

        String IXmlNamespaceResolver.LookupNamespace(string prefix)
        {
            if (!IsInReadingStates())
            {
                return _readerNav.DefaultLookupNamespace(prefix);
            }
            string ns = _readerNav.LookupNamespace(prefix);
            if (ns != null)
            {
                ns = _readerNav.NameTable.Add(ns);
            }
            return ns;
        }

        // DTD/Schema info used by XmlReader.GetDtdSchemaInfo()
        internal override IDtdInfo DtdInfo
        {
            get
            {
                return _readerNav.Document.DtdSchemaInfo;
            }
        }
    }
}


text:
/**
 * Created by jonathan on 10/29/16.
 */
import React from "react";

export default class App extends React.Component {
    render() {
        return

MBTA

            {this.props.children}

;
    }
};


text:
namespace sandbox {
namespace bpf_dsl {
class Policy;

// PolicyCompiler implements the bpf_dsl compiler, allowing users to
// transform bpf_dsl policies into BPF programs to be executed by the
// Linux kernel.
class SANDBOX_EXPORT PolicyCompiler {
 public:
  PolicyCompiler(const Policy* policy, TrapRegistry* registry);
  ~PolicyCompiler();

  // Compile registers any trap handlers needed by the policy and
  // compiles the policy to a BPF program, which it returns.
  scoped_ptr<CodeGen::Program> Compile();

  // Error returns an ErrorCode to indicate the system call should fail with
  // the specified error number.
  ErrorCode Error(int err);

  // Trap returns an ErrorCode to indicate the system call should
  // instead invoke a trap handler.
  ErrorCode Trap(TrapRegistry::TrapFnc fnc, const void* aux, bool safe);

  // UnsafeTraps require some syscalls to always be allowed.
  // This helper function returns true for these calls.
  static bool IsRequiredForUnsafeTrap(int sysno);

  // We can also use ErrorCode to request evaluation of a conditional
  // statement based on inspection of system call parameters.
  // This method wrap an ErrorCode object around the conditional statement.
  // Argument "argno" (1..6) will be bitwise-AND'd with "mask" and compared
  // to "value"; if equal, then "passed" will be returned, otherwise "failed".
  // If "is32bit" is set, the argument must in the range of 0x0..(1u << 32 - 1)
  // If it is outside this range, the sandbox treats the system call just
  // the same as any other ABI violation (i.e. it aborts with an error
  // message).
  ErrorCode CondMaskedEqual(int argno,
                            ErrorCode::ArgType is_32bit,
                            uint64_t mask,
                            uint64_t value,
                            const ErrorCode& passed,
                            const ErrorCode& failed);

  // Returns the fatal ErrorCode that is used to indicate that somebody
  // attempted to pass a 64bit value in a 32bit system call argument.
  // This method is primarily needed for testing purposes.
  ErrorCode Unexpected64bitArgument();

 private:
  struct Range;
  typedef std::vector<Range> Ranges;
  typedef std::set<ErrorCode, struct ErrorCode::LessThan> Conds;

  // Used by CondExpressionHalf to track which half of the argument it's
  // emitting instructions for.
  enum ArgHalf {
    LowerHalf,
    UpperHalf,
  };

  // Compile the configured policy into a complete instruction sequence.
  CodeGen::Node AssemblePolicy();

  // Return an instruction sequence that checks the
  // arch_seccomp_data's "arch" field is valid, and then passes
  // control to |passed| if so.
  CodeGen::Node CheckArch(CodeGen::Node passed);

  // If |has_unsafe_traps_| is true, returns an instruction sequence
  // that allows all system calls from Syscall::Call(), and otherwise
  // passes control to |rest|. Otherwise, simply returns |rest|.
  CodeGen::Node MaybeAddEscapeHatch(CodeGen::Node rest);

  // Return an instruction sequence that loads and checks the system
  // call number, performs a binary search, and then dispatches to an
  // appropriate instruction sequence compiled from the current
  // policy.
  CodeGen::Node DispatchSyscall();

  // Return an instruction sequence that checks the system call number
  // (expected to be loaded in register A) and if valid, passes
  // control to |passed| (with register A still valid).
  CodeGen::Node CheckSyscallNumber(CodeGen::Node passed);

  // Finds all the ranges of system calls that need to be handled. Ranges are
  // sorted in ascending order of system call numbers. There are no gaps in the
  // ranges. System calls with identical ErrorCodes are coalesced into a single
  // range.
  void FindRanges(Ranges* ranges);

  // Returns a BPF program snippet that implements a jump table for the
  // given range of system call numbers. This function runs recursively.
  CodeGen::Node AssembleJumpTable(Ranges::const_iterator start,
                                  Ranges::const_iterator stop);

  // CompileResult compiles an individual result expression into a
  // CodeGen node.
  CodeGen::Node CompileResult(const ResultExpr& res);

  // Returns a BPF program snippet that makes the BPF filter program exit
  // with the given ErrorCode "err". N.B. the ErrorCode may very well be a
  // conditional expression; if so, this function will recursively call
  // CondExpression() and possibly RetExpression() to build a complex set of
  // instructions.
  CodeGen::Node RetExpression(const ErrorCode& err);

  // Returns a BPF program that evaluates the conditional expression in
  // "cond" and returns the appropriate value from the BPF filter program.
  // This function recursively calls RetExpression(); it should only ever be
  // called from RetExpression().
  CodeGen::Node CondExpression(const ErrorCode& cond);

  // Returns a BPF program that evaluates half of a conditional expression;
  // it should only ever be called from CondExpression().
  CodeGen::Node CondExpressionHalf(const ErrorCode& cond,
                                   ArgHalf half,
                                   CodeGen::Node passed,
                                   CodeGen::Node failed);

  const Policy* policy_;
  TrapRegistry* registry_;

  Conds conds_;
  CodeGen gen_;
  bool has_unsafe_traps_;

  DISALLOW_COPY_AND_ASSIGN(PolicyCompiler);
};

}  // namespace bpf_dsl
}  // namespace sandbox

#endif  // SANDBOX_LINUX_BPF_DSL_POLICY_COMPILER_H_


text:
namespace System.Web.Configuration {
    using System.Web.Configuration;
    using System.Runtime.InteropServices;
    using System.Security.Permissions;

    [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("e707dcde-d1cd-11d2-bab9-00c04f8eceae")]
        internal interface IAssemblyCache {
        [PreserveSig()]
            int UninstallAssembly(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] String pszAssemblyName, IntPtr pvReserved, out uint pulDisposition);
        [PreserveSig()]
            int QueryAssemblyInfo(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] String pszAssemblyName, IntPtr pAsmInfo);
        [PreserveSig()]
            int CreateAssemblyCacheItem(uint dwFlags, IntPtr pvReserved, out IAssemblyCacheItem ppAsmItem, [MarshalAs(UnmanagedType.LPWStr)] String pszAssemblyName);
        [PreserveSig()]
            int CreateAssemblyScavenger(out Object ppAsmScavenger);
        [PreserveSig()]
            int InstallAssembly(uint dwFlags, [MarshalAs(UnmanagedType.LPWStr)] String pszManifestFilePath, IntPtr pvReserved);
    }// IAssemblyCache
}


text:
.. _campaigns/campaign_placements/loyalty_dashboard:
.. include:: /partials/common.rst

.. meta::
   :description: Loyalty Dashboard Placement is a Placement for Loyalty Campaigns.

Loyalty Dashboard Placement
===========================

You can create Loyalty Campaigns and place them on a standalone page on your site. With the Loyalty Dashboard Placement your Campaign will show up on any particular page of your site following rules specified in the placement.

.. note::
   Customers need to be authenticated in order to view their Loyalty Dashboard. This means that `email` has to be present in the `authenticate_customer` call of the :ref:`Talkable Initialization Script <integration/loyalty/integration_components/initialization_script>`.

It is a good practice to use `https://[your-site]/loyalty` URL for this new page and add a link accessible from any page that makes sense considering your website configuration. Most common uses are links in the user accounts section, or from the user accounts menu.

:ref:`Learn more about Placements <campaigns/campaign_placements>`

Integration instructions
------------------------

Loyalty Dashboard Placement doesn't require any additional integration since integration `5.0.0`.
If you have already added Talkable to your main layout (completed General Integration
for Custom platform, or installed Shopify, Magento, or Salesforce Commerce Cloud extensions), then you are all done.


text:
package net.tridentsdk.world.gen;

import javax.annotation.concurrent.Immutable;
import java.util.concurrent.Executor;

/**
 * A gen container is a context which specifies what
 * threading context to run a world generation task.
 *
 * @author TridentSDK
 * @since 0.5-alpha
 */
@Immutable
public interface GenContainer extends Executor {
    /**
     * The default container
     */
    GenContainer DEFAULT = (c) -> {
        throw new RuntimeException();
    };

    /**
     * An arbitrary container, useful for developers who are
     * familiar with multithreaded code and would like their
     * world generation code offloaded to the world handler
     */
    GenContainer ARBITRARY = (c) -> {
        throw new RuntimeException();
    };
}


text:
package com.reactnativenavigation.options;

import android.content.Context;

import com.reactnativenavigation.options.params.Bool;
import com.reactnativenavigation.options.params.Colour;
import com.reactnativenavigation.options.params.NullBool;
import com.reactnativenavigation.options.params.NullColor;
import com.reactnativenavigation.options.params.NullNumber;
import com.reactnativenavigation.options.params.Number;
import com.reactnativenavigation.options.parsers.BoolParser;
import com.reactnativenavigation.options.parsers.ColorParser;
import com.reactnativenavigation.options.parsers.NumberParser;

import org.json.JSONObject;

import androidx.annotation.Nullable;

public class DotIndicatorOptions {
    public static DotIndicatorOptions parse(Context context, @Nullable JSONObject json) {
        DotIndicatorOptions options = new DotIndicatorOptions();
        if (json == null) return options;

        options.color = ColorParser.parse(context, json, "color");
        options.size = NumberParser.parse(json, "size");
        options.visible = BoolParser.parse(json, "visible");
        options.animate = BoolParser.parse(json, "animate");

        return options;
    }

    public Colour color = new NullColor();
    public Number size = new NullNumber();
    public Bool visible = new NullBool();
    public Bool animate = new NullBool();

    public boolean hasValue() {
        return visible.hasValue();
    }
}


text:
using System.Threading.Tasks;
using Windows.Storage;

namespace Savvy.Services.SessionState
{
    public class SessionStateService : ISessionStateService
    {
        public string DropboxUserId { get; set; }
        public string DropboxAccessCode { get; set; }
        public string BudgetName { get; set; }
        public string DeviceGuid { get; set; }

        public Task SaveStateAsync()
        {
            var container = this.GetSettingsContainer();

            container.Values[nameof(this.DropboxUserId)] = this.DropboxUserId;
            container.Values[nameof(this.DropboxAccessCode)] = this.DropboxAccessCode;
            container.Values[nameof(this.BudgetName)] = this.BudgetName;

            return Task.CompletedTask;
        }

        public Task RestoreStateAsync()
        {
            var container = this.GetSettingsContainer();

            if (container.Values.ContainsKey(nameof(this.DropboxUserId)))
                this.DropboxUserId = (string)container.Values[nameof(this.DropboxUserId)];

            if (container.Values.ContainsKey(nameof(this.DropboxAccessCode)))
                this.DropboxAccessCode = (string)container.Values[nameof(this.DropboxAccessCode)];

            if (container.Values.ContainsKey(nameof(this.BudgetName)))
                this.BudgetName = (string)container.Values[nameof(this.BudgetName)];

            if (container.Values.ContainsKey(nameof(this.DeviceGuid)))
                this.DeviceGuid = (string)container.Values[nameof(this.DeviceGuid)];

            return Task.CompletedTask;
        }

        private ApplicationDataContainer GetSettingsContainer()
        {
            return ApplicationData.Current.LocalSettings.CreateContainer("Savvy.SessionState", ApplicationDataCreateDisposition.Always);
        }
    }
}


text:
<?php
/*
Template Name: Contact
*/
?>
<?php

global $post;

$contact_email = get_post_meta( $post->ID, '_contact_email', true );
$contact_subject = get_post_meta( $post->ID, '_contact_subject', true );

/*--------------------------------------------------------------------------------*/
$nameError = __( 'Please enter your name.', PRESSAPPS_TEXT_DOMAIN );
$emailError = __( 'Please enter your email address.', PRESSAPPS_TEXT_DOMAIN );
$emailInvalidError = __( 'You entered an invalid email address.', PRESSAPPS_TEXT_DOMAIN );
$commentError = __( 'Please enter a message.', PRESSAPPS_TEXT_DOMAIN );
/*--------------------------------------------------------------------------------*/

$options = get_option( PRESSAPPS_OPTIONS );

$errorMessages = array();

if(isset($_POST['submitted'])) {
	if(trim($_POST['contactName']) === '') {
		$errorMessages['nameError'] = $nameError;
		$hasError = true;
	} else {
		$name = trim($_POST['contactName']);
	}

	if(trim($_POST['email']) === '')  {
		$errorMessages['emailError'] = $emailError;
		$hasError = true;
	} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
		$errorMessages['emailInvalidError'] = $emailInvalidError;
		$hasError = true;
	} else {
		$email = trim($_POST['email']);
	}

	if(trim($_POST['comments']) === '') {
		$errorMessages['commentError'] = $commentError;
		$hasError = true;
	} else {
		if(function_exists('stripslashes')) {
			$comments = stripslashes(trim($_POST['comments']));
		} else {
			$comments = trim($_POST['comments']);
		}
	}

	if(!isset($hasError)) {
		$emailTo = $contact_email;
		if (!isset($emailTo) || ($emailTo == '') ){
			$emailTo = get_option('admin_email');
		}

		if ($contact_subject) {
			$subject = $contact_subject;
		} else {
			$subject = '[Contact Form] From '.$name;
		}

		$body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
		$headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email;

		mail($emailTo, $subject, $body, $headers);
		$emailSent = true;
	}

} ?>

<?php get_template_part('templates/page', 'header'); ?>

	<?php get_template_part('templates/content', 'page'); ?>

    <?php if(isset($emailSent) && $emailSent == true) { ?>

                <?php _e('Thank you, your email was sent successfully.', PRESSAPPS_TEXT_DOMAIN); ?>

    <?php } else { ?>

    <?php if(isset($hasError) || isset($captchaError)) { ?>

            <?php _e('Please fill in all the fields correctly.', PRESSAPPS_TEXT_DOMAIN); ?>

    <?php } ?>

	<form class="contact-form" action="<?php the_permalink(); ?>" method="post">
	  <fieldset>

	      <label class="<?php if(isset($errorMessages['nameError'])) { echo ' contact-error'; } ?>" for="contactName"><?php if(isset($errorMessages['nameError'])) { echo $errorMessages['nameError']; } else { echo __( 'Name', PRESSAPPS_TEXT_DOMAIN );} ?>
	      <input type="text" name="contactName" id="contact-form" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="required requiredField form-control">

	      <label class="<?php if(isset($errorMessages['emailError'])) { echo ' contact-error'; } ?><?php if(isset($errorMessages['emailInvalidError'])) { echo ' contact-error'; } ?>" for="email"><?php if(isset($errorMessages['emailError'])) { echo $errorMessages['emailError']; } elseif (isset($errorMessages['emailInvalidError'])) { echo $errorMessages['emailInvalidError']; } else { echo __( 'Email', PRESSAPPS_TEXT_DOMAIN );} ?>
	      <input type="text" name="email" id="contact-form" value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" class="required requiredField email form-control">

	      <label class="textarea<?php if(isset($errorMessages['commentError'])) { echo ' contact-error'; } ?>" for="commentsText"><?php if(isset($errorMessages['commentError'])) { echo $errorMessages['commentError']; } else { echo __( 'Message', PRESSAPPS_TEXT_DOMAIN );} ?>
	      <textarea name="comments" id="contact-form" rows="7" cols="30" class="required requiredField<?php if(isset($errorMessages['commentError'])) { echo ' error'; } ?> form-control"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>

	        <input type="hidden" name="submitted" id="submitted" value="true" />
	        <button type="submit" class="btn btn-primary"><?php _e('Send Email', PRESSAPPS_TEXT_DOMAIN) ?></button>
	  </fieldset>
	</form>

	<?php } ?>


text:
#include <iostream>

#include "chaiscript/chaiscript.hpp"
#ifdef READLINE_AVAILABLE
#include <readline/readline.h>
#include <readline/history.h>
#endif

using namespace chaiscript;

std::string get_next_command() {
#ifdef READLINE_AVAILABLE
  char *input_raw;
  input_raw = readline("eval> ");
  add_history(input_raw);
  return std::string(input_raw);
#else
  std::string retval;
  std::cout << "eval> ";
  std::getline(std::cin, retval);
  return retval;
#endif
}

void fuction(void)
{
  // do nothing
}

class test
{
  ChaiScript chai;
  ChaiScript::State backupState;
  public:
  test()
  {
    backupState = chai.get_state();
  }
  ~test(){}

  void ResetState()
  {
    chai.set_state(backupState);
    chai.add(fun(&fuction),"Whatever()");
  }

  void RunFile(std::string sFile)
  {
    try {
      chaiscript::Boxed_Value val = chai.eval_file(sFile);
    }
    catch (std::exception &e) {
      std::cout << e.what() << std::endl;
    }
  }

};

int main(int /*argc*/, char * /*argv*/[]) {

  test myChai;

  std::string command = "";

  //
  // this loop increases memoryusage, if RunFile is not called (just hittin enter)
  // as soon RunFile gets called, memory will be freed.
  //
  // scenario1 - RunFile gets called every Loop: memoryusage does not change
  // scenario2 - RunFile gets never called (just hitting enter): memoryusage increases every loop
  // scenario3 - RunFile gets in changing intervals: memoryusage goes up and down, but never as
  //            low as in case 1 scenario3 :

  while(command != "quit")
  {
    for(int i = 1; i < 200; i++)
      myChai.ResetState();

    if(command == "runfile")
      myChai.RunFile("Test.chai");

    command = get_next_command();
  }
}