text:
#include "ConsumeWindowsEventLog.h"
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <iostream>
#include <memory>
#include <codecvt>
#include <regex>

#include "io/DataStream.h"
#include "core/ProcessContext.h"
#include "core/ProcessSession.h"
#include "utils/OsUtils.h"

#pragma comment(lib, "wevtapi.lib")

namespace org {
namespace apache {
namespace nifi {
namespace minifi {
namespace processors {

static std::string to_string(const wchar_t* pChar) {
  return std::wstring_convert<std::codecvt_utf8<wchar_t>>().to_bytes(pChar);
}

const std::string ConsumeWindowsEventLog::ProcessorName("ConsumeWindowsEventLog");

core::Property ConsumeWindowsEventLog::Channel(
  core::PropertyBuilder::createProperty("Channel")->
  isRequired(true)->
  withDefaultValue("System")->
  withDescription("The Windows Event Log Channel to listen to.")->
  supportsExpressionLanguage(true)->
  build());

core::Property ConsumeWindowsEventLog::Query(
  core::PropertyBuilder::createProperty("Query")->
  isRequired(true)->
  withDefaultValue("*")->
  withDescription("XPath Query to filter events. (See https://msdn.microsoft.com/en-us/library/windows/desktop/dd996910(v=vs.85).aspx for examples.)")->
  supportsExpressionLanguage(true)->
  build());

core::Property ConsumeWindowsEventLog::RenderFormatXML(
  core::PropertyBuilder::createProperty("Render Format XML?")->
  isRequired(true)->
  withDefaultValue<bool>(true)->
  withDescription("Render format XML or Text.)")->
  supportsExpressionLanguage(true)->
  build());

core::Property ConsumeWindowsEventLog::MaxBufferSize(
  core::PropertyBuilder::createProperty("Max Buffer Size")->
  isRequired(true)->
  withDefaultValue<core::DataSizeValue>("1 MB")->
  withDescription(
    "The individual Event Log XMLs are rendered to a buffer."
    " This specifies the maximum size in bytes that the buffer will be allowed to grow to. (Limiting the maximum size of an individual Event XML.)")->
  build());

core::Property ConsumeWindowsEventLog::InactiveDurationToReconnect(
  core::PropertyBuilder::createProperty("Inactive Duration To Reconnect")->
  isRequired(true)->
  withDefaultValue<core::TimePeriodValue>("10 min")->
  withDescription(
    "If no new event logs are processed for the specified time period, "
    " this processor will try reconnecting to recover from a state where any further messages cannot be consumed."
    " Such situation can happen if Windows Event Log service is restarted, or ERROR_EVT_QUERY_RESULT_STALE (15011) is returned."
    " Setting no duration, e.g. '0 ms' disables auto-reconnection.")->
  build());

core::Property ConsumeWindowsEventLog::IdentifierMatcher(
	core::PropertyBuilder::createProperty("Identifier Match Regex")->
	isRequired(false)->
	withDefaultValue(".*Sid")->
	withDescription("Regular Expression to match Subject Identifier Fields. These will be placed into the attributes of the FlowFile")->
	build());

core::Property ConsumeWindowsEventLog::IdentifierFunction(
	core::PropertyBuilder::createProperty("Apply Identifier Function")->
	isRequired(false)->
	withDefaultValue<bool>(true)->
	withDescription("If true it will resolve SIDs matched in the 'Identifier Match Regex' to the DOMAIN\\USERNAME associated with that ID")->
	build());

core::Relationship ConsumeWindowsEventLog::Success("success", "Relationship for successfully consumed events.");

ConsumeWindowsEventLog::ConsumeWindowsEventLog(const std::string& name, utils::Identifier uuid)
  : core::Processor(name, uuid), logger_(logging::LoggerFactory<ConsumeWindowsEventLog>::getLogger()), apply_identifier_function_(false) {
  // Initializes COM for current thread, it is needed to MSXML parser.
  CoInitializeEx(0, COINIT_APARTMENTTHREADED);

  char buff[MAX_COMPUTERNAME_LENGTH + 1];
  DWORD size = sizeof(buff);
  if (GetComputerName(buff, &size)) {
    computerName_ = buff;
  } else {
    LogWindowsError();
  }
}

ConsumeWindowsEventLog::~ConsumeWindowsEventLog() {
  if (xmlDoc_) {
    xmlDoc_.Release();
  }
  CoUninitialize();
}

void ConsumeWindowsEventLog::initialize() {
  //! Set the supported properties
  setSupportedProperties({Channel, Query, RenderFormatXML, MaxBufferSize, InactiveDurationToReconnect, IdentifierMatcher, IdentifierFunction });

  //! Set the supported relationships
  setSupportedRelationships({Success});
}

void ConsumeWindowsEventLog::onSchedule(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSessionFactory> &sessionFactory) {
	context->getProperty(IdentifierMatcher.getName(), regex_);
	context->getProperty(IdentifierFunction.getName(), apply_identifier_function_);
  if (subscriptionHandle_) {
    logger_->log_error("Processor already subscribed to Event Log, expected cleanup to unsubscribe.");
  } else {
    sessionFactory_ = sessionFactory;

    subscribe(context);
  }
}

void ConsumeWindowsEventLog::onTrigger(const std::shared_ptr<core::ProcessContext> &context, const std::shared_ptr<core::ProcessSession> &session) {
  if (!subscriptionHandle_) {
    if (!subscribe(context)) {
      context->yield();
      return;
    }
  }

  const auto flowFileCount = processQueue(session);

  const auto now = GetTickCount64();

  if (flowFileCount > 0) {
    lastActivityTimestamp_ = now;
  }
  else if (inactiveDurationToReconnect_ > 0) {
    if ((now - lastActivityTimestamp_) > inactiveDurationToReconnect_) {
      logger_->log_info("Exceeds configured 'inactive duration to reconnect' %lld ms. Unsubscribe to reconnect..", inactiveDurationToReconnect_);
      unsubscribe();
    }
  }
}

void ConsumeWindowsEventLog::matchRegex(const MSXML2::IXMLDOMElementPtr pRoot, std::map<std::string, std::string> &fieldsAndValues, std::wregex match) {
	const auto pNodeChildren = pRoot->childNodes;
	using convert_type = std::codecvt_utf8<wchar_t>;
	std::wstring_convert<convert_type, wchar_t> converter;
	for (long i = 0; i < pNodeChildren->length; i++) {
		const auto pNode = pNodeChildren->item[i];
		const auto nodeType = pNode->GetnodeType();
		if (DOMNodeType::NODE_ELEMENT == nodeType) {
			auto nodeName = pNode->nodeName;

			std::wstring wstringNodeName(nodeName, SysStringLen(nodeName));
			bool matched = false;
			if (std::regex_match(wstringNodeName, match)) {
				matched = true;
			}
			else {
				const auto pAttributes = pNode->attributes;
				for (long iAttr = 0; iAttr < pAttributes->length; iAttr++) {
					const auto pAttribute = pAttributes->item[iAttr];
					if (pAttribute->nodeName == static_cast<_bstr_t>("Name")) {
						auto  attributeNodeName = static_cast<_bstr_t>(pAttribute->nodeValue);
						std::wstring wAttributeNodeName(attributeNodeName, SysStringLen(attributeNodeName));
						if (std::regex_match(wAttributeNodeName, match)) {
							wstringNodeName = attributeNodeName;
							matched = true;
						}
					}
				}

			}
			if (matched) {
				auto value = static_cast<_bstr_t>(pNode->Gettext());
				std::wstring wstringValue(value, SysStringLen(value));
				auto matched_field_name = converter.to_bytes(wstringNodeName);
				auto matched_field_value = converter.to_bytes(wstringValue);

				fieldsAndValues[matched_field_name] = apply_identifier_function_ ? utils::OsUtils::userIdToUsername(matched_field_value) : matched_field_value;
			}
			matchRegex(pNode, fieldsAndValues, match);
		}
	}

}

void ConsumeWindowsEventLog::createTextOutput(const MSXML2::IXMLDOMElementPtr pRoot, std::wstringstream& stream, std::vector<std::wstring>& ancestors) {
  const auto pNodeChildren = pRoot->childNodes;

  auto writeAncestors = [](const std::vector<std::wstring>& ancestors, std::wstringstream& stream) {
    for (size_t j = 0; j < ancestors.size() - 1; j++) {
      stream << ancestors[j] + L'/';
    }
    stream << ancestors.back();
  };

  if (0 == pNodeChildren->length) {
    writeAncestors(ancestors, stream);

    stream << std::endl;
  } else {
    for (long i = 0; i < pNodeChildren->length; i++) {
      std::wstringstream curStream;

      const auto pNode = pNodeChildren->item[i];

      const auto nodeType = pNode->GetnodeType();

      if (DOMNodeType::NODE_TEXT == nodeType) {
        const auto nodeValue = pNode->text;
        if (nodeValue.length()) {
          writeAncestors(ancestors, stream);

          std::wstring strNodeValue = static_cast<LPCWSTR>(nodeValue);

          // Remove '\n', '\r' - just substitute all whitespaces with ' '.
          strNodeValue = std::regex_replace(strNodeValue, std::wregex(L"\\s+"), L" ");

          curStream << L" = " << strNodeValue;
        }

        stream << curStream.str() << std::endl;
      } else if (DOMNodeType::NODE_ELEMENT == nodeType) {
        curStream << pNode->nodeName;

        const auto pAttributes = pNode->attributes;
        for (long iAttr = 0; iAttr < pAttributes->length; iAttr++) {
          const auto pAttribute = pAttributes->item[iAttr];

          curStream << L" " << pAttribute->nodeName << L'(' << static_cast<_bstr_t>(pAttribute->nodeValue) << L')';
        }

        ancestors.emplace_back(curStream.str());
        createTextOutput(pNode, stream, ancestors);
        ancestors.pop_back();
      }
    }
  }
}

bool ConsumeWindowsEventLog::subscribe(const std::shared_ptr<core::ProcessContext> &context) {
  std::string channel;
  context->getProperty(Channel.getName(), channel);

  std::string query;
  context->getProperty(Query.getName(), query);

  context->getProperty(RenderFormatXML.getName(), renderXML_);

  if (xmlDoc_) {
	  xmlDoc_.Release();
  }

  HRESULT hr = xmlDoc_.CreateInstance(__uuidof(MSXML2::DOMDocument60));
  if (FAILED(hr)) {
      logger_->log_error("!xmlDoc_.CreateInstance %x", hr);
      return false;
  }

  xmlDoc_->async = VARIANT_FALSE;
  xmlDoc_->validateOnParse = VARIANT_FALSE;
  xmlDoc_->resolveExternals = VARIANT_FALSE;

  context->getProperty(MaxBufferSize.getName(), maxBufferSize_);
  logger_->log_debug("ConsumeWindowsEventLog: maxBufferSize_ %lld", maxBufferSize_);

  provenanceUri_ = "winlog://" + computerName_ + "/" + channel + "?" + query;

  std::string strInactiveDurationToReconnect;
  context->getProperty(InactiveDurationToReconnect.getName(), strInactiveDurationToReconnect);

  // Get 'inactiveDurationToReconnect_'.
  core::TimeUnit unit;
  if (core::Property::StringToTime(strInactiveDurationToReconnect, inactiveDurationToReconnect_, unit) &&
    core::Property::ConvertTimeUnitToMS(inactiveDurationToReconnect_, unit, inactiveDurationToReconnect_)) {
    logger_->log_info("inactiveDurationToReconnect: [%lld] ms", inactiveDurationToReconnect_);
  }

  subscriptionHandle_ = EvtSubscribe(
      NULL,
      NULL,
      std::wstring(channel.begin(), channel.end()).c_str(),
      std::wstring(query.begin(), query.end()).c_str(),
      NULL,
      this,
      [](EVT_SUBSCRIBE_NOTIFY_ACTION action, PVOID pContext, EVT_HANDLE hEvent)
      {
        auto pConsumeWindowsEventLog = static_cast<ConsumeWindowsEventLog*>(pContext);

        auto& logger = pConsumeWindowsEventLog->logger_;

        if (action == EvtSubscribeActionError) {
          if (ERROR_EVT_QUERY_RESULT_STALE == (DWORD)hEvent) {
            logger->log_error("Received missing event notification. Consider triggering processor more frequently or increasing queue size.");
          } else {
            logger->log_error("Received the following Win32 error: %x", hEvent);
          }
        } else if (action == EvtSubscribeActionDeliver) {
          DWORD size = 0;
          DWORD used = 0;
          DWORD propertyCount = 0;

          if (!EvtRender(NULL, hEvent, EvtRenderEventXml, size, 0, &used, &propertyCount)) {
            if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) {
              if (used > pConsumeWindowsEventLog->maxBufferSize_) {
                logger->log_error("Dropping event %x because it couldn't be rendered within %ll bytes.", hEvent, pConsumeWindowsEventLog->maxBufferSize_);
                return 0UL;
              }

              size = used;
              std::vector<wchar_t> buf(size/2 + 1);
              if (EvtRender(NULL, hEvent, EvtRenderEventXml, size, &buf[0], &used, &propertyCount)) {
                const auto xml = to_string(&buf[0]);

				EventRender renderedData;
				if (VARIANT_FALSE == pConsumeWindowsEventLog->xmlDoc_->loadXML(_bstr_t(xml.c_str()))) {
					logger->log_error("'loadXML' failed");
					return 0UL;
				}
				if (!pConsumeWindowsEventLog->regex_.empty()) {
					std::wstring wstring_regex_;
					wstring_regex_.assign(pConsumeWindowsEventLog->regex_.begin(), pConsumeWindowsEventLog->regex_.end());
					std::wregex  regex(wstring_regex_);
					pConsumeWindowsEventLog->matchRegex(pConsumeWindowsEventLog->xmlDoc_->documentElement, renderedData.matched_fields_, regex);
				}

                if (pConsumeWindowsEventLog->renderXML_) {
					renderedData.text_ = std::move(xml);
                } else {

                  std::wstringstream stream;
                  std::vector<std::wstring> ancestors;
                  pConsumeWindowsEventLog->createTextOutput(pConsumeWindowsEventLog->xmlDoc_->documentElement, stream, ancestors);
				  renderedData.text_ = std::move(to_string(stream.str().c_str()));
                }
				pConsumeWindowsEventLog->listRenderedData_.enqueue(std::move(renderedData));
              } else {
                logger->log_error("EvtRender returned the following error code: %d.", GetLastError());
              }
            }
          }
        }

        return 0UL;
      },
      EvtSubscribeToFutureEvents | EvtSubscribeStrict);

