text:
/* image conversion */

#ifndef CONV_H
#define CONV_H

#include <climits>
#include "image.h"
#include "imutil.h"
#include "misc.h"

#define	RED_WEIGHT	0.299
#define GREEN_WEIGHT	0.587
#define BLUE_WEIGHT	0.114

static image<uchar> *imageRGBtoGRAY(image<rgb> *input) {
  int width = input->width();
  int height = input->height();
  image<uchar> *output = new image<uchar>(width, height, false);

  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      imRef(output, x, y) = (uchar)
	(imRef(input, x, y).r * RED_WEIGHT +
	 imRef(input, x, y).g * GREEN_WEIGHT +
	 imRef(input, x, y).b * BLUE_WEIGHT);
    }
  }
  return output;
}

static image<rgb> *imageGRAYtoRGB(image<uchar> *input) {
  int width = input->width();
  int height = input->height();
  image<rgb> *output = new image<rgb>(width, height, false);

  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      imRef(output, x, y).r = imRef(input, x, y);
      imRef(output, x, y).g = imRef(input, x, y);
      imRef(output, x, y).b = imRef(input, x, y);
    }
  }
  return output;
}

static image<float> *imageUCHARtoFLOAT(image<uchar> *input) {
  int width = input->width();
  int height = input->height();
  image<float> *output = new image<float>(width, height, false);

  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      imRef(output, x, y) = imRef(input, x, y);
    }
  }
  return output;
}

static image<float> *imageINTtoFLOAT(image<int> *input) {
  int width = input->width();
  int height = input->height();
  image<float> *output = new image<float>(width, height, false);

  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      imRef(output, x, y) = imRef(input, x, y);
    }
  }
  return output;
}

static image<uchar> *imageFLOATtoUCHAR(image<float> *input,
				       float min, float max) {
  int width = input->width();
  int height = input->height();
  image<uchar> *output = new image<uchar>(width, height, false);

  if (max == min)
    return output;

  float scale = UCHAR_MAX / (max - min);
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      uchar val = (uchar)((imRef(input, x, y) - min) * scale);
      imRef(output, x, y) = bound(val, (uchar)0, (uchar)UCHAR_MAX);
    }
  }
  return output;
}

static image<uchar> *imageFLOATtoUCHAR(image<float> *input) {
  float min, max;
  min_max(input, &min, &max);
  return imageFLOATtoUCHAR(input, min, max);
}

static image<long> *imageUCHARtoLONG(image<uchar> *input) {
  int width = input->width();
  int height = input->height();
  image<long> *output = new image<long>(width, height, false);

  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      imRef(output, x, y) = imRef(input, x, y);
    }
  }
  return output;
}

static image<uchar> *imageLONGtoUCHAR(image<long> *input, long min, long max) {
  int width = input->width();
  int height = input->height();
  image<uchar> *output = new image<uchar>(width, height, false);

  if (max == min)
    return output;

  float scale = UCHAR_MAX / (float)(max - min);
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      uchar val = (uchar)((imRef(input, x, y) - min) * scale);
      imRef(output, x, y) = bound(val, (uchar)0, (uchar)UCHAR_MAX);
    }
  }
  return output;
}

static image<uchar> *imageLONGtoUCHAR(image<long> *input) {
  long min, max;
  min_max(input, &min, &max);
  return imageLONGtoUCHAR(input, min, max);
}

static image<uchar> *imageSHORTtoUCHAR(image<short> *input,
					short min, short max) {
  int width = input->width();
  int height = input->height();
  image<uchar> *output = new image<uchar>(width, height, false);

  if (max == min)
    return output;

  float scale = UCHAR_MAX / (float)(max - min);
  for (int y = 0; y < height; y++) {
    for (int x = 0; x < width; x++) {
      uchar val = (uchar)((imRef(input, x, y) - min) * scale);
      imRef(output, x, y) = bound(val, (uchar)0, (uchar)UCHAR_MAX);
    }
  }
  return output;
}

static image<uchar> *imageSHORTtoUCHAR(image<short> *input) {
  short min, max;
  min_max(input, &min, &max);
  return imageSHORTtoUCHAR(input, min, max);
}

#endif


text:
<?php
$this->breadcrumbs=array(
	'Absensis'=>array('index'),
	$model->tanggal=>array('view','id'=>$model->tanggal),
	'Update',
);

$this->menu=array(
	array('label'=>'List Absensi','url'=>array('index')),
	array('label'=>'Create Absensi','url'=>array('create')),
	array('label'=>'View Absensi','url'=>array('view','id'=>$model->nis, 'id2'=>$model->tanggal, 'id3'=>$model->th_ajar, 'id4'=>$model->semester)),
	array('label'=>'Manage Absensi','url'=>array('admin')),
);
?>

<?php $box = $this->beginWidget('bootstrap.widgets.TbBox', array(
		'title' => 'PERBARUI PRESENSI SISWA',
		'headerIcon' => 'icon-th-list',
		'htmlOptions'=>array('class'=>'inline'),
		// when displaying a table, if we include bootstra-widget-table class
		// the table will be 0-padding to the box
	));?>

<?php echo $this->renderPartial('_formupdate', array('model'=>$model)); ?>
<?php $this->endWidget(); ?>

redpajama_set_name: RedPajamaGithub


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/datastore/v1/query.proto

package com.google.datastore.v1;

/**
 *

 * A batch of results produced by a query.
 *

 *
 * Protobuf type {@code google.datastore.v1.QueryResultBatch}
 */