  if (!subscriptionHandle_) {
    logger_->log_error("Unable to subscribe with provided parameters, received the following error code: %d", GetLastError());
    return false;
  }

  lastActivityTimestamp_ = GetTickCount64();

  return true;
}

void ConsumeWindowsEventLog::unsubscribe()
{
  if (subscriptionHandle_) {
    EvtClose(subscriptionHandle_);
    subscriptionHandle_ = 0;
  }
}

int ConsumeWindowsEventLog::processQueue(const std::shared_ptr<core::ProcessSession> &session)
{
  struct WriteCallback: public OutputStreamCallback {
    WriteCallback(const std::string& str)
      : str_(str) {
    }

    int64_t process(std::shared_ptr<io::BaseStream> stream) {
      return stream->writeData((uint8_t*)&str_[0], str_.size());
    }

    std::string str_;
  };

  int flowFileCount = 0;

  EventRender evt;
  while (listRenderedData_.try_dequeue(evt)) {
    auto flowFile = session->create();

    session->write(flowFile, &WriteCallback(evt.text_));
	for (const auto &fieldMapping : evt.matched_fields_) {
		if (!fieldMapping.second.empty()) {
			session->putAttribute(flowFile, fieldMapping.first, fieldMapping.second);
		}
	}
    session->putAttribute(flowFile, FlowAttributeKey(MIME_TYPE), "application/xml");
    session->getProvenanceReporter()->receive(flowFile, provenanceUri_, getUUIDStr(), "Consume windows event logs", 0);
    session->transfer(flowFile, Success);
    session->commit();

    flowFileCount++;
  }

  return flowFileCount;
}

void ConsumeWindowsEventLog::notifyStop()
{
  unsubscribe();

  if (listRenderedData_.size_approx() != 0) {
    auto session = sessionFactory_->createSession();
    if (session) {
      logger_->log_info("Finishing processing leftover events");

      processQueue(session);
    } else {
      logger_->log_error(
        "Stopping the processor but there is no ProcessSessionFactory stored and there are messages in the internal queue. "
        "Removing the processor now will clear the queue but will result in DATA LOSS. This is normally due to starting the processor, "
        "receiving events and stopping before the onTrigger happens. The messages in the internal queue cannot finish processing until "
        "the processor is triggered to run.");
    }
  }
}

void ConsumeWindowsEventLog::LogWindowsError()
{
  auto error_id = GetLastError();
  LPVOID lpMsg;

  FormatMessage(
    FORMAT_MESSAGE_ALLOCATE_BUFFER |
    FORMAT_MESSAGE_FROM_SYSTEM,
    NULL,
    error_id,
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
    (LPTSTR)&lpMsg,
    0, NULL);

  logger_->log_error("Error %d: %s\n", (int)error_id, (char *)lpMsg);

  LocalFree(lpMsg);
}

} /* namespace processors */
} /* namespace minifi */
} /* namespace nifi */
} /* namespace apache */
} /* namespace org */


text:
#ifndef SELECTION_H
#define SELECTION_H

#include <ext/functional>
#include <ext/hash_map>
#include <functional>
#include <numeric>
#include <vector>
#include <iterator>
#include <boost/iterator/transform_iterator.hpp>

#include "math_util.h"
#include "func_util.h"

using __gnu_cxx::select1st;
using __gnu_cxx::select2nd;

template<typename It,typename Selector>
It roulette_select(It from,It to,const Selector& sel,int sum=-1) {
  if (sum==-1)
    sum=std::accumulate(from,to,0,compose3(std::plus<int>(),
					   __gnu_cxx::identity<int>(),sel));
  sum=randint(sum);
  do {
    sum-=sel(*from++);
  } while (sum>=0);
  return --from;
}

template<typename It>
It roulette_select(It from,It to,double sum=-1) {
  if (sum==-1)
    sum=std::accumulate(from,to,double(0));
  sum=randfloat()*sum;
  do {
    sum-=*from++;
  } while (sum>=0);
  return --from;
}

template<typename It>
It roulette_select(It from,It to,int sum) {
  return roulette_select(from,to,double(sum));
}

template<typename It,typename Comp>
It tournament_select(It from,It to,int tSize,Comp comp) {
  int dist=std::distance(from,to);
  It res=from+randint(dist);
  for (int i=1;i<tSize;++i) {
    It tmp=from+randint(dist);
    if (comp(*res,*tmp))
      res=tmp;
  }
  return res;
}

template<typename It>
It tournament_select(It from,It to,int tSize) {
  typedef typename std::iterator_traits<It>::value_type T;
  return tournament_select(from,to,tSize,std::less<T>());
}

class Selector : public std::iterator<std::forward_iterator_tag,int> {
public:
  Selector(int n) : _n(n),_v(-1) { }
  bool empty() const { return (_n==0); }
  int operator()() { return next(); }

  int operator*() const {
    if (_v==-1)
      _v=next();
    return _v;
  }
  Selector& operator++() {
    _v=(_v==-1 ? next() : -1);
    return *this;
  }
  bool operator==(const Selector& rhs) const { return _n==rhs._n; }
private:
  mutable int _n;
  typedef __gnu_cxx::hash_map<int,int> Map;
  mutable Map _map;
  mutable int _v;

  int next() const;
};

template<typename It,typename T,typename Distance>
It nearest_neighbor(It from,It to,const T& t,const Distance& dist=Distance()) {
  It closest=from;
  typename Distance::result_type closestD;
  for (;from!=to;++from) {
    typename Distance::result_type d=d(t,*from);
    if (d>closestD) {
      d=closestD;
      closest=from;
    }
  }
  return closest;
}

template<typename NodeT>
class NodeSelector {
public:
  typedef NodeT value_type;
  typedef std::pair<NodeT,int> Pair;
  typedef std::vector<Pair> PSeq;
  typedef typename boost::transform_iterator< select1st<Pair>,
					      typename PSeq::const_iterator >
  node_iterator;

  //annoying waste of precious tokens - is there a more consise way?
  struct arity_iterator {
    int operator*() const { return _i; }
    void operator++() {
      assert(false);
      /*++_it;
      for (;_it!=_end && *_it==0;++_it)
      ++i;*/
    }
  private:
    int _i;
    std::vector<int>::const_iterator _it;
    const std::vector<int>::const_iterator _end;

    arity_iterator(std::vector<int>::const_iterator it,
		   std::vector<int>::const_iterator end) :
      _i(0),_it(it),_end(end)
    {
      for (;_it!=_end && *_it==0;++_it,++_i);
    }
  };

  node_iterator begin_with_arity(int arity) const {
    return node_iterator(_byArity[arity].begin(),select1st<Pair>());
  }
  node_iterator end_with_arity(int arity) const {
    return node_iterator(_byArity[arity].end(),select1st<Pair>());
  }

  arity_iterator begin_arity() const {
    return arity_iterator(_aritySums.begin(),_aritySums.end());
  }
  arity_iterator end_arity() const {
    return arity_iterator(_aritySums.end(),_aritySums.end());
  }

  NodeT select_with_arity(int arity) const {
    return roulette_select
      (_byArity[arity].begin(),_byArity[arity].end(),
       select2nd<typename PSeq::value_type>(),_aritySums[arity])->first;
  }
  int count_with_arity(int arity) const {
    return _byArity[arity].size();
  }

  int select_arity(int from) const {
    //could make this slightly faster by caching the partial sums,
    //but who cares?
    return distance(_aritySums.begin(),
		    roulette_select(_aritySums.begin()+from,_aritySums.end()));
  }

  void insert(const NodeT& n,int arity,int prob=1) {
    if ((int)_byArity.size()<=arity) {
      _byArity.resize(arity+1);
      _aritySums.resize(arity+1,0);
    }
    _byArity[arity].push_back(std::make_pair(n,prob));
    _aritySums[arity]+=prob;
  }

  void clear() { _byArity.clear(); _aritySums.clear(); }
private:
  std::vector<PSeq> _byArity;
  std::vector<int> _aritySums;
};

#endif

redpajama_set_name: RedPajamaGithub


text:
package org.jenkinsci.remoting.util;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Properties;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Immutable representation of a version number based on the Mercury version numbering scheme.
 *
 * {@link VersionNumber}s are {@link Comparable}.
 *
 *
Special tokens

 *

 * We allow a component to be not just a number, but also "ea", "ea1", "ea2".
 * "ea" is treated as "ea0", and eaN < M for any M < 0.
 *
 *

 * '*' is also allowed as a component, and '*' < M for any M < 0.
 *
 *

 * 'SNAPSHOT' is also allowed as a component, and "N.SNAPSHOT" is interpreted as "N-1.*"
 *
 *

 * 2.0.* < 2.0.1 < 2.0.1-SNAPSHOT < 2.0.0.99 < 2.0.0 < 2.0.ea < 2.0
 *

 *
 * This class is re-implemented in 1.415. The class was originally introduced in 1.139
 *
 * @since 1.139
 * @author Stephen Connolly (stephenc@apache.org)
 * @author Kenney Westerhof (kenney@apache.org)
 * @author Hervé Boutemy (hboutemy@apache.org)
 */
// Copied from https://github.com/jenkinsci/lib-version-number/blob/master/src/main/java/hudson/util/VersionNumber.java
// We didn't want to introduce a dependency on another library and had troubles getting shading to work.
public class VersionNumber implements Comparable<VersionNumber> {

    private static final Pattern SNAPSHOT = Pattern.compile("^.*((?:-\\d{8}\\.\\d{6}-\\d+)|-SNAPSHOT)( \\(.*\\))?$");

    private String value;

    private String snapshot;

    private String canonical;

    private ListItem items;

    private interface Item {
        int INTEGER_ITEM = 0;

        int STRING_ITEM = 1;

        int LIST_ITEM = 2;

        int WILDCARD_ITEM = 3;

        // Cannot set name to compareTo because FindBugs will think this interface extend Comparable and fire CO_ABSTRACT_SELF bug
        int compare(Item item);

        int getType();

        boolean isNull();
    }

    /**
     * Represents a wild-card item in the version item list.
     */
    private static class WildCardItem implements Item {

        @Override
        public int compare(Item item) {
            if (item==null) // 1.* ( > 1.99) > 1
                return 1;
            switch (item.getType()) {
                case INTEGER_ITEM:
                case LIST_ITEM:
                case STRING_ITEM:
                    return 1;
                case WILDCARD_ITEM:
                    return 0;
                default:
                    return 1;
            }
        }

        @Override
        public int getType() {
            return WILDCARD_ITEM;
        }

        @Override
        public boolean isNull() {
            return false;
        }

        @Override
        public String toString() {
            return "*";
        }
    }

    /**
     * Represents a numeric item in the version item list.
     */
    private static class IntegerItem
            implements Item {
        private static final BigInteger BigInteger_ZERO = new BigInteger("0");

        private final BigInteger value;

        public static final IntegerItem ZERO = new IntegerItem();

        private IntegerItem() {
            this.value = BigInteger_ZERO;
        }

        public IntegerItem(String str) {
            this.value = new BigInteger(str);
        }

        @Override
        public int getType() {
            return INTEGER_ITEM;
        }

        @Override
        public boolean isNull() {
            return BigInteger_ZERO.equals(value);
        }

        @Override
        public int compare(Item item) {
            if (item == null) {
                return BigInteger_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1
            }

            switch (item.getType()) {
                case INTEGER_ITEM:
                    if (item instanceof IntegerItem) {
                        return value.compareTo(((IntegerItem) item).value);
                    }

                case STRING_ITEM:
                    return 1; // 1.1 > 1-sp

                case LIST_ITEM:
                    return 1; // 1.1 > 1-1

                case WILDCARD_ITEM:
                    return 0;

                default:
                    throw new RuntimeException("invalid item: " + item.getClass());
            }
        }

        @Override
        public String toString() {
            return value.toString();
        }
    }

    /**
     * Represents a string in the version item list, usually a qualifier.
     */
    private static class StringItem implements Item {
        private final static String[] QUALIFIERS = {"snapshot", "alpha", "beta", "milestone", "rc", "", "sp"};

        private final static List<String> _QUALIFIERS = Arrays.asList(QUALIFIERS);

        private final static Properties ALIASES = new Properties();

        static {
            ALIASES.put("ga", "");
            ALIASES.put("final", "");
            ALIASES.put("cr", "rc");
            ALIASES.put("ea", "rc");
        }

        /**
         * A comparable for the empty-string qualifier. This one is used to determine if a given qualifier makes the
         * version older than one without a qualifier, or more recent.
         */
        private static String RELEASE_VERSION_INDEX = String.valueOf(_QUALIFIERS.indexOf(""));

        private String value;

        public StringItem(String value, boolean followedByDigit) {
            if (followedByDigit && value.length() == 1) {
                // a1 = alpha-1, b1 = beta-1, m1 = milestone-1
                switch (value.charAt(0)) {
                    case 'a':
                        value = "alpha";
                        break;
                    case 'b':
                        value = "beta";
                        break;
                    case 'm':
                        value = "milestone";
                        break;
                    default:
                        /* fall through? */
                }
            }
            this.value = ALIASES.getProperty(value, value);
        }

        @Override
        public int getType() {
            return STRING_ITEM;
        }

        @Override
        public boolean isNull() {
            return (comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX) == 0);
        }

        /**
         * Returns a comparable for a qualifier.
         *

         * This method both takes into account the ordering of known qualifiers as well as lexical ordering for unknown
         * qualifiers.
         *

         * just returning an Integer with the index here is faster, but requires a lot of if/then/else to check for -1
         * or QUALIFIERS.size and then resort to lexical ordering. Most comparisons are decided by the first character,
         * so this is still fast. If more characters are needed then it requires a lexical sort anyway.
         */
        public static String comparableQualifier(String qualifier) {
            int i = _QUALIFIERS.indexOf(qualifier);

            return i == -1 ? _QUALIFIERS.size() + "-" + qualifier : String.valueOf(i);
        }

        @Override
        public int compare(Item item) {
            if (item == null) {
                // 1-rc < 1, 1-ga > 1
                return comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX);
            }
            switch (item.getType()) {
                case INTEGER_ITEM:
                    return -1; // 1.any < 1.1 ?

                case STRING_ITEM:
                    if (item instanceof StringItem) {
                        return comparableQualifier(value).compareTo(comparableQualifier(((StringItem) item).value));
                    }

                case LIST_ITEM:
                    return -1; // 1.any < 1-1

                case WILDCARD_ITEM:
                    return -1;

                default:
                    throw new RuntimeException("invalid item: " + item.getClass());
            }
        }

        @Override
        public String toString() {
            return value;
        }
    }

    /**
     * Represents a version list item. This class is used both for the global item list and for sub-lists (which start
     * with '-(number)' in the version specification).
     */
    private static class ListItem extends ArrayList<Item> implements Item {
        private static final long serialVersionUID = 1;

        @Override
        public int getType() {
            return LIST_ITEM;
        }

        @Override
        public boolean isNull() {
            return (size() == 0);
        }

        void normalize() {
            for (ListIterator<Item> iterator = listIterator(size()); iterator.hasPrevious(); ) {
                Item item = iterator.previous();
                if (item.isNull()) {
                    iterator.remove(); // remove null trailing items: 0, "", empty list
                } else {
                    break;
                }
            }
        }

        @Override
        public int compare(Item item) {
            if (item == null) {
                if (size() == 0) {
                    return 0; // 1-0 = 1- (normalize) = 1
                }
                Item first = get(0);
                return first.compare(null);
            }

            switch (item.getType()) {
                case INTEGER_ITEM:
                    return -1; // 1-1 < 1.0.x

                case STRING_ITEM:
                    return 1; // 1-1 > 1-sp

                case LIST_ITEM:
                    if (item instanceof ListItem) {
                        Iterator<Item> left = iterator();
                        Iterator<Item> right = ((ListItem) item).iterator();

                        while (left.hasNext() || right.hasNext()) {
                            Item l = left.hasNext() ? left.next() : null;
                            Item r = right.hasNext() ? right.next() : null;

                            // if this is shorter, then invert the compare and mul with -1
                            int result;
                            if (l == null) {
                                if (r == null) {
                                    result = 0;
                                } else {
                                    result = -1 * r.compare(null);
                                }
                            } else {
                                result = l.compare(r);
                            }

                            if (result != 0) {
                                return result;
                            }
                        }

                        return 0;
                    }

                case WILDCARD_ITEM:
                    return -1;

                default:
                    throw new RuntimeException("invalid item: " + item.getClass());
            }
        }

        @Override
        public String toString() {
            StringBuilder buffer = new StringBuilder("(");
            for (Iterator<Item> iter = iterator(); iter.hasNext(); ) {
                buffer.append(iter.next());
                if (iter.hasNext()) {
                    buffer.append(',');
                }
            }
            buffer.append(')');
            return buffer.toString();
        }
    }

    public VersionNumber(String version) {
        parseVersion(version);
    }

    private void parseVersion(String version) {
        this.value = version;

        items = new ListItem();

        Matcher matcher = SNAPSHOT.matcher(version);
        if (matcher.matches()) {
            snapshot = matcher.group(1);
            version = version.substring(0, matcher.start(1)) + "-SNAPSHOT";
        }
        version = version.toLowerCase(Locale.ENGLISH);

        ListItem list = items;

        Stack<Item> stack = new Stack<>();
        stack.push(list);

        boolean isDigit = false;

        int startIndex = 0;

        for (int i = 0; i < version.length(); i++) {
            char c = version.charAt(i);

            if (c == '.') {
                if (i == startIndex) {
                    list.add(IntegerItem.ZERO);
                } else {
                    list.add(parseItem(isDigit, version.substring(startIndex, i)));
                }
                startIndex = i + 1;
            } else if (c == '-') {
                if (i == startIndex) {
                    list.add(IntegerItem.ZERO);
                } else {
                    list.add(parseItem(isDigit, version.substring(startIndex, i)));
                }
                startIndex = i + 1;

                if (isDigit) {
                    list.normalize(); // 1.0-* = 1-*

                    if ((i + 1 < version.length()) && Character.isDigit(version.charAt(i + 1))) {
                        // new ListItem only if previous were digits and new char is a digit,
                        // ie need to differentiate only 1.1 from 1-1
                        list.add(list = new ListItem());

                        stack.push(list);
                    }
                }
            } else if (c == '*') {
                list.add(new WildCardItem());
                startIndex = i + 1;
            } else if (Character.isDigit(c)) {
                if (!isDigit && i > startIndex) {
                    list.add(new StringItem(version.substring(startIndex, i), true));
                    startIndex = i;
                }

                isDigit = true;
            } else if (Character.isWhitespace(c)) {
                if (i > startIndex) {
                    if (isDigit) {
                        list.add(parseItem(true, version.substring(startIndex, i)));
                    } else {
                        list.add(new StringItem(version.substring(startIndex, i), true));
                    }
                    startIndex = i;
                }

                isDigit = false;
            } else {
                if (isDigit && i > startIndex) {
                    list.add(parseItem(true, version.substring(startIndex, i)));
                    startIndex = i;
                }

                isDigit = false;
            }
        }

        if (version.length() > startIndex) {
            list.add(parseItem(isDigit, version.substring(startIndex)));
        }

        while (!stack.isEmpty()) {
            list = (ListItem) stack.pop();
            list.normalize();
        }

        canonical = items.toString();
    }

    private static Item parseItem(boolean isDigit, String buf) {
        return isDigit ? new IntegerItem(buf) : new StringItem(buf, false);
    }

    @Override
    public int compareTo(VersionNumber o) {
        int result = items.compare(o.items);
        if (result != 0) {
            return result;
        }
        if (snapshot == null) {
            return o.snapshot == null ? 0 : -1;
        }
        if (o.snapshot == null) {
            return 1;
        }
        if ("-SNAPSHOT".equals(snapshot) || "-SNAPSHOT".equals(o.snapshot)) {
            // cannot compare literal with timestamped.
            return 0;
        }
        result = snapshot.substring(1, 16).compareTo(o.snapshot.substring(1, 16));
        if (result != 0) {
            return result;
        }
        int i1 = Integer.parseInt(snapshot.substring(17));
        int i2 = Integer.parseInt(o.snapshot.substring(17));
        return Integer.compare(i1, i2);
    }

    @Override
    public String toString() {
        return value;
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof VersionNumber)) {
            return false;
        }
        VersionNumber that = (VersionNumber) o;
        if (!canonical.equals(that.canonical)) {
            return false;
        }
        if (snapshot == null) {
            return that.snapshot == null;
        }
        if ("-SNAPSHOT".equals(snapshot) || "-SNAPSHOT".equals(that.snapshot)) {
            // text snapshots always match text or timestamped
            return true;
        }
        return snapshot.equals(that.snapshot);
    }

    @Override
    public int hashCode() {
        return canonical.hashCode();
    }

    public boolean isOlderThan(VersionNumber rhs) {
        return compareTo(rhs) < 0;
    }

    public boolean isNewerThan(VersionNumber rhs) {
        return compareTo(rhs) > 0;
    }

    public boolean isOlderThanOrEqualTo(VersionNumber rhs) {
        return compareTo(rhs) <= 0;
    }

    public boolean isNewerThanOrEqualTo(VersionNumber rhs) {
        return compareTo(rhs) >= 0;
    }

    /**
     * Returns a digit (numeric component) by its position. Once a non-numeric component is found all remaining components
     * are also considered non-numeric by this method.
     *
     * @param idx Digit position we want to retrieve starting by 0.
     * @return The digit or -1 in case the position does not correspond with a digit.
     */
    public int getDigitAt(int idx) {
        if (idx < 0) {
            return -1;
        }

        Iterator<Item> it = items.iterator();
        int i = 0;
        Item item = null;
        while (i <= idx && it.hasNext()) {
            item = it.next();
            if (item instanceof IntegerItem) {
                i++;
            } else {
                return -1;
            }
        }
        return (idx - i >= 0) ? -1 : ((IntegerItem) item).value.intValue();
    }

    public static final Comparator<VersionNumber> DESCENDING = Comparator.reverseOrder();
}


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Homodium subcuspidans Nyl.