public  final class QueryResultBatch extends
    com.google.protobuf.GeneratedMessageV3 implements
    // @@protoc_insertion_point(message_implements:google.datastore.v1.QueryResultBatch)
    QueryResultBatchOrBuilder {
  // Use QueryResultBatch.newBuilder() to construct.
  private QueryResultBatch(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }
  private QueryResultBatch() {
    skippedResults_ = 0;
    skippedCursor_ = com.google.protobuf.ByteString.EMPTY;
    entityResultType_ = 0;
    entityResults_ = java.util.Collections.emptyList();
    endCursor_ = com.google.protobuf.ByteString.EMPTY;
    moreResults_ = 0;
    snapshotVersion_ = 0L;
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet
  getUnknownFields() {
    return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
  }
  private QueryResultBatch(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    this();
    int mutable_bitField0_ = 0;
    try {
      boolean done = false;
      while (!done) {
        int tag = input.readTag();
        switch (tag) {
          case 0:
            done = true;
            break;
          default: {
            if (!input.skipField(tag)) {
              done = true;
            }
            break;
          }
          case 8: {
            int rawValue = input.readEnum();

            entityResultType_ = rawValue;
            break;
          }
          case 18: {
            if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
              entityResults_ = new java.util.ArrayList<com.google.datastore.v1.EntityResult>();
              mutable_bitField0_ |= 0x00000008;
            }
            entityResults_.add(
                input.readMessage(com.google.datastore.v1.EntityResult.parser(), extensionRegistry));
            break;
          }
          case 26: {

            skippedCursor_ = input.readBytes();
            break;
          }
          case 34: {

            endCursor_ = input.readBytes();
            break;
          }
          case 40: {
            int rawValue = input.readEnum();

            moreResults_ = rawValue;
            break;
          }
          case 48: {

            skippedResults_ = input.readInt32();
            break;
          }
          case 56: {

            snapshotVersion_ = input.readInt64();
            break;
          }
        }
      }
    } catch (com.google.protobuf.InvalidProtocolBufferException e) {
      throw e.setUnfinishedMessage(this);
    } catch (java.io.IOException e) {
      throw new com.google.protobuf.InvalidProtocolBufferException(
          e).setUnfinishedMessage(this);
    } finally {
      if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
        entityResults_ = java.util.Collections.unmodifiableList(entityResults_);
      }
      makeExtensionsImmutable();
    }
  }
  public static final com.google.protobuf.Descriptors.Descriptor
      getDescriptor() {
    return com.google.datastore.v1.QueryProto.internal_static_google_datastore_v1_QueryResultBatch_descriptor;
  }

  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.datastore.v1.QueryProto.internal_static_google_datastore_v1_QueryResultBatch_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.datastore.v1.QueryResultBatch.class, com.google.datastore.v1.QueryResultBatch.Builder.class);
  }

  /**
   *

   * The possible values for the `more_results` field.
   *

   *
   * Protobuf enum {@code google.datastore.v1.QueryResultBatch.MoreResultsType}
   */
  public enum MoreResultsType
      implements com.google.protobuf.ProtocolMessageEnum {
    /**
     *

     * Unspecified. This value is never used.
     *

     *
     * MORE_RESULTS_TYPE_UNSPECIFIED = 0;
     */
    MORE_RESULTS_TYPE_UNSPECIFIED(0),
    /**
     *

     * There may be additional batches to fetch from this query.
     *

     *
     * NOT_FINISHED = 1;
     */
    NOT_FINISHED(1),
    /**
     *

     * The query is finished, but there may be more results after the limit.
     *

     *
     * MORE_RESULTS_AFTER_LIMIT = 2;
     */
    MORE_RESULTS_AFTER_LIMIT(2),
    /**
     *

     * The query is finished, but there may be more results after the end
     * cursor.
     *

     *
     * MORE_RESULTS_AFTER_CURSOR = 4;
     */
    MORE_RESULTS_AFTER_CURSOR(4),
    /**
     *

     * The query has been exhausted.
     *

     *
     * NO_MORE_RESULTS = 3;
     */
    NO_MORE_RESULTS(3),
    UNRECOGNIZED(-1),
    ;

    /**
     *

     * Unspecified. This value is never used.
     *

     *
     * MORE_RESULTS_TYPE_UNSPECIFIED = 0;
     */
    public static final int MORE_RESULTS_TYPE_UNSPECIFIED_VALUE = 0;
    /**
     *

     * There may be additional batches to fetch from this query.
     *

     *
     * NOT_FINISHED = 1;
     */
    public static final int NOT_FINISHED_VALUE = 1;
    /**
     *

     * The query is finished, but there may be more results after the limit.
     *

     *
     * MORE_RESULTS_AFTER_LIMIT = 2;
     */
    public static final int MORE_RESULTS_AFTER_LIMIT_VALUE = 2;
    /**
     *

     * The query is finished, but there may be more results after the end
     * cursor.
     *

     *
     * MORE_RESULTS_AFTER_CURSOR = 4;
     */
    public static final int MORE_RESULTS_AFTER_CURSOR_VALUE = 4;
    /**
     *

     * The query has been exhausted.
     *

     *
     * NO_MORE_RESULTS = 3;
     */
    public static final int NO_MORE_RESULTS_VALUE = 3;

    public final int getNumber() {
      if (this == UNRECOGNIZED) {
        throw new java.lang.IllegalArgumentException(
            "Can't get the number of an unknown enum value.");
      }
      return value;
    }

    /**
     * @deprecated Use {@link #forNumber(int)} instead.
     */
    @java.lang.Deprecated
    public static MoreResultsType valueOf(int value) {
      return forNumber(value);
    }

    public static MoreResultsType forNumber(int value) {
      switch (value) {
        case 0: return MORE_RESULTS_TYPE_UNSPECIFIED;
        case 1: return NOT_FINISHED;
        case 2: return MORE_RESULTS_AFTER_LIMIT;
        case 4: return MORE_RESULTS_AFTER_CURSOR;
        case 3: return NO_MORE_RESULTS;
        default: return null;
      }
    }

    public static com.google.protobuf.Internal.EnumLiteMap<MoreResultsType>
        internalGetValueMap() {
      return internalValueMap;
    }
    private static final com.google.protobuf.Internal.EnumLiteMap<
        MoreResultsType> internalValueMap =
          new com.google.protobuf.Internal.EnumLiteMap<MoreResultsType>() {
            public MoreResultsType findValueByNumber(int number) {
              return MoreResultsType.forNumber(number);
            }
          };

    public final com.google.protobuf.Descriptors.EnumValueDescriptor
        getValueDescriptor() {
      return getDescriptor().getValues().get(ordinal());
    }
    public final com.google.protobuf.Descriptors.EnumDescriptor
        getDescriptorForType() {
      return getDescriptor();
    }
    public static final com.google.protobuf.Descriptors.EnumDescriptor
        getDescriptor() {
      return com.google.datastore.v1.QueryResultBatch.getDescriptor().getEnumTypes().get(0);
    }

    private static final MoreResultsType[] VALUES = values();

    public static MoreResultsType valueOf(
        com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
      if (desc.getType() != getDescriptor()) {
        throw new java.lang.IllegalArgumentException(
          "EnumValueDescriptor is not for this type.");
      }
      if (desc.getIndex() == -1) {
        return UNRECOGNIZED;
      }
      return VALUES[desc.getIndex()];
    }

    private final int value;

    private MoreResultsType(int value) {
      this.value = value;
    }

    // @@protoc_insertion_point(enum_scope:google.datastore.v1.QueryResultBatch.MoreResultsType)
  }

  private int bitField0_;
  public static final int SKIPPED_RESULTS_FIELD_NUMBER = 6;
  private int skippedResults_;
  /**
   *

   * The number of results skipped, typically because of an offset.
   *

   *
   * optional int32 skipped_results = 6;
   */
  public int getSkippedResults() {
    return skippedResults_;
  }

  public static final int SKIPPED_CURSOR_FIELD_NUMBER = 3;
  private com.google.protobuf.ByteString skippedCursor_;
  /**
   *

   * A cursor that points to the position after the last skipped result.
   * Will be set when `skipped_results` != 0.
   *

   *
   * optional bytes skipped_cursor = 3;
   */
  public com.google.protobuf.ByteString getSkippedCursor() {
    return skippedCursor_;
  }

  public static final int ENTITY_RESULT_TYPE_FIELD_NUMBER = 1;
  private int entityResultType_;
  /**
   *

   * The result type for every entity in `entity_results`.
   *

   *
   * optional .google.datastore.v1.EntityResult.ResultType entity_result_type = 1;
   */
  public int getEntityResultTypeValue() {
    return entityResultType_;
  }
  /**
   *

   * The result type for every entity in `entity_results`.
   *

   *
   * optional .google.datastore.v1.EntityResult.ResultType entity_result_type = 1;
   */
  public com.google.datastore.v1.EntityResult.ResultType getEntityResultType() {
    com.google.datastore.v1.EntityResult.ResultType result = com.google.datastore.v1.EntityResult.ResultType.valueOf(entityResultType_);
    return result == null ? com.google.datastore.v1.EntityResult.ResultType.UNRECOGNIZED : result;
  }

  public static final int ENTITY_RESULTS_FIELD_NUMBER = 2;
  private java.util.List<com.google.datastore.v1.EntityResult> entityResults_;
  /**
   *

   * The results for this batch.
   *

   *
   * repeated .google.datastore.v1.EntityResult entity_results = 2;
   */
  public java.util.List<com.google.datastore.v1.EntityResult> getEntityResultsList() {
    return entityResults_;
  }
  /**
   *

   * The results for this batch.
   *

   *
   * repeated .google.datastore.v1.EntityResult entity_results = 2;
   */
  public java.util.List<? extends com.google.datastore.v1.EntityResultOrBuilder>
      getEntityResultsOrBuilderList() {
    return entityResults_;
  }
  /**
   *

   * The results for this batch.
   *

   *
   * repeated .google.datastore.v1.EntityResult entity_results = 2;
   */
  public int getEntityResultsCount() {
    return entityResults_.size();
  }
  /**
   *

   * The results for this batch.
   *

   *
   * repeated .google.datastore.v1.EntityResult entity_results = 2;
   */
  public com.google.datastore.v1.EntityResult getEntityResults(int index) {
    return entityResults_.get(index);
  }
  /**
   *

   * The results for this batch.
   *

   *
   * repeated .google.datastore.v1.EntityResult entity_results = 2;
   */
  public com.google.datastore.v1.EntityResultOrBuilder getEntityResultsOrBuilder(
      int index) {
    return entityResults_.get(index);
  }

  public static final int END_CURSOR_FIELD_NUMBER = 4;
  private com.google.protobuf.ByteString endCursor_;
  /**
   *

   * A cursor that points to the position after the last result in the batch.
   *

   *
   * optional bytes end_cursor = 4;
   */
  public com.google.protobuf.ByteString getEndCursor() {
    return endCursor_;
  }

  public static final int MORE_RESULTS_FIELD_NUMBER = 5;
  private int moreResults_;
  /**
   *

   * The state of the query after the current batch.
   *

   *
   * optional .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5;
   */
  public int getMoreResultsValue() {
    return moreResults_;
  }
  /**
   *

   * The state of the query after the current batch.
   *

   *
   * optional .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5;
   */
  public com.google.datastore.v1.QueryResultBatch.MoreResultsType getMoreResults() {
    com.google.datastore.v1.QueryResultBatch.MoreResultsType result = com.google.datastore.v1.QueryResultBatch.MoreResultsType.valueOf(moreResults_);
    return result == null ? com.google.datastore.v1.QueryResultBatch.MoreResultsType.UNRECOGNIZED : result;
  }

  public static final int SNAPSHOT_VERSION_FIELD_NUMBER = 7;
  private long snapshotVersion_;
  /**
   *

   * The version number of the snapshot this batch was returned from.
   * This applies to the range of results from the query's `start_cursor` (or
   * the beginning of the query if no cursor was given) to this batch's
   * `end_cursor` (not the query's `end_cursor`).
   * In a single transaction, subsequent query result batches for the same query
   * can have a greater snapshot version number. Each batch's snapshot version
   * is valid for all preceding batches.
   * The value will be zero for eventually consistent queries.
   *

   *
   * optional int64 snapshot_version = 7;
   */
  public long getSnapshotVersion() {
    return snapshotVersion_;
  }

  private byte memoizedIsInitialized = -1;
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  public void writeTo(com.google.protobuf.CodedOutputStream output)
                      throws java.io.IOException {
    if (entityResultType_ != com.google.datastore.v1.EntityResult.ResultType.RESULT_TYPE_UNSPECIFIED.getNumber()) {
      output.writeEnum(1, entityResultType_);
    }
    for (int i = 0; i < entityResults_.size(); i++) {
      output.writeMessage(2, entityResults_.get(i));
    }
    if (!skippedCursor_.isEmpty()) {
      output.writeBytes(3, skippedCursor_);
    }
    if (!endCursor_.isEmpty()) {
      output.writeBytes(4, endCursor_);
    }
    if (moreResults_ != com.google.datastore.v1.QueryResultBatch.MoreResultsType.MORE_RESULTS_TYPE_UNSPECIFIED.getNumber()) {
      output.writeEnum(5, moreResults_);
    }
    if (skippedResults_ != 0) {
      output.writeInt32(6, skippedResults_);
    }
    if (snapshotVersion_ != 0L) {
      output.writeInt64(7, snapshotVersion_);
    }
  }

  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (entityResultType_ != com.google.datastore.v1.EntityResult.ResultType.RESULT_TYPE_UNSPECIFIED.getNumber()) {
      size += com.google.protobuf.CodedOutputStream
        .computeEnumSize(1, entityResultType_);
    }
    for (int i = 0; i < entityResults_.size(); i++) {
      size += com.google.protobuf.CodedOutputStream
        .computeMessageSize(2, entityResults_.get(i));
    }
    if (!skippedCursor_.isEmpty()) {
      size += com.google.protobuf.CodedOutputStream
        .computeBytesSize(3, skippedCursor_);
    }
    if (!endCursor_.isEmpty()) {
      size += com.google.protobuf.CodedOutputStream
        .computeBytesSize(4, endCursor_);
    }
    if (moreResults_ != com.google.datastore.v1.QueryResultBatch.MoreResultsType.MORE_RESULTS_TYPE_UNSPECIFIED.getNumber()) {
      size += com.google.protobuf.CodedOutputStream
        .computeEnumSize(5, moreResults_);
    }
    if (skippedResults_ != 0) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt32Size(6, skippedResults_);
    }
    if (snapshotVersion_ != 0L) {
      size += com.google.protobuf.CodedOutputStream
        .computeInt64Size(7, snapshotVersion_);
    }
    memoizedSize = size;
    return size;
  }

  private static final long serialVersionUID = 0L;
  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
     return true;
    }
    if (!(obj instanceof com.google.datastore.v1.QueryResultBatch)) {
      return super.equals(obj);
    }
    com.google.datastore.v1.QueryResultBatch other = (com.google.datastore.v1.QueryResultBatch) obj;

    boolean result = true;
    result = result && (getSkippedResults()
        == other.getSkippedResults());
    result = result && getSkippedCursor()
        .equals(other.getSkippedCursor());
    result = result && entityResultType_ == other.entityResultType_;
    result = result && getEntityResultsList()
        .equals(other.getEntityResultsList());
    result = result && getEndCursor()
        .equals(other.getEndCursor());
    result = result && moreResults_ == other.moreResults_;
    result = result && (getSnapshotVersion()
        == other.getSnapshotVersion());
    return result;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptorForType().hashCode();
    hash = (37 * hash) + SKIPPED_RESULTS_FIELD_NUMBER;
    hash = (53 * hash) + getSkippedResults();
    hash = (37 * hash) + SKIPPED_CURSOR_FIELD_NUMBER;
    hash = (53 * hash) + getSkippedCursor().hashCode();
    hash = (37 * hash) + ENTITY_RESULT_TYPE_FIELD_NUMBER;
    hash = (53 * hash) + entityResultType_;
    if (getEntityResultsCount() > 0) {
      hash = (37 * hash) + ENTITY_RESULTS_FIELD_NUMBER;
      hash = (53 * hash) + getEntityResultsList().hashCode();
    }
    hash = (37 * hash) + END_CURSOR_FIELD_NUMBER;
    hash = (53 * hash) + getEndCursor().hashCode();
    hash = (37 * hash) + MORE_RESULTS_FIELD_NUMBER;
    hash = (53 * hash) + moreResults_;
    hash = (37 * hash) + SNAPSHOT_VERSION_FIELD_NUMBER;
    hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
        getSnapshotVersion());
    hash = (29 * hash) + unknownFields.hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.datastore.v1.QueryResultBatch parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.datastore.v1.QueryResultBatch parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.datastore.v1.QueryResultBatch parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }
  public static com.google.datastore.v1.QueryResultBatch parseFrom(
      byte[] data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }
  public static com.google.datastore.v1.QueryResultBatch parseFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.datastore.v1.QueryResultBatch parseFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.google.datastore.v1.QueryResultBatch parseDelimitedFrom(java.io.InputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input);
  }
  public static com.google.datastore.v1.QueryResultBatch parseDelimitedFrom(
      java.io.InputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
  }
  public static com.google.datastore.v1.QueryResultBatch parseFrom(
      com.google.protobuf.CodedInputStream input)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input);
  }
  public static com.google.datastore.v1.QueryResultBatch parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3
        .parseWithIOException(PARSER, input, extensionRegistry);
  }

  public Builder newBuilderForType() { return newBuilder(); }
  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }
  public static Builder newBuilder(com.google.datastore.v1.QueryResultBatch prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE
        ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(
      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   *

   * A batch of results produced by a query.
   *

   *
   * Protobuf type {@code google.datastore.v1.QueryResultBatch}
   */
  public static final class Builder extends
      com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
      // @@protoc_insertion_point(builder_implements:google.datastore.v1.QueryResultBatch)
      com.google.datastore.v1.QueryResultBatchOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return com.google.datastore.v1.QueryProto.internal_static_google_datastore_v1_QueryResultBatch_descriptor;
    }

    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.datastore.v1.QueryProto.internal_static_google_datastore_v1_QueryResultBatch_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.datastore.v1.QueryResultBatch.class, com.google.datastore.v1.QueryResultBatch.Builder.class);
    }

    // Construct using com.google.datastore.v1.QueryResultBatch.newBuilder()
    private Builder() {
      maybeForceBuilderInitialization();
    }

    private Builder(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
      maybeForceBuilderInitialization();
    }
    private void maybeForceBuilderInitialization() {
      if (com.google.protobuf.GeneratedMessageV3
              .alwaysUseFieldBuilders) {
        getEntityResultsFieldBuilder();
      }
    }
    public Builder clear() {
      super.clear();
      skippedResults_ = 0;

      skippedCursor_ = com.google.protobuf.ByteString.EMPTY;

      entityResultType_ = 0;

      if (entityResultsBuilder_ == null) {
        entityResults_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000008);
      } else {
        entityResultsBuilder_.clear();
      }
      endCursor_ = com.google.protobuf.ByteString.EMPTY;

      moreResults_ = 0;

      snapshotVersion_ = 0L;

      return this;
    }

    public com.google.protobuf.Descriptors.Descriptor
        getDescriptorForType() {
      return com.google.datastore.v1.QueryProto.internal_static_google_datastore_v1_QueryResultBatch_descriptor;
    }

    public com.google.datastore.v1.QueryResultBatch getDefaultInstanceForType() {
      return com.google.datastore.v1.QueryResultBatch.getDefaultInstance();
    }

    public com.google.datastore.v1.QueryResultBatch build() {
      com.google.datastore.v1.QueryResultBatch result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    public com.google.datastore.v1.QueryResultBatch buildPartial() {
      com.google.datastore.v1.QueryResultBatch result = new com.google.datastore.v1.QueryResultBatch(this);
      int from_bitField0_ = bitField0_;
      int to_bitField0_ = 0;
      result.skippedResults_ = skippedResults_;
      result.skippedCursor_ = skippedCursor_;
      result.entityResultType_ = entityResultType_;
      if (entityResultsBuilder_ == null) {
        if (((bitField0_ & 0x00000008) == 0x00000008)) {
          entityResults_ = java.util.Collections.unmodifiableList(entityResults_);
          bitField0_ = (bitField0_ & ~0x00000008);
        }
        result.entityResults_ = entityResults_;
      } else {
        result.entityResults_ = entityResultsBuilder_.build();
      }
      result.endCursor_ = endCursor_;
      result.moreResults_ = moreResults_;
      result.snapshotVersion_ = snapshotVersion_;
      result.bitField0_ = to_bitField0_;
      onBuilt();
      return result;
    }

    public Builder clone() {
      return (Builder) super.clone();
    }
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        Object value) {
      return (Builder) super.setField(field, value);
    }
    public Builder clearField(
        com.google.protobuf.Descriptors.FieldDescriptor field) {
      return (Builder) super.clearField(field);
    }
    public Builder clearOneof(
        com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return (Builder) super.clearOneof(oneof);
    }
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        int index, Object value) {
      return (Builder) super.setRepeatedField(field, index, value);
    }
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field,
        Object value) {
      return (Builder) super.addRepeatedField(field, value);
    }
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.datastore.v1.QueryResultBatch) {
        return mergeFrom((com.google.datastore.v1.QueryResultBatch)other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.datastore.v1.QueryResultBatch other) {
      if (other == com.google.datastore.v1.QueryResultBatch.getDefaultInstance()) return this;
      if (other.getSkippedResults() != 0) {
        setSkippedResults(other.getSkippedResults());
      }
      if (other.getSkippedCursor() != com.google.protobuf.ByteString.EMPTY) {
        setSkippedCursor(other.getSkippedCursor());
      }
      if (other.entityResultType_ != 0) {
        setEntityResultTypeValue(other.getEntityResultTypeValue());
      }
      if (entityResultsBuilder_ == null) {
        if (!other.entityResults_.isEmpty()) {
          if (entityResults_.isEmpty()) {
            entityResults_ = other.entityResults_;
            bitField0_ = (bitField0_ & ~0x00000008);
          } else {
            ensureEntityResultsIsMutable();
            entityResults_.addAll(other.entityResults_);
          }
          onChanged();
        }
      } else {
        if (!other.entityResults_.isEmpty()) {
          if (entityResultsBuilder_.isEmpty()) {
            entityResultsBuilder_.dispose();
            entityResultsBuilder_ = null;
            entityResults_ = other.entityResults_;
            bitField0_ = (bitField0_ & ~0x00000008);
            entityResultsBuilder_ =
              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
                 getEntityResultsFieldBuilder() : null;
          } else {
            entityResultsBuilder_.addAllMessages(other.entityResults_);
          }
        }
      }
      if (other.getEndCursor() != com.google.protobuf.ByteString.EMPTY) {
        setEndCursor(other.getEndCursor());
      }
      if (other.moreResults_ != 0) {
        setMoreResultsValue(other.getMoreResultsValue());
      }
      if (other.getSnapshotVersion() != 0L) {
        setSnapshotVersion(other.getSnapshotVersion());
      }
      onChanged();
      return this;
    }

    public final boolean isInitialized() {
      return true;
    }

    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      com.google.datastore.v1.QueryResultBatch parsedMessage = null;
      try {
        parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        parsedMessage = (com.google.datastore.v1.QueryResultBatch) e.getUnfinishedMessage();
        throw e.unwrapIOException();
      } finally {
        if (parsedMessage != null) {
          mergeFrom(parsedMessage);
        }
      }
      return this;
    }
    private int bitField0_;

    private int skippedResults_ ;
    /**
     *

     * The number of results skipped, typically because of an offset.
     *

     *
     * optional int32 skipped_results = 6;
     */
    public int getSkippedResults() {
      return skippedResults_;
    }
    /**
     *

     * The number of results skipped, typically because of an offset.
     *

     *
     * optional int32 skipped_results = 6;
     */
    public Builder setSkippedResults(int value) {

      skippedResults_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * The number of results skipped, typically because of an offset.
     *

     *
     * optional int32 skipped_results = 6;
     */
    public Builder clearSkippedResults() {

      skippedResults_ = 0;
      onChanged();
      return this;
    }

    private com.google.protobuf.ByteString skippedCursor_ = com.google.protobuf.ByteString.EMPTY;
    /**
     *

     * A cursor that points to the position after the last skipped result.
     * Will be set when `skipped_results` != 0.
     *

     *
     * optional bytes skipped_cursor = 3;
     */
    public com.google.protobuf.ByteString getSkippedCursor() {
      return skippedCursor_;
    }
    /**
     *

     * A cursor that points to the position after the last skipped result.
     * Will be set when `skipped_results` != 0.
     *

     *
     * optional bytes skipped_cursor = 3;
     */
    public Builder setSkippedCursor(com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }

      skippedCursor_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * A cursor that points to the position after the last skipped result.
     * Will be set when `skipped_results` != 0.
     *

     *
     * optional bytes skipped_cursor = 3;
     */
    public Builder clearSkippedCursor() {

      skippedCursor_ = getDefaultInstance().getSkippedCursor();
      onChanged();
      return this;
    }

    private int entityResultType_ = 0;
    /**
     *

     * The result type for every entity in `entity_results`.
     *

     *
     * optional .google.datastore.v1.EntityResult.ResultType entity_result_type = 1;
     */
    public int getEntityResultTypeValue() {
      return entityResultType_;
    }
    /**
     *

     * The result type for every entity in `entity_results`.
     *

     *
     * optional .google.datastore.v1.EntityResult.ResultType entity_result_type = 1;
     */
    public Builder setEntityResultTypeValue(int value) {
      entityResultType_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * The result type for every entity in `entity_results`.
     *

     *
     * optional .google.datastore.v1.EntityResult.ResultType entity_result_type = 1;
     */
    public com.google.datastore.v1.EntityResult.ResultType getEntityResultType() {
      com.google.datastore.v1.EntityResult.ResultType result = com.google.datastore.v1.EntityResult.ResultType.valueOf(entityResultType_);
      return result == null ? com.google.datastore.v1.EntityResult.ResultType.UNRECOGNIZED : result;
    }
    /**
     *

     * The result type for every entity in `entity_results`.
     *

     *
     * optional .google.datastore.v1.EntityResult.ResultType entity_result_type = 1;
     */
    public Builder setEntityResultType(com.google.datastore.v1.EntityResult.ResultType value) {
      if (value == null) {
        throw new NullPointerException();
      }

      entityResultType_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     *

     * The result type for every entity in `entity_results`.
     *

     *
     * optional .google.datastore.v1.EntityResult.ResultType entity_result_type = 1;
     */
    public Builder clearEntityResultType() {

      entityResultType_ = 0;
      onChanged();
      return this;
    }

    private java.util.List<com.google.datastore.v1.EntityResult> entityResults_ =
      java.util.Collections.emptyList();
    private void ensureEntityResultsIsMutable() {
      if (!((bitField0_ & 0x00000008) == 0x00000008)) {
        entityResults_ = new java.util.ArrayList<com.google.datastore.v1.EntityResult>(entityResults_);
        bitField0_ |= 0x00000008;
       }
    }

    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.datastore.v1.EntityResult, com.google.datastore.v1.EntityResult.Builder, com.google.datastore.v1.EntityResultOrBuilder> entityResultsBuilder_;

    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public java.util.List<com.google.datastore.v1.EntityResult> getEntityResultsList() {
      if (entityResultsBuilder_ == null) {
        return java.util.Collections.unmodifiableList(entityResults_);
      } else {
        return entityResultsBuilder_.getMessageList();
      }
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public int getEntityResultsCount() {
      if (entityResultsBuilder_ == null) {
        return entityResults_.size();
      } else {
        return entityResultsBuilder_.getCount();
      }
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public com.google.datastore.v1.EntityResult getEntityResults(int index) {
      if (entityResultsBuilder_ == null) {
        return entityResults_.get(index);
      } else {
        return entityResultsBuilder_.getMessage(index);
      }
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder setEntityResults(
        int index, com.google.datastore.v1.EntityResult value) {
      if (entityResultsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureEntityResultsIsMutable();
        entityResults_.set(index, value);
        onChanged();
      } else {
        entityResultsBuilder_.setMessage(index, value);
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder setEntityResults(
        int index, com.google.datastore.v1.EntityResult.Builder builderForValue) {
      if (entityResultsBuilder_ == null) {
        ensureEntityResultsIsMutable();
        entityResults_.set(index, builderForValue.build());
        onChanged();
      } else {
        entityResultsBuilder_.setMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder addEntityResults(com.google.datastore.v1.EntityResult value) {
      if (entityResultsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureEntityResultsIsMutable();
        entityResults_.add(value);
        onChanged();
      } else {
        entityResultsBuilder_.addMessage(value);
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder addEntityResults(
        int index, com.google.datastore.v1.EntityResult value) {
      if (entityResultsBuilder_ == null) {
        if (value == null) {
          throw new NullPointerException();
        }
        ensureEntityResultsIsMutable();
        entityResults_.add(index, value);
        onChanged();
      } else {
        entityResultsBuilder_.addMessage(index, value);
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder addEntityResults(
        com.google.datastore.v1.EntityResult.Builder builderForValue) {
      if (entityResultsBuilder_ == null) {
        ensureEntityResultsIsMutable();
        entityResults_.add(builderForValue.build());
        onChanged();
      } else {
        entityResultsBuilder_.addMessage(builderForValue.build());
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder addEntityResults(
        int index, com.google.datastore.v1.EntityResult.Builder builderForValue) {
      if (entityResultsBuilder_ == null) {
        ensureEntityResultsIsMutable();
        entityResults_.add(index, builderForValue.build());
        onChanged();
      } else {
        entityResultsBuilder_.addMessage(index, builderForValue.build());
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder addAllEntityResults(
        java.lang.Iterable<? extends com.google.datastore.v1.EntityResult> values) {
      if (entityResultsBuilder_ == null) {
        ensureEntityResultsIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, entityResults_);
        onChanged();
      } else {
        entityResultsBuilder_.addAllMessages(values);
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder clearEntityResults() {
      if (entityResultsBuilder_ == null) {
        entityResults_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000008);
        onChanged();
      } else {
        entityResultsBuilder_.clear();
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public Builder removeEntityResults(int index) {
      if (entityResultsBuilder_ == null) {
        ensureEntityResultsIsMutable();
        entityResults_.remove(index);
        onChanged();
      } else {
        entityResultsBuilder_.remove(index);
      }
      return this;
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public com.google.datastore.v1.EntityResult.Builder getEntityResultsBuilder(
        int index) {
      return getEntityResultsFieldBuilder().getBuilder(index);
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public com.google.datastore.v1.EntityResultOrBuilder getEntityResultsOrBuilder(
        int index) {
      if (entityResultsBuilder_ == null) {
        return entityResults_.get(index);  } else {
        return entityResultsBuilder_.getMessageOrBuilder(index);
      }
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public java.util.List<? extends com.google.datastore.v1.EntityResultOrBuilder>
         getEntityResultsOrBuilderList() {
      if (entityResultsBuilder_ != null) {
        return entityResultsBuilder_.getMessageOrBuilderList();
      } else {
        return java.util.Collections.unmodifiableList(entityResults_);
      }
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public com.google.datastore.v1.EntityResult.Builder addEntityResultsBuilder() {
      return getEntityResultsFieldBuilder().addBuilder(
          com.google.datastore.v1.EntityResult.getDefaultInstance());
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public com.google.datastore.v1.EntityResult.Builder addEntityResultsBuilder(
        int index) {
      return getEntityResultsFieldBuilder().addBuilder(
          index, com.google.datastore.v1.EntityResult.getDefaultInstance());
    }
    /**
     *

     * The results for this batch.
     *

     *
     * repeated .google.datastore.v1.EntityResult entity_results = 2;
     */
    public java.util.List<com.google.datastore.v1.EntityResult.Builder>
         getEntityResultsBuilderList() {
      return getEntityResultsFieldBuilder().getBuilderList();
    }
    private com.google.protobuf.RepeatedFieldBuilderV3<
        com.google.datastore.v1.EntityResult, com.google.datastore.v1.EntityResult.Builder, com.google.datastore.v1.EntityResultOrBuilder>
        getEntityResultsFieldBuilder() {
      if (entityResultsBuilder_ == null) {
        entityResultsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
            com.google.datastore.v1.EntityResult, com.google.datastore.v1.EntityResult.Builder, com.google.datastore.v1.EntityResultOrBuilder>(
                entityResults_,
                ((bitField0_ & 0x00000008) == 0x00000008),
                getParentForChildren(),
                isClean());
        entityResults_ = null;
      }
      return entityResultsBuilder_;
    }

    private com.google.protobuf.ByteString endCursor_ = com.google.protobuf.ByteString.EMPTY;
    /**
     *

     * A cursor that points to the position after the last result in the batch.
     *

     *
     * optional bytes end_cursor = 4;
     */
    public com.google.protobuf.ByteString getEndCursor() {
      return endCursor_;
    }
    /**
     *

     * A cursor that points to the position after the last result in the batch.
     *

     *
     * optional bytes end_cursor = 4;
     */
    public Builder setEndCursor(com.google.protobuf.ByteString value) {
      if (value == null) {
    throw new NullPointerException();
  }

      endCursor_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * A cursor that points to the position after the last result in the batch.
     *

     *
     * optional bytes end_cursor = 4;
     */
    public Builder clearEndCursor() {

      endCursor_ = getDefaultInstance().getEndCursor();
      onChanged();
      return this;
    }

    private int moreResults_ = 0;
    /**
     *

     * The state of the query after the current batch.
     *

     *
     * optional .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5;
     */
    public int getMoreResultsValue() {
      return moreResults_;
    }
    /**
     *

     * The state of the query after the current batch.
     *

     *
     * optional .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5;
     */
    public Builder setMoreResultsValue(int value) {
      moreResults_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * The state of the query after the current batch.
     *

     *
     * optional .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5;
     */
    public com.google.datastore.v1.QueryResultBatch.MoreResultsType getMoreResults() {
      com.google.datastore.v1.QueryResultBatch.MoreResultsType result = com.google.datastore.v1.QueryResultBatch.MoreResultsType.valueOf(moreResults_);
      return result == null ? com.google.datastore.v1.QueryResultBatch.MoreResultsType.UNRECOGNIZED : result;
    }
    /**
     *

     * The state of the query after the current batch.
     *

     *
     * optional .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5;
     */
    public Builder setMoreResults(com.google.datastore.v1.QueryResultBatch.MoreResultsType value) {
      if (value == null) {
        throw new NullPointerException();
      }

      moreResults_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     *

     * The state of the query after the current batch.
     *

     *
     * optional .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5;
     */
    public Builder clearMoreResults() {

      moreResults_ = 0;
      onChanged();
      return this;
    }

    private long snapshotVersion_ ;
    /**
     *

     * The version number of the snapshot this batch was returned from.
     * This applies to the range of results from the query's `start_cursor` (or
     * the beginning of the query if no cursor was given) to this batch's
     * `end_cursor` (not the query's `end_cursor`).
     * In a single transaction, subsequent query result batches for the same query
     * can have a greater snapshot version number. Each batch's snapshot version
     * is valid for all preceding batches.
     * The value will be zero for eventually consistent queries.
     *

     *
     * optional int64 snapshot_version = 7;
     */
    public long getSnapshotVersion() {
      return snapshotVersion_;
    }
    /**
     *

     * The version number of the snapshot this batch was returned from.
     * This applies to the range of results from the query's `start_cursor` (or
     * the beginning of the query if no cursor was given) to this batch's
     * `end_cursor` (not the query's `end_cursor`).
     * In a single transaction, subsequent query result batches for the same query
     * can have a greater snapshot version number. Each batch's snapshot version
     * is valid for all preceding batches.
     * The value will be zero for eventually consistent queries.
     *

     *
     * optional int64 snapshot_version = 7;
     */
    public Builder setSnapshotVersion(long value) {

      snapshotVersion_ = value;
      onChanged();
      return this;
    }
    /**
     *

     * The version number of the snapshot this batch was returned from.
     * This applies to the range of results from the query's `start_cursor` (or
     * the beginning of the query if no cursor was given) to this batch's
     * `end_cursor` (not the query's `end_cursor`).
     * In a single transaction, subsequent query result batches for the same query
     * can have a greater snapshot version number. Each batch's snapshot version
     * is valid for all preceding batches.
     * The value will be zero for eventually consistent queries.
     *

     *
     * optional int64 snapshot_version = 7;
     */
    public Builder clearSnapshotVersion() {

      snapshotVersion_ = 0L;
      onChanged();
      return this;
    }
    public final Builder setUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return this;
    }

    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return this;
    }

    // @@protoc_insertion_point(builder_scope:google.datastore.v1.QueryResultBatch)
  }

  // @@protoc_insertion_point(class_scope:google.datastore.v1.QueryResultBatch)
  private static final com.google.datastore.v1.QueryResultBatch DEFAULT_INSTANCE;
  static {
    DEFAULT_INSTANCE = new com.google.datastore.v1.QueryResultBatch();
  }

  public static com.google.datastore.v1.QueryResultBatch getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<QueryResultBatch>
      PARSER = new com.google.protobuf.AbstractParser<QueryResultBatch>() {
    public QueryResultBatch parsePartialFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
        return new QueryResultBatch(input, extensionRegistry);
    }
  };

  public static com.google.protobuf.Parser<QueryResultBatch> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<QueryResultBatch> getParserForType() {
    return PARSER;
  }

  public com.google.datastore.v1.QueryResultBatch getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }

}


text:
package cs263w16.amazon;

import java.net.URL;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

import com.google.appengine.api.memcache.MemcacheService;
import com.google.appengine.api.memcache.MemcacheServiceFactory;

import cs263w16.WishlistProduct;

public class JavaCodeSnippet {

	private static final String ENDPOINT = "webservices.amazon.com";

	private SignedRequestsHelper helper;
	private Map<String, String> params;

	public JavaCodeSnippet() {
		params = new HashMap<String, String>();
		params.put("Service", "AWSECommerceService");
		params.put("Operation", "ItemLookup");
		params.put("AWSAccessKeyId", AWSCrendential.AWS_ACCESS_KEY_ID);
		params.put("AssociateTag", AWSCrendential.AWS_ASSOCIATE_TAG);
		params.put("IdType", "ASIN");
		params.put("ResponseGroup", "Images,ItemAttributes,Offers");
		try {
			helper = SignedRequestsHelper.getInstance(ENDPOINT,
					AWSCrendential.AWS_ACCESS_KEY_ID,
					AWSCrendential.AWS_SECRET_KEY);

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public WishlistProduct search(String productID) throws Exception {
		// TODO test
		if (productID.equals("XXXXXXXXXX")) {
			return new WishlistProduct("XXXXXXXXXX", "Test product",
					(1458500000000l - System.currentTimeMillis()) / 1000, 500,
					new Date());
		}
		params.put("ItemId", productID);
		String url = helper.sign(params);
		System.out.println(url);
		WishlistProduct wishlistProduct = new WishlistProduct();

		XMLReader xmlReader = XMLReaderFactory.createXMLReader();
		xmlReader.setContentHandler(new XMLContentHandler(wishlistProduct));
		xmlReader.parse(new InputSource(new URL(url).openStream()));
		if (wishlistProduct.getCurrentPrice() == 0) {
			return null;
		}
		return wishlistProduct;
	}

	public double getCachedPrice(String productID) {
		MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
		return (double) syncCache.get(productID);
	}
}


text:
title: OnRequestFail
page_title: OnRequestFail - RadODataDataSource
description: Check our Web Forms article about OnRequestFail.
slug: odatadatasource/client-side-programming/events/onrequestfail
tags: onrequestfail
published: True
position: 3
---

# OnRequestFail

##

The **OnRequestFail** client-side event occurs when data request fails.

The event handler receives two parameters - **sender** (an instance of the datasource) and **args**.


text:
#include "MCNPInput.hpp"
#include "geometry.hpp"
#include "options.hpp"

#include <stdexcept>
#include <cassert>
#include <iostream>
#include <sstream>
#include <cstdlib>

/******************
 * IMPLEMENTATIONS OF DataRef
 ******************/

template <class T>
class CardRef : public DataRef<T>{

protected:
  InputDeck& deck;
  DataCard::id_t key;

public:
  CardRef( InputDeck& deck_p, DataCard::kind kind, int ident ) :
    DataRef<T>(), deck(deck_p), key( std::make_pair( kind, ident ) )
  {}

  virtual const T& getData() const {
    DataCard* c = deck.lookup_data_card( key );
    const T& ref = dynamic_cast< DataRef<T>* >(c)->getData();
    return ref;
  }

  virtual CardRef<T> * clone(){
    return new CardRef<T>( *this );
  }

  const DataCard::id_t& getKey() const { return key; }

};

/******************
 * HELPER FUNCTIONS
 ******************/

static void strlower( std::string& str ){
  // convert to lowercase
  for(size_t i = 0; i < str.length(); ++i){
    str[i] = tolower( str.at(i) );
  }
}

static int makeint( const std::string& token ){
  const char* str = token.c_str();
  char* end;
  int ret = strtol(str, &end, 10);
  if( end != str+token.length() ){
    std::cerr << "Warning: string [" << token << "] did not convert to int as expected." << std::endl;
  }
  return ret;
}

static std::vector<std::string> parseID( const token_list_t tokens ){
  //This function returns the first two or three arguments in token_list, which
  //name and define the type of surface.
  std::vector<std::string> identifier (3);
  identifier[0] = tokens.at(0);
  if(identifier[0].find_first_of("*+") != identifier[0].npos){
    std::cerr << "Warning: no special handling for reflecting or white-boundary surfaces" << std::endl;
    identifier[0][0] = ' ';
  }

  if(tokens.at(1).find_first_of("1234567890-") != 0){
    identifier[1] = '0';
    identifier[2] = tokens.at(1);
  }
  else{
    identifier[1] = tokens.at(1);
    identifier[2] = tokens.at(2);
    if( makeint( identifier.at(1) ) == 0 ){
      std::cerr << "I don't think 0 is a valid surface transformation ID, so I'm ignoring it." << std::endl;
    }
  }
  return identifier;
}

static double makedouble( const std::string& token ){
  std::string tmp = token;

  // MCNP allows FORTRAN-style floating point values where the 'e' in the exponent is missing,
  // e.g. 1.23-45 means 1.23e-45.  The following check inserts such a missing 'e' to avoid
  // confusing strtod().
  size_t s_idx = tmp.find_last_of("+-");
  if( s_idx != tmp.npos && s_idx > tmp.find_first_of("1234567890") && tmp.at(s_idx-1) != 'e' ){
    tmp.insert( tmp.find_last_of("+-"), "e" );
    if( OPT_DEBUG ) std::cout << "Formatting FORTRAN value: converted " << token << " to " << tmp << std::endl;
  }

  const char* str = tmp.c_str();
  char* end;
  double ret = strtod(str, &end);
  if( end != str+tmp.length() ){
    std::cerr << "Warning: string [" << tmp << "] did not convert to double as expected." << std::endl;
  }
  return ret;
}

/** parse the args of an MCNP geometry transform */
static std::vector<double> makeTransformArgs( const token_list_t tokens ){
  std::vector<double> args;
  for( token_list_t::const_iterator i = tokens.begin(); i!=tokens.end(); ++i){

    std::string token = *i;
    size_t idx;
    while( (idx = token.find_first_of("()")) != token.npos){
      token.replace( idx, 1, "" ); // remove parentheses
    }
    if( token.find_first_of( "1234567890" ) != token.npos){
      args.push_back( makedouble( token ) );
    }
    else if( token.length() > 0) {
      std::cerr << "Warning: makeTransformArgs ignoring unrecognized input token [" << token << "]" << std::endl;
    }
  }
  return args;
}

/**
 * Attempt to create a Transform object using the given numbers. Bounding parentheses are allowed
 * and will be removed.
 *
 * The returned object is allocated with new and becomes the property of the caller.
 */
static DataRef<Transform>* parseTransform( InputDeck& deck, const token_list_t tokens, bool degree_format = false ){

  std::vector<double> args = makeTransformArgs( tokens );
  if( args.size() == 1 ){
    return new CardRef<Transform>( deck, DataCard::TR, static_cast<int>(args[0]) );
  }
  else{
    return new ImmediateRef<Transform>( Transform( args, degree_format ) );
  }
}

static DataRef<Transform>* parseTransform( InputDeck& deck, token_list_t::iterator& i, bool degree_format = false ){

  token_list_t args;
  std::string next_token = *i;

  if( next_token.find("(") != next_token.npos ){
    do{
      args.push_back( next_token );
      next_token = *(++i);
    }
    while( next_token.find(")") == next_token.npos );
  }

  args.push_back( next_token );

  return parseTransform( deck, args, degree_format );
}

static FillNode parseFillNode( InputDeck& deck, token_list_t::iterator& i, const token_list_t::iterator& end, bool degree_format = false ){
  // simple fill. Format is n or n (transform). Transform may be either a TR card number
  // or an immediate transform

  int n; // the filling universe
  DataRef<Transform>* t;
  bool has_transform = false;

  std::string first_token = *i;
  size_t paren_idx = first_token.find("(");

  std::string second_token;

  if( paren_idx != first_token.npos ){
    // first_token has an open paren
    std::string n_str(first_token, 0, paren_idx);
    n = makeint(n_str);

    second_token = first_token.substr(paren_idx,first_token.npos);
    has_transform = true;
  }
  else{
    n = makeint(first_token);

    if( ++i != end ){
      second_token = *i;
      if( second_token[0] == '(' ){
        has_transform = true;
      }
      else{
        // the next token didn't belong to this fill
        i--;
      }
    }
    else{ i--; }
  }

  if( has_transform ){
    token_list_t transform_tokens;
    std::string next_token = second_token;

    while( next_token.find(")") == next_token.npos ){
      transform_tokens.push_back(next_token);
      next_token = *(++i);
    }
    transform_tokens.push_back( next_token );

    t = parseTransform( deck, transform_tokens, degree_format );

  }
  else{
    t = new NullRef<Transform>();
  }

  if( n < 0 ){
    n = -n; // TODO: handle negative universe numbers specially
  }

  return FillNode (n, t );
}

static bool isblank( const std::string& line ){
  return (line=="" || line.find_first_not_of(" ") == line.npos );
}

template < class T >
std::ostream& operator<<( std::ostream& out, const std::vector<T>& list ){

  out << "[";

  for(typename std::vector<T>::const_iterator i = list.begin(); i!=list.end(); ++i){
    out << *i << "|";
  }

  if(list.size() > 0)
    out << "\b"; // unless list was empty, backspace the last | character

  out << "]";
  return out;
}

/******************
 * CELL CARDS
 ******************/

class CellCardImpl : public CellCard {
protected:
  static geom_list_entry_t make_geom_entry(geom_token_t t, int param = 0){
    return std::make_pair(t, param);
  }

  static bool is_num_token( geom_list_entry_t t ){
    return t.first == CELLNUM || t.first == SURFNUM || t.first == MBODYFACET;
  }

  static bool is_op_token( geom_list_entry_t t ){
    return t.first == COMPLEMENT || t.first == UNION || t.first == INTERSECT;
  }

  static int operator_priority( geom_list_entry_t t ){
    switch(t.first){
    case COMPLEMENT: return 3;
    case INTERSECT:  return 2;
    case UNION:      return 1;
    default:
      throw std::runtime_error("queried operator priority for a non-operator token");
    }
  }

  /**
   * Build the geom list as part of cell construction.
   * Each item in the list will be a string; either " ", ":", or "#", indicating
   * operators, or parentheses, or numbers indicating surface or cell identities.
   *
   * @param The list of geometry tokens in the input file, as a list of strings that were
   *        separated by white space in the original file.
   */
  void retokenize_geometry( const token_list_t& tokens ){
    for(token_list_t::const_iterator i = tokens.begin(); i!=tokens.end(); ++i){
      const std::string& token = *i;

      size_t j = 0;
      while( j < token.length() ){

        char cj = token.at(j);

        switch(cj){

          // the following macro pushes an intersect token onto the geom list
          // if the end of that list indicates that one is needed
#define IMPLICIT_INTERSECT() do{                                \
            if(geom.size()){                                    \
              geom_list_entry_t &t = geom.at(geom.size()-1);    \
              if( is_num_token(t) || t.first == RPAREN ){       \
                geom.push_back( make_geom_entry( INTERSECT ) ); \
              }}} while(0)

        case '(':
          IMPLICIT_INTERSECT();
          geom.push_back(make_geom_entry(LPAREN)); j++;
          break;

        case ')':
          geom.push_back(make_geom_entry(RPAREN)); j++;
          break;

        case '#':
          IMPLICIT_INTERSECT();
          geom.push_back(make_geom_entry(COMPLEMENT)); j++;
          break;

        case ':':
          geom.push_back(make_geom_entry(UNION)); j++;
          break;

        default: // a number
          // the number refers to a cell if the previous token is a complement
          bool is_cell = geom.size() && ((geom.at(geom.size()-1)).first == COMPLEMENT);
          IMPLICIT_INTERSECT();
          assert(isdigit(cj) || cj == '+' || cj == '-' );
          size_t end = token.find_first_not_of("1234567890-+.",j);
          assert(j != end);

          std::string numstr( token, j, end-j );
          const char* numstr_c = numstr.c_str();
          char* p;
          int num = strtol( numstr_c, &p, 10 );

          if( *p == '.' ){
            // This is a macrobody facet
            assert( !is_cell );

            int facet = strtol( p+1, NULL, 10 );
            assert( facet > 0 && facet <= 8 );

            // storage of macrobody facets: multiply cell number by ten, add facet number
            num *= 10;
            // don't add a positive facet number to a negative cell numer
            num += (num > 0) ? facet : -facet;
            geom.push_back( make_geom_entry( MBODYFACET, num ) );
          }
          else{
            geom.push_back( make_geom_entry( is_cell ? CELLNUM : SURFNUM, num ));
          }

          j += (end-j);
          break;
#undef IMPLICIT_INTERSECT

        }

      }
    }

    if( OPT_DEBUG ) std::cout << tokens << " -> " << geom << std::endl;

  }

  /**
   * The final step of geometry parsing: convert the geometry list to RPN, which
   * greatly simplifies the process of evaluating the geometry later.  This function
   * uses the shunting yard algorithm.  For more info consult
   * http://en.wikipedia.org/wiki/Shunting_yard_algorithm
   */
  void shunt_geometry( ){
    geom_list_t geom_copy( geom );
    geom.clear();

    geom_list_t stack;
    for(geom_list_t::iterator i = geom_copy.begin(); i!=geom_copy.end(); ++i){
      geom_list_entry_t token = *i;
      if( is_num_token(token) ){
        geom.push_back(token);
      }
      else if( is_op_token(token) ){

        while(stack.size()){
          geom_list_entry_t& stack_top = stack.back();
          if( is_op_token(stack_top) && operator_priority(stack_top) > operator_priority(token) ){
            geom.push_back(stack_top);
            stack.pop_back();
          }
          else{
            break;
          }
        }
        stack.push_back(token);
      }
      else if( token.first == LPAREN ){
        stack.push_back(token);
      }
      else if( token.first == RPAREN ){
        while( stack.back().first != LPAREN ){
          geom.push_back( stack.back() );
          stack.pop_back();
        }
        stack.pop_back(); // remove the LPAREN
      }
    }
    while( stack.size() ){
      geom.push_back( stack.back() );
      stack.pop_back();
    }
  }

  Vector3d latticeVectorHelper( Vector3d difference_along_normal, Vector3d v_dir ){
    double length = difference_along_normal.length() / (difference_along_normal.normalize().dot(v_dir));
    return v_dir * length;
  }

  void setupLattice(){

    if( OPT_DEBUG ) std::cout << "Setting up lattice for cell " << ident << std::endl;

    std::vector< std::pair<SurfaceCard*,bool> > surfaceCards;

    for( geom_list_t::iterator i = geom.begin(); i!=geom.end(); ++i){
      geom_list_entry_t entry = *i;
      if( entry.first == SURFNUM ){
        SurfaceCard* surf = parent_deck.lookup_surface_card( std::abs(entry.second) );
        assert(surf);
        surfaceCards.push_back( std::make_pair(surf, (entry.second>0) ) );
      }
    }

    int num_finite_dims = 0;
    Vector3d v1, v2, v3;

    std::vector< std::pair<Vector3d, double> > planes;

    if( surfaceCards.size() == 1 ){
      planes = surfaceCards.at(0).first->getMacrobodyPlaneParams();
      if( surfaceCards.at(0).second != false ){
        std::cerr << "Warning: macrobody lattice with positive sense, will proceed as if it was negative.";
      }
    }
    else{
      for( unsigned int i = 0; i < surfaceCards.size(); ++i){
        planes.push_back( surfaceCards.at(i).first->getPlaneParams() );
        if( surfaceCards.at(i).second == true ){ planes[i].first = -planes[i].first; }
      }
    }

    if( OPT_DEBUG ){
      for( unsigned int i = 0; i < planes.size(); ++i){
        std::cout << " plane " << i << " normal = " << planes[i].first << " d = " << planes[i].second  << std::endl;
      }
    }
    if( lat_type == HEXAHEDRAL ){
      assert( planes.size() == 2 || planes.size() == 4 || planes.size() == 6 );
      if( planes.size() == 2 ){

        num_finite_dims = 1;
        v1 = planes[0].first.normalize() * std::fabs( planes[0].second - planes[1].second );

      }
      else if( planes.size() == 4 ){
        num_finite_dims = 2;

        Vector3d v3 = planes[0].first.cross( planes[2].first ).normalize(); // infer a third (infinite) direction

        // vector from planes[1] to planes[0]
        Vector3d xv = planes[0].first.normalize() * std::fabs( planes[0].second - planes[1].second );

        // direction of l.v1: cross product of normals planes[2] and v3
        Vector3d xv2 = planes[2].first.normalize().cross( v3 ).normalize();
        v1 = latticeVectorHelper( xv, xv2 );

        Vector3d yv = planes[2].first.normalize() * std::fabs( planes[2].second - planes[3].second );
        Vector3d yv2 = planes[0].first.normalize().cross( v3 ).normalize();
        v2 = latticeVectorHelper( yv, yv2 );

      }
      else{ // planes.size() == 6
        num_finite_dims = 3;

        // vector from planes[1] to planes[0]
        Vector3d xv = planes[0].first.normalize() * std::fabs( planes[0].second - planes[1].second );

        // direction of v1: cross product of normals planes[2] and planes[4]
        Vector3d xv2 = planes[2].first.normalize().cross( planes[4].first.normalize() ).normalize();
        v1 = latticeVectorHelper( xv, xv2 );

        Vector3d yv = planes[2].first.normalize() * std::fabs( planes[2].second - planes[3].second );
        Vector3d yv2 = planes[0].first.normalize().cross( planes[4].first.normalize() ).normalize();
        v2 = latticeVectorHelper( yv, yv2 );

        Vector3d zv = planes[4].first.normalize() * std::fabs( planes[4].second - planes[5].second );
        Vector3d zv2 = planes[0].first.normalize().cross( planes[2].first.normalize() ).normalize();
        v3 = latticeVectorHelper( zv, zv2 );

      }

    }
    else if( lat_type == HEXAGONAL ){
      assert( planes.size() == 6 || planes.size() == 8 );

      v3 = planes[0].first.cross( planes[2].first ).normalize(); // prism's primary axis

      // vector from planes[1] to planes[0]
      Vector3d xv = planes[0].first.normalize() * std::fabs( planes[0].second - planes[1].second );

      // direction of l.v1: cross product of normals average(planes[2]+planes[4]) and v3
      // TODO: this averaging trick only works with regular hexagons...
      Vector3d xv2 = (planes[2].first.normalize()+planes[4].first.normalize()).normalize().cross( v3 ).normalize();
      v1 = latticeVectorHelper( xv, xv2 );

      Vector3d yv = planes[2].first.normalize() * std::fabs( planes[2].second - planes[3].second );
      Vector3d yv2 = (planes[1].first.normalize()+planes[4].first.normalize()).normalize().cross( v3 ).normalize();
      v2 = latticeVectorHelper( yv, yv2 );

      if( planes.size() == 6 ){
        num_finite_dims = 2;

      }
      else{ // planes.size() == 8
        num_finite_dims = 3;

        Vector3d zv = planes[6].first.normalize() * std::fabs( planes[6].second - planes[7].second );
        Vector3d zv2 = v3;
        v3 = latticeVectorHelper( zv, zv2 );
      }
    }

    if( OPT_DEBUG )std::cout << " dims " << num_finite_dims << " vectors " << v1 << v2 << v3 << std::endl;

    Lattice l;
    if( fill->hasData() ){
      l = Lattice( num_finite_dims, v1, v2, v3, fill->getData() );
    }
    else{
      FillNode n( this->universe );
      l = Lattice( num_finite_dims, v1, v2, v3,  n );
    }

    lattice = new ImmediateRef<Lattice>( l );

  }

  void makeData(){

    for( token_list_t::iterator i = data.begin(); i!=data.end(); ++i ){

      std::string token = *i;

      if( token == "trcl" || token == "*trcl" ){
        bool degree_format = (token[0] == '*');

        i++;
        trcl = parseTransform( parent_deck, i, degree_format );

      } // token == {*}trcl

      else if( token == "u" ){
        universe = makeint(*(++i));
      } // token == "u"
      else if ( token == "lat" ){
        int lat_designator = makeint(*(++i));
        assert( lat_designator >= 0 && lat_designator <= 2 );
        lat_type = static_cast<lattice_type_t>(lat_designator);
        if( OPT_DEBUG ) std::cout << "cell " << ident << " is lattice type " << lat_type << std::endl;
      }
      else if ( token == "mat" ){
        material = makeint(*(++i));
      }
      else if ( token == "rho" ){
        rho = makedouble(*(++i));
      }
      else if ( token.length() == 5 && token.substr(0,4) == "imp:" ){
        double imp = makedouble(*(++i));
        importances[token[4]] = imp;
      }
      else if( token == "fill" || token == "*fill" ){

        bool degree_format = (token[0] == '*');

        std::string next_token = *(++i);

        // an explicit lattice grid exists if
        // * the next token contains a colon, or
        // * the token after it exists and starts with a colon
        bool explicit_grid = next_token.find(":") != next_token.npos;
        explicit_grid = explicit_grid || (i+1 != data.end() && (*(i+1)).at(0) == ':' );

        if( explicit_grid ){

          // convert the grid specifiers (x1:x2, y1:y2, z1:z2) into three spaceless strings for easier parsing
          std::string gridspec[3];
          for( int dim = 0; dim < 3; ++dim ){

            std::string spec;

            // add tokens to the spec string until it contains a colon but does not end with one
            do{
              spec += *i;
              i++;
            }
            while( spec.find(":") == spec.npos || spec.at(spec.length()-1) == ':' );

            if(OPT_DEBUG) std::cout << "gridspec[" << dim << "]: " << spec << std::endl;
            gridspec[dim] = spec;

          }

          irange ranges[3];
          const char* range_str;
          char *p;

          int num_elements = 1;
          for( int dim = 0; dim < 3; ++dim ){
            range_str = gridspec[dim].c_str();
            ranges[dim].first  = strtol(range_str, &p, 10);
            ranges[dim].second = strtol(p+1, NULL, 10);

            if( ranges[dim].second != ranges[dim].first ){
              num_elements *= ( ranges[dim].second - ranges[dim].first )+1;
            }

          }

          std::vector<FillNode> elements;
          for( int j = 0; j < num_elements; ++j ){
            elements.push_back( parseFillNode( parent_deck, i, data.end(), degree_format )  );
            i++;
          }
          i--;

          fill = new ImmediateRef< Fill >( Fill( ranges[0], ranges[1], ranges[2], elements) );

        }
        else{ // no explicit grid; fill card is a single fill node
          FillNode filler = parseFillNode( parent_deck, i, data.end(), degree_format );
          fill = new ImmediateRef< Fill >( Fill(filler) );

        }
      } // token == {*}fill
    }

    // ensure data pointers are valid
    if( !trcl ) {
      trcl = new NullRef< Transform >();
    }

    if( !fill ){
      fill = new NullRef< Fill > ();
    }

  }

  int ident;
  int material;
  double rho; // material density
  std::map<char, double> importances;

  geom_list_t geom;
  token_list_t data;
  DataRef<Transform>* trcl;
  DataRef<Fill>* fill;
  int universe;

  bool likenbut;
  int likeness_cell_n;

  lattice_type_t lat_type;
  DataRef<Lattice> *lattice;

public:
  CellCardImpl( InputDeck& deck, const token_list_t& tokens ) :
    CellCard( deck ), trcl(NULL), fill(NULL), universe(0), likenbut(false), likeness_cell_n(0),
    lat_type(NONE), lattice(NULL)
  {

    unsigned int idx = 0;

    ident = makeint(tokens.at(idx++));

    if(tokens.at(idx) == "like"){

      idx++;
      likenbut = true;
      likeness_cell_n = makeint(tokens.at(idx++));
      idx++; // skip the "but" token
      while(idx < tokens.size()){
        data.push_back(tokens[idx++]);
      }
      return;
    }

    material = makeint(tokens.at(idx++));
    rho = 0.0;
    if(material != 0){
      rho = makedouble(tokens.at(idx++)); // material density
    }

    token_list_t temp_geom;

    // while the tokens appear in geometry-specification syntax, store them into temporary list
    while(idx < tokens.size() && tokens.at(idx).find_first_of("1234567890:#-+()") == 0){
      temp_geom.push_back(tokens[idx++]);
    }

    // retokenize the geometry list, which follows a specialized syntax.
    retokenize_geometry( temp_geom );
    shunt_geometry();

    // store the rest of the tokens into the data list
    while(idx < tokens.size()){
      data.push_back(tokens[idx++]);
    }

    makeData();

  }

  ~CellCardImpl(){
    if(trcl)
      delete trcl;
    if(fill)
      delete fill;
    if(lattice)
      delete lattice;
  }

  virtual int getIdent() const{ return ident; }
  virtual const geom_list_t getGeom() const { return geom; }

  virtual const DataRef<Transform>& getTrcl() const { return *trcl; }
  virtual int getUniverse() const { return universe; }

  virtual bool hasFill() const { return fill && fill->hasData(); }
  virtual const Fill& getFill() const {
    if( fill && fill->hasData() ){
      return fill->getData();
    }
    throw std::runtime_error( "Called getFill() on an unfilled cell");
  }

  virtual bool isLattice() const {
    return lat_type != NONE;
  }

  virtual lattice_type_t getLatticeType() const {
    return lat_type;
  }

  virtual const Lattice& getLattice() const {
    if( lattice && lattice->hasData() ){
      return lattice->getData();
    }
    throw std::runtime_error( "Called getLattice() on a cell that hasn't got one" );
  }

  virtual int getMat() const { return material; }
  virtual double getRho() const { return rho; }
  virtual const std::map<char,double>& getImportances() const { return importances; }

  virtual void print( std::ostream& s ) const{
    s << "Cell " << ident << " geom " << geom << std::endl;
  }

protected:
  void finish(){
    if( likenbut ){
      CellCardImpl* host = dynamic_cast<CellCardImpl*>(parent_deck.lookup_cell_card( likeness_cell_n ));
      if(host->likenbut){
        host->finish(); // infinite recursion if cells are circularly defined... but our users wouldn't do that, right?
      }
      geom = host->geom;
      universe = host->universe;
      lat_type = host->lat_type;
      material = host->material;
      rho = host->rho;
      importances = host->importances;

      if( host->trcl->hasData()){
        trcl = host->trcl->clone();
      }
      if( host->hasFill()){
        fill = host->fill->clone();
      }
      if( host->isLattice()){
        lattice = host->lattice->clone();
      }
      makeData();

      likenbut = false;
    }

    if( lat_type != NONE && lattice == NULL ){
      setupLattice();
    }

  }

  friend class InputDeck;
};

CellCard::CellCard( InputDeck& deck ) :
  Card(deck)
{}

std::ostream& operator<<(std::ostream& str, const CellCard::geom_list_entry_t& t ){
  switch(t.first){
  case CellCard::LPAREN:     str << "("; break;
  case CellCard::RPAREN:     str << ")"; break;
  case CellCard::COMPLEMENT: str << "#"; break;
  case CellCard::UNION:      str << ":"; break;
  case CellCard::INTERSECT:  str << "*"; break;
  case CellCard::SURFNUM:    str << t.second; break;
  case CellCard::CELLNUM:    str << "c" << t.second; break;
  case CellCard::MBODYFACET:
    int cell = t.second / 10;
    int facet = abs(t.second) - (abs(cell)*10);
    str << cell << "." << facet;
    break;
  }
  return str;
}

/******************
 * SURFACE CARDS
 ******************/

SurfaceCard::SurfaceCard( InputDeck& deck, const token_list_t tokens ):
  Card(deck)
{
      std::vector<std::string> identifier = parseID( tokens );
      ident = makeint(identifier.at(0));
      tx_id = makeint(identifier.at(1));
      mnemonic = identifier.at(2);
      size_t idx = 2;
      if( tx_id == 0 ){
        coord_xform = new NullRef<Transform>();
      }
      else if ( tx_id < 0 ){
        // abs(tx_id) is the ID of surface with respect to which this surface is periodic.
        std::cerr << "Warning: surface " << ident << " periodic, but this program has no special handling for periodic surfaces";
      }
      else{ // tx_id is positive and nonzero
        coord_xform = new CardRef<Transform>( deck, DataCard::TR, tx_id );
      }
      if( tokens.at(2) == mnemonic ){
        idx++;
      }

      while( idx < tokens.size() ){
        args.push_back( makedouble(tokens[idx++]) );
      }
}

SurfaceCard::SurfaceCard( InputDeck& deck, const SurfaceCard s, int facetNum ):
  Card(deck)
{
  //This form of SurfaceCard makes a copy of a macrobody for use with one of its facets.
  ident = facetNum;
  mnemonic = s.getMnemonic();
  args = s.getArgs();
  tx_id = s.getTxid();
  if( tx_id == 0 ){
    coord_xform = new NullRef<Transform>();
  }
  else if ( tx_id < 0 ){
    // abs(tx_id) is the ID of surface with respect to which this surface is periodic.
    std::cerr << "Warning: surface " << ident << " periodic, but this program has no special handling for periodic surfaces";
  }
  else{ // tx_id is positive and nonzero
    coord_xform = new CardRef<Transform>( deck, DataCard::TR, tx_id );
  }
}

const DataRef<Transform>& SurfaceCard::getTransform() const {
  return *coord_xform;
}

void SurfaceCard::print( std::ostream& s ) const {
  s << "Surface " << ident << " " << mnemonic << args;
  if( coord_xform->hasData() ){
    // this ugly lookup returns the integer ID of the TR card
    s << " TR" << dynamic_cast<CardRef<Transform>*>(coord_xform)->getKey().second;
  }
  s << std::endl;
}

std::pair<Vector3d,double> SurfaceCard::getPlaneParams() const {
  if(mnemonic == "px"){
    return std::make_pair(Vector3d(1,0,0), args[0]);
  }
  else if(mnemonic == "py"){
    return std::make_pair(Vector3d(0,1,0), args[0]);
  }
  else if(mnemonic == "pz"){
    return std::make_pair(Vector3d(0,0,1), args[0]);
  }
  else if(mnemonic == "p"){
    return std::make_pair(Vector3d( args ), args[3]/Vector3d(args).length());
  }
  else{
    throw std::runtime_error("Tried to get plane normal of non-plane surface!");
  }
}

std::vector< std::pair<Vector3d, double> > SurfaceCard::getMacrobodyPlaneParams() const {

  std::vector< std::pair< Vector3d, double> > ret;
  if( mnemonic == "box" ){
    Vector3d corner( args );
    const Vector3d v[3] = {Vector3d(args,3), Vector3d(args,6), Vector3d(args,9)};

    // face order: v1 -v1 v2 -v2 v3 -v3
    for( int i = 0; i < 3; ++i ){
      Vector3d p = corner + v[i];
      ret.push_back( std::make_pair( v[i].normalize(), v[i].projection( p ).length() ) );
      ret.push_back( std::make_pair( -v[i].normalize(), v[i].projection( p ).length()-v[i].length() ) );
    }

  }
  else if( mnemonic == "rpp" ){
    Vector3d min( args.at(0), args.at(2), args.at(4) );
    Vector3d max( args.at(1), args.at(3), args.at(5) );

    for( int i = 0; i < 3; ++i ){
      Vector3d v; v.v[i] = 1;
      ret.push_back( std::make_pair( v.normalize(), max.v[i] ));
      ret.push_back( std::make_pair(-v.normalize(), min.v[i] ));
    }

  }
  else if( mnemonic == "hex" || mnemonic == "rhp" ){

    Vector3d vertex( args ), height( args,3 ), RV( args, 6 ), SV, TV;
    if( args.size() == 9 ){
      SV = RV.rotate_about(height, 60); TV = RV.rotate_about(height, 120);
    }
    else{
      SV = Vector3d( args, 9 ); TV = Vector3d( args, 12 );
    }

    double len = RV.projection( vertex+RV ).length();
    ret.push_back( std::make_pair( RV.normalize(), len ) );
    ret.push_back( std::make_pair(-RV.normalize(), len - 2.0 * RV.length() ));

    len = SV.projection( vertex+SV ).length();
    ret.push_back( std::make_pair( SV.normalize(), len ) );
    ret.push_back( std::make_pair(-SV.normalize(), len - 2.0 * SV.length() ));

    len = TV.projection( vertex+TV ).length();
    ret.push_back( std::make_pair( TV.normalize(), len ) );
    ret.push_back( std::make_pair(-TV.normalize(), len - 2.0 * TV.length() ));

    len = height.projection( vertex+height ).length();
    ret.push_back( std::make_pair( height.normalize(), len ) );
    ret.push_back( std::make_pair(-height.normalize(), len - height.length() ));

  }
  else{
    throw std::runtime_error("Tried to get macrobody plane normals of unsupported surface!" );
  }
  return ret;
}

/******************
 * DATA CARDS
 ******************/

class TransformCard : public DataCard, public DataRef<Transform> {

protected:
  int ident;
  Transform trans;

public:
  TransformCard( InputDeck& deck, int ident_p, bool degree_format, const token_list_t& input );

  //  const Transform& getTransform() const{ return trans; }
  const Transform& getData() const{ return trans; }
  TransformCard* clone(){ return new TransformCard(*this); }

  virtual void print( std::ostream& str );
  virtual kind getKind(){ return TR; }
  int getIdent() const{ return ident; }

};

TransformCard::TransformCard( InputDeck& deck, int ident_p, bool degree_format, const token_list_t& input ):
  DataCard(deck), ident(ident_p), trans( Transform( makeTransformArgs( input ), degree_format ) )
{}

void TransformCard::print( std::ostream& str ){
  str << "TR" << ident << ": ";
  trans.print(str);
  str << std::endl;
}

/******************
 * PARSING UTILITIES
 ******************/

class InputDeck::LineExtractor{

protected:
  std::istream& input;
  std::string next_line;
  bool has_next;
  int next_line_idx;

  /*
   * Take note of the following, from mcnp5 manual page 1-3:
   * Tab characters in the input file are converted to one or more blanks, such that the character
   * following the tab will be positioned at the next tab stop. Tab stops are set every 8 characters,
   * i.e., 9, 17, 25, etc. The limit of input lines to 80 columns applies after tabs are expanded into blank
   * spaces. </snip>
   * I don't know whether this needs to be addressed to handle corner cases for line continuation, etc.
   * currently, it is not addressed.
   */

  void get_next(){

    bool comment;
    do{

      if(!std::getline(input, next_line)){
        has_next = false;
      }
      else{

        comment = false;
        next_line_idx++;

        // strip trailing carriage return, if any
        if(next_line.length() > 0 && *(next_line.rbegin()) == '\r')
          next_line.resize(next_line.size()-1);

        // convert to lowercase
        strlower(next_line);

        // Append a space, to catch blank comment lines (e.g. "c\n") that would otherwise not meet
        // the MCNP comment card spec ("a C anywhere in columns 1-5 followed by at least one blank.")
        // I have seen lines like "c\n" or " c\n" as complete comment cards in practice, so MCNP must
        // accept them.
        next_line.append(" ");

        // We want to find "c " within the first five
        // columns, but not if the c has anything other than a space before it.
        size_t idx = next_line.find("c ");
        if( idx < 5 ){
          if( idx == 0 || next_line.at(idx-1) == ' '){
            comment = true;
          }
        }
      }
    }
    while( has_next && comment );
    // iterate until next_line is not a comment line.

  }

public:
  LineExtractor( std::istream& input_p ) :
    input(input_p), next_line("*NO INPUT*"), has_next(true), next_line_idx(0)
  {
    get_next();
  }

  const std::string& peekLine() const {
    if( has_next ) return next_line;
    else throw std::runtime_error("LineExtractor out of lines, cannot peekLine().");
  }

  const std::string& peekLine( int& lineno ) const {
    lineno = next_line_idx;
    return peekLine();
  }

  std::string takeLine() {
    if( has_next ){
      std::string ret = next_line;
      get_next();
      return ret;
    }
    else throw std::runtime_error("LineExtractor out of lines, cannot takeLine().");
  }

  std::string takeLine( int& lineno ){
    lineno = next_line_idx;
    return takeLine();
  }

  bool hasLine() const{
    return has_next;
  }

  /**
   * @return the file line number of the next line (as will be returned by either
   * peekLine or takeLine)
   */
  int getLineCount() const{
    return next_line_idx;
  }

};

/**
 * Append a single token to the given list of tokens.
 * The token is assumed to be lowercase, free of comments, and non-blank.
 * This function is for handling shortcut
 * syntax, e.g. 1 4r, which should translate into four copies of the token 1
 */
void appendToTokenList( const std::string& token, token_list_t& tokens ){
  if( token.find_first_of("123456789") == 0 && token.at(token.length()-1) == 'r' ){
    // token starts with a number and ends with r: treat as repeat syntax.
    const char* string = token.c_str();
    char* p;
    int num = strtol( string, &p, 10 );
    if( (p - string) != static_cast<int>(token.length()) - 1 ){
      // oops, this isn't repeat format after all
      tokens.push_back(token);
      return;
    }

    if( OPT_DEBUG ) { std::cout << "Repeat syntax: " << token << " repeats "
                                << tokens.back() << " " << num << " times." << std::endl; }

    for( int i = 0; i < num; ++i){
      const std::string& last_tok = tokens.back();
      tokens.push_back( last_tok );
    }
  }
  else{
    tokens.push_back(token);
  }
}

void tokenizeLine( std::string line, token_list_t& tokens, const char* extra_separators = "" ){

  // replace any occurances of the characters in extra_separators with spaces;
  // they will then act as token separators
  size_t found;

  found = line.find_first_of(extra_separators);
  while (found!= line.npos )
  {
    line[found] = ' ';
    found = line.find_first_of(extra_separators,found+1);
  }

  std::stringstream str(line);
  while(str){
    std::string t;
    str >> t;

    // skip over $-style inline comments
    size_t idx;
    if((idx = t.find("$")) != t.npos){
      if(idx > 0){
        // this token had some data before the $
        t.resize(idx);
        appendToTokenList( t, tokens );
      }
      break;
    }

    // if the token is nontrivial, save it
    // necessary because stringstream may return a "" at the end of lines.
    if(t.length() > 0)  appendToTokenList( t, tokens );
  }

}

/******************
 * INPUT DECK
 ******************/

InputDeck::~InputDeck(){
  for(cell_card_list::iterator i = cells.begin(); i!=cells.end(); ++i){
    delete *i;
  }
  cells.clear();
  for(surface_card_list::iterator i = surfaces.begin(); i!=surfaces.end(); ++i){
    delete *i;
  }
  surfaces.clear();
  for(data_card_list::iterator i = datacards.begin(); i!=datacards.end(); ++i){
    delete *i;
  }
  datacards.clear();

}

/* handle line continuations: return true if the next line should be treated as part of
 * the current line */
bool InputDeck::do_line_continuation( LineExtractor& lines, token_list_t& token_buffer ){

  /* check for final character being & */
  std::string last_token = token_buffer.at(token_buffer.size()-1);
  if( last_token.at(last_token.length()-1) == '&' ){

    if( last_token.length() == 1 ){
      token_buffer.pop_back();
    }
    else{
      last_token.resize(last_token.length()-1);
      token_buffer.at(token_buffer.size()-1).swap( last_token );
    }

    return true;
  }
  /* check for next line beginning with five spaces */
  else if( lines.hasLine() && lines.peekLine().find("     ") == 0){
      /* but don't count it as a continuation if the line is entirely blank */
      if( lines.peekLine().find_first_not_of(" \t\n") != std::string::npos ){
          return true;
      }
  }

  return false;
}

void InputDeck::parseCells( LineExtractor& lines ){

  std::string line;
  token_list_t token_buffer;

  while( !isblank(line = lines.takeLine()) ){

    tokenizeLine(line, token_buffer, "=");

    if( do_line_continuation( lines, token_buffer ) ){
      continue;
    }

    if( OPT_DEBUG ) std::cout << "Creating cell with the following tokens:\n" << token_buffer << std::endl;
    CellCard* c = new CellCardImpl(*this, token_buffer);

    if( OPT_VERBOSE ) c->print(std::cout);

    this->cells.push_back(c);
    this->cell_map.insert( std::make_pair(c->getIdent(), c) );

    token_buffer.clear();

  }

}

void InputDeck::parseTitle( LineExtractor& lines ){

  // FIXME: will break if the title line looks like a comment card.

  int lineno;
  std::string topLine = lines.takeLine(lineno);
  if(topLine.find("message:") == 0){
    if( OPT_VERBOSE ) std::cout << "Skipping MCNP file message block..." << std::endl;
    do{
      // nothing
    }
    while( !isblank(lines.takeLine()) ) /*do nothing */;

    topLine = lines.takeLine(lineno);
  }

  if(topLine.find("continue") == 0){
    std::cerr << "Warning: this looks like it might be a `continue-run' input file." << std::endl;
    std::cerr << "  beware of trouble ahead!" << std::endl;
  }

  std::cout << "The MCNP title card is: " << topLine << std::endl;
  //std::cout << "    and occupies line " << lineno << std::endl;
}

void InputDeck::parseSurfaces( LineExtractor& lines ){
  std::string line;
  token_list_t token_buffer;
  while( !isblank(line = lines.takeLine()) ){

    tokenizeLine(line, token_buffer );

    if( do_line_continuation( lines, token_buffer ) ){
      continue;
    }
    //Create a surface card for each surface
    SurfaceCard* s = new SurfaceCard(*this, token_buffer);

    if( OPT_VERBOSE) s->print(std::cout);

    this->surfaces.push_back(s);
    this->surface_map.insert( std::make_pair(s->getIdent(), s) );

    token_buffer.clear();
  }
}

void InputDeck::parseDataCards( LineExtractor& lines ){
  std::string line;
  token_list_t token_buffer;

  while( lines.hasLine() && !isblank(line = lines.takeLine()) ){

    tokenizeLine(line, token_buffer );

    if( do_line_continuation( lines, token_buffer ) ){
      continue;
    }
    else if( token_buffer.at(0) == "#" ){
      std::cerr << "Vertical data card format not supported" << std::endl;
      std::cerr << "Data written in this format will be ignored." << std::endl;
    }

    DataCard* d = NULL;
    DataCard::kind t = DataCard::OTHER;
    int ident = 0;

    std::string cardname = token_buffer.at(0);
    token_buffer.erase( token_buffer.begin() );

    if( cardname.find("tr") == 0 || cardname.find("*tr") == 0 ){

      t = DataCard::TR;
      bool degree_format = false;
      if( cardname[0] == '*' ){
        degree_format = true;
        cardname = cardname.substr( 1 ); // remove leading *
      }
      else if( cardname.find("*") == cardname.length()-1 ){
        // although it's undocumented, apparently TRn* is a synonym for *TRn
        // (the manual uses this undocumented form in chapter 4)
        degree_format = true;
        cardname.resize( cardname.length() -1 ); // remove trailing *
      }

      std::string id_string( cardname, 2 );

      // the id_string may be empty, indicating that n is missing from TRn.
      // examples from the manual indicate it should be assumed to be 1
      if( id_string == "" ){
        ident = 1;
      }
      else{
        ident = makeint( id_string );
      }

      d = new TransformCard( *this, ident, degree_format, token_buffer);
    }

    if(d){
      if( OPT_VERBOSE ){ d->print( std::cout ); }
      this->datacards.push_back(d);
      this->datacard_map.insert( std::make_pair( std::make_pair(t,ident), d) );
    }

    token_buffer.clear();

  }

}

void InputDeck::copyMacrobodies(){
  //If a macrobody facet is used, this creates a copy of the surface card of the macrobody with a different id.
  for( cell_card_list::iterator k = cells.begin(); k!=cells.end(); ++k){
    CellCard* c = *k;
    const CellCard::geom_list_t& geom = c->getGeom();
    for(CellCard::geom_list_t::const_iterator i = geom.begin(); i!=geom.end(); ++i){

      const CellCard::geom_list_entry_t& token = (*i);

      if( token.first == 7 ){
        //this is a macrobody facet
        int ident = -std::abs( token.second );
        if( surface_map.find(ident) == surface_map.end() ){
          //It won't create multiple copies if a facet is used more than once.
          int surfaceNum = -ident/10;

          SurfaceCard* surface = this->lookup_surface_card( surfaceNum );
          SurfaceCard* s = new SurfaceCard( *this, *surface, ident );

          if( OPT_VERBOSE ) s->print(std::cout);

          this->surfaces.push_back(s);
          this->surface_map.insert( std::make_pair(s->getIdent(), s) );
        }
      }
    }
  }
}

InputDeck& InputDeck::build( std::istream& input){

  LineExtractor lines(input);

  InputDeck* deck = new InputDeck();

  deck->parseTitle(lines);
  deck->parseCells(lines);
  deck->parseSurfaces(lines);
  deck->parseDataCards(lines);
  deck->copyMacrobodies();

  for( std::vector<CellCard*>::iterator i = deck->cells.begin(); i!=deck->cells.end(); ++i){
    dynamic_cast<CellCardImpl*>(*i)->finish();
  }

  while(lines.hasLine()){ lines.takeLine(); }
  if( OPT_VERBOSE ) { std::cout << "Total lines read: " << lines.getLineCount()  <<  std::endl; }

  return *deck;
}

InputDeck::cell_card_list InputDeck::getCellsOfUniverse( int universe ){

  cell_card_list ret;
  for( cell_card_list::iterator i = cells.begin(); i!=cells.end(); ++i){
    CellCard* c = *i;
    if( std::abs(c->getUniverse()) == universe ){
      ret.push_back( *i );
    }
  }
  return ret;

}

CellCard* InputDeck::lookup_cell_card(int ident){
  assert( cell_map.find(ident) != cell_map.end() );
  return (*cell_map.find(ident)).second;
}

SurfaceCard* InputDeck::lookup_surface_card(int ident){
  assert( surface_map.find(ident) != surface_map.end() );
  return (*surface_map.find(ident)).second;
}

DataCard* InputDeck::lookup_data_card( const DataCard::id_t& ident ){
  assert( datacard_map.find(ident) != datacard_map.end() );
  return (*datacard_map.find(ident)).second;
}


text:
import { jsdom } from 'jsdom';

global.document = jsdom('', {
  parsingMode: 'html'
});
global.window = global.document.parentWindow;
global.navigator = window.navigator || {};


text:
package cn.scau.edu.ssm.showdoc.mapper;

import java.util.List;

import cn.scau.edu.ssm.showdoc.po.PageExtendClass;

public interface PageExtendMapper {
	public int insertPage(PageExtendClass pageExtendClass) throws Exception;
	public List<PageExtendClass> selectPageByPid(PageExtendClass pageExtendClass) throws Exception;
}