### Remarks
null


text:
package shared

import (
	"code.cloudfoundry.org/cli/api/cloudcontroller/ccv3"
	ccWrapper "code.cloudfoundry.org/cli/api/cloudcontroller/wrapper"
	"code.cloudfoundry.org/cli/api/uaa"
	uaaWrapper "code.cloudfoundry.org/cli/api/uaa/wrapper"
	"code.cloudfoundry.org/cli/command"
)

// NewClients creates a new V3 Cloud Controller client and UAA client using the
// passed in config.
func NewClients(config command.Config, ui command.UI) (*ccv3.Client, error) {
	if config.Target() == "" {
		return nil, command.NoAPISetError{
			BinaryName: config.BinaryName(),
		}
	}

	ccClient := ccv3.NewClient(config.BinaryName(), config.BinaryVersion())
	_, err := ccClient.TargetCF(ccv3.TargetSettings{
		URL:               config.Target(),
		SkipSSLValidation: config.SkipSSLValidation(),
		DialTimeout:       config.DialTimeout(),
	})
	if err != nil {
		return nil, ClientTargetError{Message: err.Error()}
	}

	uaaClient := uaa.NewClient(uaa.Config{
		AppName:           config.BinaryName(),
		AppVersion:        config.BinaryVersion(),
		ClientID:          config.UAAOAuthClient(),
		ClientSecret:      config.UAAOAuthClientSecret(),
		DialTimeout:       config.DialTimeout(),
		SkipSSLValidation: config.SkipSSLValidation(),
		URL:               ccClient.UAA(),
	})

	verbose, location := config.Verbose()
	if verbose {
		ccClient.WrapConnection(ccWrapper.NewRequestLogger(command.NewRequestLoggerTerminalDisplay(ui)))
		uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(command.NewRequestLoggerTerminalDisplay(ui)))
	}
	if location != nil {
		ccClient.WrapConnection(ccWrapper.NewRequestLogger(command.NewRequestLoggerFileWriter(ui, location)))
		uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(command.NewRequestLoggerFileWriter(ui, location)))
	}

	ccClient.WrapConnection(ccWrapper.NewUAAAuthentication(uaaClient, config))
	ccClient.WrapConnection(ccWrapper.NewRetryRequest(2))

	return ccClient, nil
}


text:
/**
 * @description Spice types
 */
export enum SpiceType {
	Cinnamon,
	Ginger,
	Paprika
}


text:
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace YAF.Lucene.Net.Codecs
{

    using AtomicReader = YAF.Lucene.Net.Index.AtomicReader;
    using IBits = YAF.Lucene.Net.Util.IBits;
    using Document = Documents.Document;
    using FieldInfo = YAF.Lucene.Net.Index.FieldInfo;
    using FieldInfos = YAF.Lucene.Net.Index.FieldInfos;
    using IIndexableField = YAF.Lucene.Net.Index.IIndexableField;
    using MergeState = YAF.Lucene.Net.Index.MergeState;

    /// <summary>
    /// Codec API for writing stored fields:
    /// <para/>
    /// <list type="number">
    ///   <item><description>For every document, <see cref="StartDocument(int)"/> is called,
    ///       informing the Codec how many fields will be written.</description></item>
    ///   <item><description><see cref="WriteField(FieldInfo, IIndexableField)"/> is called for
    ///       each field in the document.</description></item>
    ///   <item><description>After all documents have been written, <see cref="Finish(FieldInfos, int)"/>
    ///       is called for verification/sanity-checks.</description></item>
    ///   <item><description>Finally the writer is disposed (<see cref="Dispose(bool)"/>)</description></item>
    /// </list>
    /// <para/>
    /// @lucene.experimental
    /// </summary>
    public abstract class StoredFieldsWriter : IDisposable
    {
        /// <summary>
        /// Sole constructor. (For invocation by subclass
        /// constructors, typically implicit.)
        /// </summary>
        protected internal StoredFieldsWriter()
        {
        }

        /// <summary>
        /// Called before writing the stored fields of the document.
        /// <see cref="WriteField(FieldInfo, IIndexableField)"/> will be called
        /// <paramref name="numStoredFields"/> times. Note that this is
        /// called even if the document has no stored fields, in
        /// this case <paramref name="numStoredFields"/> will be zero.
        /// </summary>
        public abstract void StartDocument(int numStoredFields);

        /// <summary>
        /// Called when a document and all its fields have been added. </summary>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public virtual void FinishDocument()
        {
        }

        /// <summary>
        /// Writes a single stored field. </summary>
        public abstract void WriteField(FieldInfo info, IIndexableField field);

        /// <summary>
        /// Aborts writing entirely, implementation should remove
        /// any partially-written files, etc.
        /// </summary>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public abstract void Abort();

        /// <summary>
        /// Called before <see cref="Dispose()"/>, passing in the number
        /// of documents that were written. Note that this is
        /// intentionally redundant (equivalent to the number of
        /// calls to <see cref="StartDocument(int)"/>, but a <see cref="Codec"/> should
        /// check that this is the case to detect the bug described
        /// in LUCENE-1282.
        /// </summary>
        public abstract void Finish(FieldInfos fis, int numDocs);

        /// <summary>
        /// Merges in the stored fields from the readers in
        /// <paramref name="mergeState"/>. The default implementation skips
        /// over deleted documents, and uses <see cref="StartDocument(int)"/>,
        /// <see cref="WriteField(FieldInfo, IIndexableField)"/>, and <see cref="Finish(FieldInfos, int)"/>,
        /// returning the number of documents that were written.
        /// Implementations can override this method for more sophisticated
        /// merging (bulk-byte copying, etc).
        /// </summary>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public virtual int Merge(MergeState mergeState)
        {
            int docCount = 0;
            foreach (AtomicReader reader in mergeState.Readers)
            {
                int maxDoc = reader.MaxDoc;
                IBits liveDocs = reader.LiveDocs;
                for (int i = 0; i < maxDoc; i++)
                {
                    if (liveDocs != null && !liveDocs.Get(i))
                    {
                        // skip deleted docs
                        continue;
                    }
                    // TODO: this could be more efficient using
                    // FieldVisitor instead of loading/writing entire
                    // doc; ie we just have to renumber the field number
                    // on the fly?
                    // NOTE: it's very important to first assign to doc then pass it to
                    // fieldsWriter.addDocument; see LUCENE-1282
                    Document doc = reader.Document(i);
                    AddDocument(doc, mergeState.FieldInfos);
                    docCount++;
                    mergeState.CheckAbort.Work(300);
                }
            }
            Finish(mergeState.FieldInfos, docCount);
            return docCount;
        }

        /// <summary>
        /// Sugar method for <see cref="StartDocument(int)"/> + <see cref="WriteField(FieldInfo, IIndexableField)"/>
        /// for every stored field in the document. </summary>
        protected void AddDocument<T1>(IEnumerable<T1> doc, FieldInfos fieldInfos) where T1 : Lucene.Net.Index.IIndexableField
        {
            int storedCount = 0;
            foreach (IIndexableField field in doc)
            {
                if (field.IndexableFieldType.IsStored)
                {
                    storedCount++;
                }
            }

            StartDocument(storedCount);

            foreach (IIndexableField field in doc)
            {
                if (field.IndexableFieldType.IsStored)
                {
                    WriteField(fieldInfos.FieldInfo(field.Name), field);
                }
            }

            FinishDocument();
        }

        /// <summary>
        /// Disposes all resources used by this object.
        /// </summary>
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        /// <summary>
        /// Implementations must override and should dispose all resources used by this instance.
        /// </summary>
        protected abstract void Dispose(bool disposing);
    }
}


text:
using base::android::ConvertJavaStringToUTF16;
using base::android::ConvertUTF16ToJavaString;
using base::android::ConvertUTF8ToJavaString;

namespace {

Profile* GetOriginalProfile() {
  return g_browser_process->profile_manager()->GetDefaultProfile()->
      GetOriginalProfile();
}

}  // namespace

TemplateUrlServiceAndroid::TemplateUrlServiceAndroid(JNIEnv* env,
                                                     jobject obj)
    : weak_java_obj_(env, obj),
      template_url_service_(
          TemplateURLServiceFactory::GetForProfile(GetOriginalProfile())) {
  template_url_subscription_ =
      template_url_service_->RegisterOnLoadedCallback(
          base::Bind(&TemplateUrlServiceAndroid::OnTemplateURLServiceLoaded,
                     base::Unretained(this)));
}

TemplateUrlServiceAndroid::~TemplateUrlServiceAndroid() {
}

void TemplateUrlServiceAndroid::Load(JNIEnv* env, jobject obj) {
  template_url_service_->Load();
}

void TemplateUrlServiceAndroid::SetDefaultSearchProvider(JNIEnv* env,
                                                         jobject obj,
                                                         jint selected_index) {
  std::vector<TemplateURL*> template_urls =
      template_url_service_->GetTemplateURLs();
  size_t selected_index_size_t = static_cast<size_t>(selected_index);
  DCHECK_LT(selected_index_size_t, template_urls.size()) <<
      "Wrong index for search engine";

  TemplateURL* template_url = template_urls[selected_index_size_t];
  DCHECK_GT(template_url->prepopulate_id(), 0) <<
      "Tried to select non-prepopulated search engine";
  template_url_service_->SetDefaultSearchProvider(template_url);
}

jint TemplateUrlServiceAndroid::GetDefaultSearchProvider(JNIEnv* env,
                                                         jobject obj) {
  std::vector<TemplateURL*> template_urls =
      template_url_service_->GetTemplateURLs();
  TemplateURL* default_search_provider =
      template_url_service_->GetDefaultSearchProvider();
  for (size_t i = 0; i < template_urls.size(); ++i) {
    if (default_search_provider == template_urls[i])
      return i;
  }
  return -1;
}

jboolean TemplateUrlServiceAndroid::IsLoaded(JNIEnv* env, jobject obj) {
  return template_url_service_->loaded();
}

jint TemplateUrlServiceAndroid::GetTemplateUrlCount(JNIEnv* env, jobject obj) {
  return template_url_service_->GetTemplateURLs().size();
}

jboolean TemplateUrlServiceAndroid::IsSearchProviderManaged(JNIEnv* env,
                                                            jobject obj) {
  return template_url_service_->is_default_search_managed();
}

jboolean TemplateUrlServiceAndroid::IsSearchByImageAvailable(JNIEnv* env,
                                                             jobject obj) {
  const TemplateURL* default_search_provider =
      template_url_service_->GetDefaultSearchProvider();
  return default_search_provider &&
      !default_search_provider->image_url().empty() &&
      default_search_provider->image_url_ref().IsValid();
}

jboolean TemplateUrlServiceAndroid::IsDefaultSearchEngineGoogle(JNIEnv* env,
                                                                jobject obj) {
  TemplateURL* default_search_provider =
      template_url_service_->GetDefaultSearchProvider();
  return default_search_provider &&
      default_search_provider->url_ref().HasGoogleBaseURLs();
}

base::android::ScopedJavaLocalRef<jobject>
TemplateUrlServiceAndroid::GetPrepopulatedTemplateUrlAt(JNIEnv* env,
                                                        jobject obj,
                                                        jint index) {
  TemplateURL* template_url = template_url_service_->GetTemplateURLs()[index];
  if (!IsPrepopulatedTemplate(template_url) &&
      !template_url->created_by_policy())
   return ScopedJavaLocalRef<jobject>();

  return Java_TemplateUrl_create(
      env,
      index,
      ConvertUTF16ToJavaString(env, template_url->short_name()).obj(),
      ConvertUTF16ToJavaString(env, template_url->keyword()).obj());
}

bool TemplateUrlServiceAndroid::IsPrepopulatedTemplate(TemplateURL* url) {
  return url->prepopulate_id() > 0;
}

void TemplateUrlServiceAndroid::OnTemplateURLServiceLoaded() {
  template_url_subscription_.reset();
  JNIEnv* env = base::android::AttachCurrentThread();
  if (weak_java_obj_.get(env).is_null())
    return;

  Java_TemplateUrlService_templateUrlServiceLoaded(
      env, weak_java_obj_.get(env).obj());
}

base::android::ScopedJavaLocalRef<jstring>
TemplateUrlServiceAndroid::GetUrlForSearchQuery(JNIEnv* env,
                                                jobject obj,
                                                jstring jquery) {
  const TemplateURL* default_provider =
      template_url_service_->GetDefaultSearchProvider();

  string16 query(ConvertJavaStringToUTF16(env, jquery));

  std::string url;
  if (default_provider &&
      default_provider->url_ref().SupportsReplacement() && !query.empty()) {
    url = default_provider->url_ref().ReplaceSearchTerms(
        TemplateURLRef::SearchTermsArgs(query));
  }

  return ConvertUTF8ToJavaString(env, url);
}

base::android::ScopedJavaLocalRef<jstring>
TemplateUrlServiceAndroid::ReplaceSearchTermsInUrl(JNIEnv* env,
                                                   jobject obj,
                                                   jstring jquery,
                                                   jstring jcurrent_url) {
  TemplateURL* default_provider =
      template_url_service_->GetDefaultSearchProvider();

  string16 query(ConvertJavaStringToUTF16(env, jquery));
  GURL current_url(ConvertJavaStringToUTF16(env, jcurrent_url));
  GURL destination_url(current_url);
  if (default_provider && !query.empty()) {
    bool refined_query = default_provider->ReplaceSearchTermsInURL(current_url,
        TemplateURLRef::SearchTermsArgs(query), &destination_url);
    if (refined_query)
      return ConvertUTF8ToJavaString(env, destination_url.spec());
  }
  return base::android::ScopedJavaLocalRef<jstring>(env, NULL);
}

static jint Init(JNIEnv* env, jobject obj) {
  TemplateUrlServiceAndroid* template_url_service_android =
      new TemplateUrlServiceAndroid(env, obj);
  return reinterpret_cast<jint>(template_url_service_android);
}

// static
bool TemplateUrlServiceAndroid::Register(JNIEnv* env) {
  return RegisterNativesImpl(env);
}


text:
<?php

namespace ygg\Db;

abstract class PDO implements Driver {

	protected $_server;
	protected $_dbname;
	protected $_login;
	protected $_pwd;
	protected $_charset;

	protected $_link;

	/**
	 * Constructor
	 *
	 * @param string $server Server or UNIX Socket
	 * @param string $login Login
	 * @param string $pwd Password
	 * @param string $dbname Database name
	 * @param string $charset Charset
	**/
	public function __construct($server, $login = null, $pwd = null, $dbname = null, $charset = null){

		$this->_server = $server;
		$this->_login = $login;
		$this->_pwd = $pwd;
		$this->_dbname = $dbname;
		$this->_charset = $charset;

		$this->_link = null;

	}

	/**
	 * Instanciate PDO
	 *
	 * @param string $dsn DSN
	 * @param array $options PDO Options
	 * @return \PDO
	**/
	public function pdoConnect($dsn, array $options = null){

		try{

			$pdo = new \PDO($dsn, $this->_login, $this->_pwd, $options);
			$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
			$pdo->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);

		}catch(\PDOException $e){

			throw new Exception\ConnectionError(
				$e->getMessage(),
				get_class($this),
				$this->_server,
				$this->_dbname,
				$this->_login,
				$this->_pwd,
				$this->_charset
			);

		}

		return $pdo;

	}

	/**
	 * Disconnect
	 *
	 * @return PDO
	**/
	public function disconnect(){

		$this->_link = null;
		return $this;

	}

	/**
	 * Get database link
	 * (Because winners don't do (fake-)ORM.)
	 *
	 * @return \PDO|null
	**/
	public function giveMeControl(){

		return $this->_link;

	}

	/**
	 * Quote value
	 *
	 * @return string
	**/
	public function quoteValue($value){

		$this->connect();
		return $this->_link->quote($value);

	}

	/**
	 * Try to execute a request, throw a RequestError Exception if problem encountered
	 *
	 * @param \Closure $closure Request
	 * @return mixed
	**/
	private function tryRequest(\Closure $closure, $query, array $params = null){

		$this->connect();

		try{

			return $closure();

		}catch(\PDOException $e){

			if($query instanceof \PDOStatement){

				$infos = $query->errorInfo();
				$query = $query->queryString;
				$code = $infos[0];

			}else{

				$infos = $this->_link->errorInfo();
				$code = $this->_link->errorCode();

			}

			$message = $infos[2];

			throw new Exception\RequestError($query, $params, $code, $message);

		}

	}

	/**
	 * Query
	 *
	 * @param string $query Query string
	 * @return \PDOStatement
	**/
	public function query($query){

		return $this->tryRequest(function() use($query){
			return $this->_link->query($query);
		}, $query);

	}

	/**
	 * Exec
	 *
	 * @param string $query Query string
	 * @return \PDOStatement
	**/
	public function exec($query){

		return $this->tryRequest(function() use($query){
			return $this->_link->exec($query);
		}, $query);

	}

	/**
	 * Prepare a request
	 *
	 * @param string $query Query string
	 * @return \PDOStatement
	**/
	public function prepare($query){

		$this->connect();
		return $this->_link->prepare($query);

	}

	/**
	 * Execute a query
	 *
	 * @param \PDOStatement|Query $prepared PDOStatement or Query
	 * @param array $params Query parameters
	 * @return \PDOStatement
	**/
	public function execute($prepared, array $params = array()){

		//Instance of ygg\Db\Query ?
		if($prepared instanceof Query){

			$query = $prepared;
			$prepared = $query->getPreparedQuery();
			$params = $query->getParams();

		}

		//Replace Expr
		foreach($params AS $param => $value){

			if($value instanceof Expr){

				$params[$param] = $value->sqlizeString($this);

			}

		}

		//Try request
		$result = $this->tryRequest(
			function() use($prepared, $params){
				return $prepared->execute($params);
			},
			$prepared,
			$params
		);

		//Internal handler result
		if(isset($query)){

			$result = new Result\PDO($query, $this, $result);

		}

		return $result;

	}

	/**
	 * Create a Select query
	 * (using current connection)
	 *
	 * @param Table|string $table
	 * @return ygg\Db\Select
	**/
	public function select($table){

		$select = new Select($table);
		$select->setDriver($this);

		return $select;

	}

	/**
	 * Create an Insert Query
	 *
	 * @param Table|string $table Table or table name
	 * @param array $datas Date for insert
	 * @return bool
	**/
	public function insert($table, array $datas = array()){

		//Create an insert query
		$insert = new Insert($table);
		$insert->setDriver($this);

		//No data ? Return Insert
		if(empty($datas))
			return $insert;

		//Add values
		foreach($datas AS $key => $value){

			$insert->set($key, $value);

		}

		return $insert->execute();

	}

	/**
	 * Create an Update Query
	 *
	 * @param Table|table $table Table or table name
	 * @param array $datas New datas
	 * @param array $wheres Condition for update
	 * @return int number of affected rows
	**/
	public function update($table, array $datas = array(), array $wheres = null){

		//Create an update query
		$update = new Update($table);
		$update->setDriver($this);

		//No data ? Return Update
		if(empty($datas))
			return $update;

		//Set value(s)
		foreach($datas AS $key => $value){

			$update->set($key, $value);

		}

		//Add condition(s)
		if($wheres != null){

			// TODO More elegant condition system
			foreach($wheres AS $key => $value){

				if(is_array($value)){

					$operator = $value['operator'];
					$value = $value['value'];

				}else{

					$operator = $update::EQUAL;

				}

				$update->where($key, $value, $operator);

			}

		}

		return $update->execute();

	}

	/**
	 * Create a Delete Query
	 *
	 * @param Table|string $table Table or table name
	 * @param array $wheres Condition for delete
	 * @return int Affected rows
	**/
	public function delete($table, array $wheres = array()){

		//Create a delete query
		$delete = new Delete($table);
		$delete->setDriver($this);

		//No condition ? Hum... return in case of error
		if(empty($wheres))
			return $delete;

		//Add condition(s)
		foreach($wheres AS $key => $value){

			if(is_array($value)){

				$operator = $value['operator'];
				$value = $value['value'];

			}else{

				$operator = $delete::EQUAL;

			}

			$delete->where($key, $value, $operator);

		}

		return $delete->execute();

	}

	/**
	 * Fetch a row
	 *
	 * @param \PDOStatement $results Results
	 * @param int $offset Row number
	 * @return mixed
	**/
	public function fetch($results, $offset = 0){

		$this->connect();

		$offset = (int) $offset;

		$orientation = ($offset > 0)
			? \PDO::FETCH_ORI_ABS
			: \PDO::FETCH_ORI_NEXT;

		return $results->fetch(\PDO::FETCH_ASSOC, $orientation, $offset);

	}

	/**
	 * Fetch all row
	 *
	 * @param \PDOStatement $results Result
	 * @return array
	**/
	public function fetchAll($results){

		$this->connect();

		return $results->fetchAll(\PDO::FETCH_ASSOC);

	}

	/**
	 * Get last inserted id
	 *
	 * @param Table|string $name Table or Sequence name
	 * @return mixed
	**/
	public function lastInsertId($name = null){

		$this->connect();

		if($name instanceof Table)
			$name = $name->getTableSequence();

		return $this->_link->lastInsertId($name);

	}

}


text:
Speech to Text for Node.js

Currently support Chinese only. Will add more language(en/etc) and more engine(now stt use baidu api) recently.

# Quick Start

## JavaScript

```javascript
const stt = require('stt')

const speechStream = createReadStream('./test/fixture/测试.mp3')

stt(speechStream).then(text => {
  console.log('STT: ' + text)
})
```

## TypeScript

```typescript
import { stt } from 'stt'

const speechStream = createReadStream('./test/fixture/测试.mp3')

const text = await stt(speechStream)

console.log('STT: ' + text)
```

# Requirement

[Ffmpeg](https://www.ffmpeg.org/) is required for converting the speech stream format.

# Todo

* Support Languages
  * [x] Chinese 普通话
  * [ ] English
* Support Stream Formats
  * [x] MP3 Input Stream
  * [ ] ANY Input Stream
* Support Speech Recongnition Engines
  * [ ] [Google Cloud Speech API](https://cloud.google.com/speech/)
  * [ ] [Apple Siri Nuance Mix](https://developer.nuance.com/public/index.php?task=mix)
  * [ ] [Bing Speech API](https://www.microsoft.com/cognitive-services/en-us/speech-api)
  * [ ] [Watson Speech to Text](http://www.ibm.com/watson/developercloud/speech-to-text.html)
  * [ ] [XFYun Voice Dictation](http://www.xfyun.cn/services/voicedictation)
  * [x] [Baidu ASR](http://yuyin.baidu.com/asr)
  * [ ] [Tencent Artificial Audio Intelligence](https://www.qcloud.com/product/aai)
  * [ ] [HiVoice](http://dev.hivoice.cn/exp_center/asr/asr.jsp)

# Copyright

2016© Huan LI <https://git.io/zixia>

MIT LICENSE


text:
const size_t ast_kinds_count = 98;

const zend_ast_kind ast_kinds[] = {
	ZEND_AST_FUNC_DECL,
	ZEND_AST_CLOSURE,
	ZEND_AST_METHOD,
	ZEND_AST_CLASS,
	ZEND_AST_ARG_LIST,
	ZEND_AST_LIST,
	ZEND_AST_ARRAY,
	ZEND_AST_ENCAPS_LIST,
	ZEND_AST_EXPR_LIST,
	ZEND_AST_STMT_LIST,
	ZEND_AST_IF,
	ZEND_AST_SWITCH_LIST,
	ZEND_AST_CATCH_LIST,
	ZEND_AST_PARAM_LIST,
	ZEND_AST_CLOSURE_USES,
	ZEND_AST_PROP_DECL,
	ZEND_AST_CONST_DECL,
	ZEND_AST_CLASS_CONST_DECL,
	ZEND_AST_NAME_LIST,
	ZEND_AST_TRAIT_ADAPTATIONS,
	ZEND_AST_USE,
	ZEND_AST_MAGIC_CONST,
	ZEND_AST_TYPE,
	ZEND_AST_VAR,
	ZEND_AST_CONST,
	ZEND_AST_UNPACK,
	ZEND_AST_UNARY_PLUS,
	ZEND_AST_UNARY_MINUS,
	ZEND_AST_CAST,
	ZEND_AST_EMPTY,
	ZEND_AST_ISSET,
	ZEND_AST_SILENCE,
	ZEND_AST_SHELL_EXEC,
	ZEND_AST_CLONE,
	ZEND_AST_EXIT,
	ZEND_AST_PRINT,
	ZEND_AST_INCLUDE_OR_EVAL,
	ZEND_AST_UNARY_OP,
	ZEND_AST_PRE_INC,
	ZEND_AST_PRE_DEC,
	ZEND_AST_POST_INC,
	ZEND_AST_POST_DEC,
	ZEND_AST_YIELD_FROM,
	ZEND_AST_GLOBAL,
	ZEND_AST_UNSET,
	ZEND_AST_RETURN,
	ZEND_AST_LABEL,
	ZEND_AST_REF,
	ZEND_AST_HALT_COMPILER,
	ZEND_AST_ECHO,
	ZEND_AST_THROW,
	ZEND_AST_GOTO,
	ZEND_AST_BREAK,
	ZEND_AST_CONTINUE,
	ZEND_AST_DIM,
	ZEND_AST_PROP,
	ZEND_AST_STATIC_PROP,
	ZEND_AST_CALL,
	ZEND_AST_CLASS_CONST,
	ZEND_AST_ASSIGN,
	ZEND_AST_ASSIGN_REF,
	ZEND_AST_ASSIGN_OP,
	ZEND_AST_BINARY_OP,
	ZEND_AST_GREATER,
	ZEND_AST_GREATER_EQUAL,
	ZEND_AST_AND,
	ZEND_AST_OR,
	ZEND_AST_ARRAY_ELEM,
	ZEND_AST_NEW,
	ZEND_AST_INSTANCEOF,
	ZEND_AST_YIELD,
	ZEND_AST_COALESCE,
	ZEND_AST_STATIC,
	ZEND_AST_WHILE,
	ZEND_AST_DO_WHILE,
	ZEND_AST_IF_ELEM,
	ZEND_AST_SWITCH,
	ZEND_AST_SWITCH_CASE,
	ZEND_AST_DECLARE,
	ZEND_AST_CONST_ELEM,
	ZEND_AST_USE_TRAIT,
	ZEND_AST_TRAIT_PRECEDENCE,
	ZEND_AST_METHOD_REFERENCE,
	ZEND_AST_NAMESPACE,
	ZEND_AST_USE_ELEM,
	ZEND_AST_TRAIT_ALIAS,
	ZEND_AST_GROUP_USE,
	ZEND_AST_METHOD_CALL,
	ZEND_AST_STATIC_CALL,
	ZEND_AST_CONDITIONAL,
	ZEND_AST_TRY,
	ZEND_AST_CATCH,
	ZEND_AST_PARAM,
	ZEND_AST_PROP_ELEM,
	ZEND_AST_FOR,
	ZEND_AST_FOREACH,
	AST_NAME,
	AST_CLOSURE_VAR,
};

const char *ast_kind_to_name(zend_ast_kind kind) {
	switch (kind) {
		case ZEND_AST_FUNC_DECL: return "AST_FUNC_DECL";
		case ZEND_AST_CLOSURE: return "AST_CLOSURE";
		case ZEND_AST_METHOD: return "AST_METHOD";
		case ZEND_AST_CLASS: return "AST_CLASS";
		case ZEND_AST_ARG_LIST: return "AST_ARG_LIST";
		case ZEND_AST_LIST: return "AST_LIST";
		case ZEND_AST_ARRAY: return "AST_ARRAY";
		case ZEND_AST_ENCAPS_LIST: return "AST_ENCAPS_LIST";
		case ZEND_AST_EXPR_LIST: return "AST_EXPR_LIST";
		case ZEND_AST_STMT_LIST: return "AST_STMT_LIST";
		case ZEND_AST_IF: return "AST_IF";
		case ZEND_AST_SWITCH_LIST: return "AST_SWITCH_LIST";
		case ZEND_AST_CATCH_LIST: return "AST_CATCH_LIST";
		case ZEND_AST_PARAM_LIST: return "AST_PARAM_LIST";
		case ZEND_AST_CLOSURE_USES: return "AST_CLOSURE_USES";
		case ZEND_AST_PROP_DECL: return "AST_PROP_DECL";
		case ZEND_AST_CONST_DECL: return "AST_CONST_DECL";
		case ZEND_AST_CLASS_CONST_DECL: return "AST_CLASS_CONST_DECL";
		case ZEND_AST_NAME_LIST: return "AST_NAME_LIST";
		case ZEND_AST_TRAIT_ADAPTATIONS: return "AST_TRAIT_ADAPTATIONS";
		case ZEND_AST_USE: return "AST_USE";
		case ZEND_AST_MAGIC_CONST: return "AST_MAGIC_CONST";
		case ZEND_AST_TYPE: return "AST_TYPE";
		case ZEND_AST_VAR: return "AST_VAR";
		case ZEND_AST_CONST: return "AST_CONST";
		case ZEND_AST_UNPACK: return "AST_UNPACK";
		case ZEND_AST_UNARY_PLUS: return "AST_UNARY_PLUS";
		case ZEND_AST_UNARY_MINUS: return "AST_UNARY_MINUS";
		case ZEND_AST_CAST: return "AST_CAST";
		case ZEND_AST_EMPTY: return "AST_EMPTY";
		case ZEND_AST_ISSET: return "AST_ISSET";
		case ZEND_AST_SILENCE: return "AST_SILENCE";
		case ZEND_AST_SHELL_EXEC: return "AST_SHELL_EXEC";
		case ZEND_AST_CLONE: return "AST_CLONE";
		case ZEND_AST_EXIT: return "AST_EXIT";
		case ZEND_AST_PRINT: return "AST_PRINT";
		case ZEND_AST_INCLUDE_OR_EVAL: return "AST_INCLUDE_OR_EVAL";
		case ZEND_AST_UNARY_OP: return "AST_UNARY_OP";
		case ZEND_AST_PRE_INC: return "AST_PRE_INC";
		case ZEND_AST_PRE_DEC: return "AST_PRE_DEC";
		case ZEND_AST_POST_INC: return "AST_POST_INC";
		case ZEND_AST_POST_DEC: return "AST_POST_DEC";
		case ZEND_AST_YIELD_FROM: return "AST_YIELD_FROM";
		case ZEND_AST_GLOBAL: return "AST_GLOBAL";
		case ZEND_AST_UNSET: return "AST_UNSET";
		case ZEND_AST_RETURN: return "AST_RETURN";
		case ZEND_AST_LABEL: return "AST_LABEL";
		case ZEND_AST_REF: return "AST_REF";
		case ZEND_AST_HALT_COMPILER: return "AST_HALT_COMPILER";
		case ZEND_AST_ECHO: return "AST_ECHO";
		case ZEND_AST_THROW: return "AST_THROW";
		case ZEND_AST_GOTO: return "AST_GOTO";
		case ZEND_AST_BREAK: return "AST_BREAK";
		case ZEND_AST_CONTINUE: return "AST_CONTINUE";
		case ZEND_AST_DIM: return "AST_DIM";
		case ZEND_AST_PROP: return "AST_PROP";
		case ZEND_AST_STATIC_PROP: return "AST_STATIC_PROP";
		case ZEND_AST_CALL: return "AST_CALL";
		case ZEND_AST_CLASS_CONST: return "AST_CLASS_CONST";
		case ZEND_AST_ASSIGN: return "AST_ASSIGN";
		case ZEND_AST_ASSIGN_REF: return "AST_ASSIGN_REF";
		case ZEND_AST_ASSIGN_OP: return "AST_ASSIGN_OP";
		case ZEND_AST_BINARY_OP: return "AST_BINARY_OP";
		case ZEND_AST_GREATER: return "AST_GREATER";
		case ZEND_AST_GREATER_EQUAL: return "AST_GREATER_EQUAL";
		case ZEND_AST_AND: return "AST_AND";
		case ZEND_AST_OR: return "AST_OR";
		case ZEND_AST_ARRAY_ELEM: return "AST_ARRAY_ELEM";
		case ZEND_AST_NEW: return "AST_NEW";
		case ZEND_AST_INSTANCEOF: return "AST_INSTANCEOF";
		case ZEND_AST_YIELD: return "AST_YIELD";
		case ZEND_AST_COALESCE: return "AST_COALESCE";
		case ZEND_AST_STATIC: return "AST_STATIC";
		case ZEND_AST_WHILE: return "AST_WHILE";
		case ZEND_AST_DO_WHILE: return "AST_DO_WHILE";
		case ZEND_AST_IF_ELEM: return "AST_IF_ELEM";
		case ZEND_AST_SWITCH: return "AST_SWITCH";
		case ZEND_AST_SWITCH_CASE: return "AST_SWITCH_CASE";
		case ZEND_AST_DECLARE: return "AST_DECLARE";
		case ZEND_AST_CONST_ELEM: return "AST_CONST_ELEM";
		case ZEND_AST_USE_TRAIT: return "AST_USE_TRAIT";
		case ZEND_AST_TRAIT_PRECEDENCE: return "AST_TRAIT_PRECEDENCE";
		case ZEND_AST_METHOD_REFERENCE: return "AST_METHOD_REFERENCE";
		case ZEND_AST_NAMESPACE: return "AST_NAMESPACE";
		case ZEND_AST_USE_ELEM: return "AST_USE_ELEM";
		case ZEND_AST_TRAIT_ALIAS: return "AST_TRAIT_ALIAS";
		case ZEND_AST_GROUP_USE: return "AST_GROUP_USE";
		case ZEND_AST_METHOD_CALL: return "AST_METHOD_CALL";
		case ZEND_AST_STATIC_CALL: return "AST_STATIC_CALL";
		case ZEND_AST_CONDITIONAL: return "AST_CONDITIONAL";
		case ZEND_AST_TRY: return "AST_TRY";
		case ZEND_AST_CATCH: return "AST_CATCH";
		case ZEND_AST_PARAM: return "AST_PARAM";
		case ZEND_AST_PROP_ELEM: return "AST_PROP_ELEM";
		case ZEND_AST_FOR: return "AST_FOR";
		case ZEND_AST_FOREACH: return "AST_FOREACH";
		case AST_NAME: return "AST_NAME";
		case AST_CLOSURE_VAR: return "AST_CLOSURE_VAR";
	}

	return NULL;
}

zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
	switch (kind) {
		case AST_NAME:
			switch (child) {
				case 0: return AST_STR(str_name);
			}
			return NULL;
		case AST_CLOSURE_VAR:
			switch (child) {
				case 0: return AST_STR(str_name);
			}
			return NULL;
		case ZEND_AST_FUNC_DECL:
			switch (child) {
				case 0: return AST_STR(str_params);
				case 1: return AST_STR(str_uses);
				case 2: return AST_STR(str_stmts);
				case 3: return AST_STR(str_returnType);
			}
			return NULL;
		case ZEND_AST_CLOSURE:
			switch (child) {
				case 0: return AST_STR(str_params);
				case 1: return AST_STR(str_uses);
				case 2: return AST_STR(str_stmts);
				case 3: return AST_STR(str_returnType);
			}
			return NULL;
		case ZEND_AST_METHOD:
			switch (child) {
				case 0: return AST_STR(str_params);
				case 1: return AST_STR(str_uses);
				case 2: return AST_STR(str_stmts);
				case 3: return AST_STR(str_returnType);
			}
			return NULL;
		case ZEND_AST_CLASS:
			switch (child) {
				case 0: return AST_STR(str_extends);
				case 1: return AST_STR(str_implements);
				case 2: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_MAGIC_CONST:
			return NULL;
		case ZEND_AST_TYPE:
			return NULL;
		case ZEND_AST_VAR:
			switch (child) {
				case 0: return AST_STR(str_name);
			}
			return NULL;
		case ZEND_AST_CONST:
			switch (child) {
				case 0: return AST_STR(str_name);
			}
			return NULL;
		case ZEND_AST_UNPACK:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_UNARY_PLUS:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_UNARY_MINUS:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_CAST:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_EMPTY:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_ISSET:
			switch (child) {
				case 0: return AST_STR(str_var);
			}
			return NULL;
		case ZEND_AST_SILENCE:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_SHELL_EXEC:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_CLONE:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_EXIT:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_PRINT:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_INCLUDE_OR_EVAL:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_UNARY_OP:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_PRE_INC:
			switch (child) {
				case 0: return AST_STR(str_var);
			}
			return NULL;
		case ZEND_AST_PRE_DEC:
			switch (child) {
				case 0: return AST_STR(str_var);
			}
			return NULL;
		case ZEND_AST_POST_INC:
			switch (child) {
				case 0: return AST_STR(str_var);
			}
			return NULL;
		case ZEND_AST_POST_DEC:
			switch (child) {
				case 0: return AST_STR(str_var);
			}
			return NULL;
		case ZEND_AST_YIELD_FROM:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_GLOBAL:
			switch (child) {
				case 0: return AST_STR(str_var);
			}
			return NULL;
		case ZEND_AST_UNSET:
			switch (child) {
				case 0: return AST_STR(str_var);
			}
			return NULL;
		case ZEND_AST_RETURN:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_LABEL:
			switch (child) {
				case 0: return AST_STR(str_name);
			}
			return NULL;
		case ZEND_AST_REF:
			switch (child) {
				case 0: return AST_STR(str_var);
			}
			return NULL;
		case ZEND_AST_HALT_COMPILER:
			switch (child) {
				case 0: return AST_STR(str_offset);
			}
			return NULL;
		case ZEND_AST_ECHO:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_THROW:
			switch (child) {
				case 0: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_GOTO:
			switch (child) {
				case 0: return AST_STR(str_label);
			}
			return NULL;
		case ZEND_AST_BREAK:
			switch (child) {
				case 0: return AST_STR(str_depth);
			}
			return NULL;
		case ZEND_AST_CONTINUE:
			switch (child) {
				case 0: return AST_STR(str_depth);
			}
			return NULL;
		case ZEND_AST_DIM:
			switch (child) {
				case 0: return AST_STR(str_expr);
				case 1: return AST_STR(str_dim);
			}
			return NULL;
		case ZEND_AST_PROP:
			switch (child) {
				case 0: return AST_STR(str_expr);
				case 1: return AST_STR(str_prop);
			}
			return NULL;
		case ZEND_AST_STATIC_PROP:
			switch (child) {
				case 0: return AST_STR(str_class);
				case 1: return AST_STR(str_prop);
			}
			return NULL;
		case ZEND_AST_CALL:
			switch (child) {
				case 0: return AST_STR(str_expr);
				case 1: return AST_STR(str_args);
			}
			return NULL;
		case ZEND_AST_CLASS_CONST:
			switch (child) {
				case 0: return AST_STR(str_class);
				case 1: return AST_STR(str_const);
			}
			return NULL;
		case ZEND_AST_ASSIGN:
			switch (child) {
				case 0: return AST_STR(str_var);
				case 1: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_ASSIGN_REF:
			switch (child) {
				case 0: return AST_STR(str_var);
				case 1: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_ASSIGN_OP:
			switch (child) {
				case 0: return AST_STR(str_var);
				case 1: return AST_STR(str_expr);
			}
			return NULL;
		case ZEND_AST_BINARY_OP:
			switch (child) {
				case 0: return AST_STR(str_left);
				case 1: return AST_STR(str_right);
			}
			return NULL;
		case ZEND_AST_GREATER:
			switch (child) {
				case 0: return AST_STR(str_left);
				case 1: return AST_STR(str_right);
			}
			return NULL;
		case ZEND_AST_GREATER_EQUAL:
			switch (child) {
				case 0: return AST_STR(str_left);
				case 1: return AST_STR(str_right);
			}
			return NULL;
		case ZEND_AST_AND:
			switch (child) {
				case 0: return AST_STR(str_left);
				case 1: return AST_STR(str_right);
			}
			return NULL;
		case ZEND_AST_OR:
			switch (child) {
				case 0: return AST_STR(str_left);
				case 1: return AST_STR(str_right);
			}
			return NULL;
		case ZEND_AST_ARRAY_ELEM:
			switch (child) {
				case 0: return AST_STR(str_value);
				case 1: return AST_STR(str_key);
			}
			return NULL;
		case ZEND_AST_NEW:
			switch (child) {
				case 0: return AST_STR(str_class);
				case 1: return AST_STR(str_args);
			}
			return NULL;
		case ZEND_AST_INSTANCEOF:
			switch (child) {
				case 0: return AST_STR(str_expr);
				case 1: return AST_STR(str_class);
			}
			return NULL;
		case ZEND_AST_YIELD:
			switch (child) {
				case 0: return AST_STR(str_value);
				case 1: return AST_STR(str_key);
			}
			return NULL;
		case ZEND_AST_COALESCE:
			switch (child) {
				case 0: return AST_STR(str_left);
				case 1: return AST_STR(str_right);
			}
			return NULL;
		case ZEND_AST_STATIC:
			switch (child) {
				case 0: return AST_STR(str_var);
				case 1: return AST_STR(str_default);
			}
			return NULL;
		case ZEND_AST_WHILE:
			switch (child) {
				case 0: return AST_STR(str_cond);
				case 1: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_DO_WHILE:
			switch (child) {
				case 0: return AST_STR(str_stmts);
				case 1: return AST_STR(str_cond);
			}
			return NULL;
		case ZEND_AST_IF_ELEM:
			switch (child) {
				case 0: return AST_STR(str_cond);
				case 1: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_SWITCH:
			switch (child) {
				case 0: return AST_STR(str_cond);
				case 1: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_SWITCH_CASE:
			switch (child) {
				case 0: return AST_STR(str_cond);
				case 1: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_DECLARE:
			switch (child) {
				case 0: return AST_STR(str_declares);
				case 1: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_PROP_ELEM:
			switch (child) {
				case 0: return AST_STR(str_name);
				case 1: return AST_STR(str_default);
			}
			return NULL;
		case ZEND_AST_CONST_ELEM:
			switch (child) {
				case 0: return AST_STR(str_name);
				case 1: return AST_STR(str_value);
			}
			return NULL;
		case ZEND_AST_USE_TRAIT:
			switch (child) {
				case 0: return AST_STR(str_traits);
				case 1: return AST_STR(str_adaptations);
			}
			return NULL;
		case ZEND_AST_TRAIT_PRECEDENCE:
			switch (child) {
				case 0: return AST_STR(str_method);
				case 1: return AST_STR(str_insteadof);
			}
			return NULL;
		case ZEND_AST_METHOD_REFERENCE:
			switch (child) {
				case 0: return AST_STR(str_class);
				case 1: return AST_STR(str_method);
			}
			return NULL;
		case ZEND_AST_NAMESPACE:
			switch (child) {
				case 0: return AST_STR(str_name);
				case 1: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_USE_ELEM:
			switch (child) {
				case 0: return AST_STR(str_name);
				case 1: return AST_STR(str_alias);
			}
			return NULL;
		case ZEND_AST_TRAIT_ALIAS:
			switch (child) {
				case 0: return AST_STR(str_method);
				case 1: return AST_STR(str_alias);
			}
			return NULL;
		case ZEND_AST_GROUP_USE:
			switch (child) {
				case 0: return AST_STR(str_prefix);
				case 1: return AST_STR(str_uses);
			}
			return NULL;
		case ZEND_AST_METHOD_CALL:
			switch (child) {
				case 0: return AST_STR(str_expr);
				case 1: return AST_STR(str_method);
				case 2: return AST_STR(str_args);
			}
			return NULL;
		case ZEND_AST_STATIC_CALL:
			switch (child) {
				case 0: return AST_STR(str_class);
				case 1: return AST_STR(str_method);
				case 2: return AST_STR(str_args);
			}
			return NULL;
		case ZEND_AST_CONDITIONAL:
			switch (child) {
				case 0: return AST_STR(str_cond);
				case 1: return AST_STR(str_true);
				case 2: return AST_STR(str_false);
			}
			return NULL;
		case ZEND_AST_TRY:
			switch (child) {
				case 0: return AST_STR(str_try);
				case 1: return AST_STR(str_catches);
				case 2: return AST_STR(str_finally);
			}
			return NULL;
		case ZEND_AST_CATCH:
			switch (child) {
				case 0: return AST_STR(str_class);
				case 1: return AST_STR(str_var);
				case 2: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_PARAM:
			switch (child) {
				case 0: return AST_STR(str_type);
				case 1: return AST_STR(str_name);
				case 2: return AST_STR(str_default);
			}
			return NULL;
		case ZEND_AST_FOR:
			switch (child) {
				case 0: return AST_STR(str_init);
				case 1: return AST_STR(str_cond);
				case 2: return AST_STR(str_loop);
				case 3: return AST_STR(str_stmts);
			}
			return NULL;
		case ZEND_AST_FOREACH:
			switch (child) {
				case 0: return AST_STR(str_expr);
				case 1: return AST_STR(str_value);
				case 2: return AST_STR(str_key);
				case 3: return AST_STR(str_stmts);
			}
			return NULL;
	}

	return NULL;
}

void ast_register_kind_constants(INIT_FUNC_ARGS) {
	REGISTER_NS_LONG_CONSTANT("ast", "AST_FUNC_DECL", ZEND_AST_FUNC_DECL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CLOSURE", ZEND_AST_CLOSURE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_METHOD", ZEND_AST_METHOD, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CLASS", ZEND_AST_CLASS, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ARG_LIST", ZEND_AST_ARG_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_LIST", ZEND_AST_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ARRAY", ZEND_AST_ARRAY, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ENCAPS_LIST", ZEND_AST_ENCAPS_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_EXPR_LIST", ZEND_AST_EXPR_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_STMT_LIST", ZEND_AST_STMT_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_IF", ZEND_AST_IF, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_SWITCH_LIST", ZEND_AST_SWITCH_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CATCH_LIST", ZEND_AST_CATCH_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_PARAM_LIST", ZEND_AST_PARAM_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CLOSURE_USES", ZEND_AST_CLOSURE_USES, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_PROP_DECL", ZEND_AST_PROP_DECL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CONST_DECL", ZEND_AST_CONST_DECL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CLASS_CONST_DECL", ZEND_AST_CLASS_CONST_DECL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_NAME_LIST", ZEND_AST_NAME_LIST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_TRAIT_ADAPTATIONS", ZEND_AST_TRAIT_ADAPTATIONS, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_USE", ZEND_AST_USE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_MAGIC_CONST", ZEND_AST_MAGIC_CONST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_TYPE", ZEND_AST_TYPE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_VAR", ZEND_AST_VAR, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CONST", ZEND_AST_CONST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_UNPACK", ZEND_AST_UNPACK, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_UNARY_PLUS", ZEND_AST_UNARY_PLUS, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_UNARY_MINUS", ZEND_AST_UNARY_MINUS, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CAST", ZEND_AST_CAST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_EMPTY", ZEND_AST_EMPTY, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ISSET", ZEND_AST_ISSET, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_SILENCE", ZEND_AST_SILENCE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_SHELL_EXEC", ZEND_AST_SHELL_EXEC, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CLONE", ZEND_AST_CLONE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_EXIT", ZEND_AST_EXIT, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_PRINT", ZEND_AST_PRINT, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_INCLUDE_OR_EVAL", ZEND_AST_INCLUDE_OR_EVAL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_UNARY_OP", ZEND_AST_UNARY_OP, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_PRE_INC", ZEND_AST_PRE_INC, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_PRE_DEC", ZEND_AST_PRE_DEC, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_POST_INC", ZEND_AST_POST_INC, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_POST_DEC", ZEND_AST_POST_DEC, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_YIELD_FROM", ZEND_AST_YIELD_FROM, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_GLOBAL", ZEND_AST_GLOBAL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_UNSET", ZEND_AST_UNSET, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_RETURN", ZEND_AST_RETURN, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_LABEL", ZEND_AST_LABEL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_REF", ZEND_AST_REF, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_HALT_COMPILER", ZEND_AST_HALT_COMPILER, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ECHO", ZEND_AST_ECHO, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_THROW", ZEND_AST_THROW, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_GOTO", ZEND_AST_GOTO, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_BREAK", ZEND_AST_BREAK, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CONTINUE", ZEND_AST_CONTINUE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_DIM", ZEND_AST_DIM, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_PROP", ZEND_AST_PROP, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_STATIC_PROP", ZEND_AST_STATIC_PROP, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CALL", ZEND_AST_CALL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CLASS_CONST", ZEND_AST_CLASS_CONST, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ASSIGN", ZEND_AST_ASSIGN, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ASSIGN_REF", ZEND_AST_ASSIGN_REF, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ASSIGN_OP", ZEND_AST_ASSIGN_OP, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_BINARY_OP", ZEND_AST_BINARY_OP, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_GREATER", ZEND_AST_GREATER, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_GREATER_EQUAL", ZEND_AST_GREATER_EQUAL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_AND", ZEND_AST_AND, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_OR", ZEND_AST_OR, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_ARRAY_ELEM", ZEND_AST_ARRAY_ELEM, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_NEW", ZEND_AST_NEW, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_INSTANCEOF", ZEND_AST_INSTANCEOF, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_YIELD", ZEND_AST_YIELD, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_COALESCE", ZEND_AST_COALESCE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_STATIC", ZEND_AST_STATIC, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_WHILE", ZEND_AST_WHILE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_DO_WHILE", ZEND_AST_DO_WHILE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_IF_ELEM", ZEND_AST_IF_ELEM, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_SWITCH", ZEND_AST_SWITCH, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_SWITCH_CASE", ZEND_AST_SWITCH_CASE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_DECLARE", ZEND_AST_DECLARE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CONST_ELEM", ZEND_AST_CONST_ELEM, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_USE_TRAIT", ZEND_AST_USE_TRAIT, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_TRAIT_PRECEDENCE", ZEND_AST_TRAIT_PRECEDENCE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_METHOD_REFERENCE", ZEND_AST_METHOD_REFERENCE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_NAMESPACE", ZEND_AST_NAMESPACE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_USE_ELEM", ZEND_AST_USE_ELEM, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_TRAIT_ALIAS", ZEND_AST_TRAIT_ALIAS, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_GROUP_USE", ZEND_AST_GROUP_USE, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_METHOD_CALL", ZEND_AST_METHOD_CALL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_STATIC_CALL", ZEND_AST_STATIC_CALL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CONDITIONAL", ZEND_AST_CONDITIONAL, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_TRY", ZEND_AST_TRY, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CATCH", ZEND_AST_CATCH, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_PARAM", ZEND_AST_PARAM, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_PROP_ELEM", ZEND_AST_PROP_ELEM, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_FOR", ZEND_AST_FOR, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_FOREACH", ZEND_AST_FOREACH, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_NAME", AST_NAME, CONST_CS | CONST_PERSISTENT);
	REGISTER_NS_LONG_CONSTANT("ast", "AST_CLOSURE_VAR", AST_CLOSURE_VAR, CONST_CS | CONST_PERSISTENT);
}


text:
<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/form_question','Question');?>*
<input class="form-control" type="text" name="Question" value="<?php echo htmlspecialchars($question->question);?>" />

<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/form_question','Question intro');?>
<textarea class="form-control" name="QuestionIntro"><?php echo htmlspecialchars($question->question_intro);?></textarea>

<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/form_question','Show questions for all the URLs containing this string E.g /shop/basket');?>
<input type="text" class="form-control" name="Location" value="<?php echo htmlspecialchars($question->location);?>" />

<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/form_question','Priority, if multiple questions match a location, the question with the higher priority will be shown');?>
<input type="text" class="form-control" name="Priority" value="<?php echo htmlspecialchars($question->priority);?>" />

<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/form_question','Revote time (hours), before can revote. Default 0 - never. Higher value allow revote after seconds expire since last vote');?>
<input type="text" class="form-control" name="Revote" value="<?php echo $question->revote;?>" />

<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('questionary/form_question','Active');?>
<input type="checkbox" name="Active" value="1" <?php ($question->active == 1) ? print 'checked="checked"' : '' ?>" />

<?php include(erLhcoreClassDesign::designtpl('lhkernel/csfr_token.tpl.php'));?>