text:
// .NAME vtk2DHistogramItem - 2D histogram item.
//
// .SECTION Description
//

#ifndef __vtk2DHistogramItem_h
#define __vtk2DHistogramItem_h

#include "vtkContextItem.h"
#include "vtkSmartPointer.h"  // Needed for SP ivars
#include "vtkVector.h"        // Needed for vtkRectf

class vtkImageData;
class vtkScalarsToColors;

class VTK_CHARTS_EXPORT vtk2DHistogramItem : public vtkContextItem
{
public:
  vtkTypeMacro(vtk2DHistogramItem, vtkContextItem);
  virtual void PrintSelf(ostream &os, vtkIndent indent);

  // Description:
  // Creates a new object.
  static vtk2DHistogramItem *New();

  // Description:
  // Perform any updates to the item that may be necessary before rendering.
  // The scene should take care of calling this on all items before their
  // Paint function is invoked.
  virtual void Update();

  // Description:
  // Paint event for the item, called whenever it needs to be drawn.
  virtual bool Paint(vtkContext2D *painter);

  // Description:
  // Set the input, we are expecting a vtkImageData with just one component,
  // this would normally be a float or a double. It will be passed to the other
  // functions as a double to generate a color.
  void SetInput(vtkImageData *data, vtkIdType z = 0);

  // Description:
  // Get the input table used by the plot.
  vtkImageData * GetInput();

  // Description:
  // Set the color transfer funtion that will be used to generate the 2D
  // histogram.
  void SetTransferFunction(vtkScalarsToColors *transfer);

  // Description:
  // Get the color transfer function that is used to generate the histogram.
  vtkScalarsToColors * GetTransferFunction();

  virtual void GetBounds(double bounds[4]);

  virtual void SetPosition(const vtkRectf& pos);
  virtual vtkRectf GetPosition();

//BTX
protected:
  vtk2DHistogramItem();
  ~vtk2DHistogramItem();

  // Description:
  // Where all the magic happens...
  void GenerateHistogram();

  vtkSmartPointer<vtkImageData> Input;
  vtkSmartPointer<vtkImageData> Output;
  vtkSmartPointer<vtkScalarsToColors> TransferFunction;
  vtkRectf Position;

private:
  vtk2DHistogramItem(const vtk2DHistogramItem &); // Not implemented.
  void operator=(const vtk2DHistogramItem &); // Not implemented.

//ETX
};

#endif //__vtk2DHistogramItem_h


text:
namespace {
const CobaltExtensionInstallationManagerApi kInstallationManagerApi = {
    kCobaltExtensionInstallationManagerName,
    1,  // API version that's implemented.
    &ImGetCurrentInstallationIndex,
    &ImMarkInstallationSuccessful,
    &ImRequestRollForwardToInstallation,
    &ImGetInstallationPath,
    &ImSelectNewInstallationIndex,
    &ImGetAppKey,
    &ImGetMaxNumberInstallations,
    &ImResetInstallation,
    &ImReset,
};
}  // namespace
namespace starboard {
namespace loader_app {

const void* SbSystemGetExtensionShim(const char* name) {
  if (strcmp(name, kCobaltExtensionInstallationManagerName) == 0) {
    return &kInstallationManagerApi;
  }
  return NULL;
}
}  // namespace loader_app
}  // namespace starboard

redpajama_set_name: RedPajamaGithub


text:
package adb.wifi.woaiwhz.wifiadbandroid.bean;

import android.util.Property;
import android.view.View;

/**
 * Created by huazhou.whz on 2016/10/6.
 */

public class XProperty extends Property<View, Float> {

    public XProperty(Class<Float> type, String name) {
        super(type, name);
    }

    @Override
    public Float get(View object) {
        return object.getX();
    }

    @Override
    public void set(View object, Float value) {
        object.setX(value);
    }
}


text:
package org.revapi.simple;

import javax.annotation.Nonnull;

import org.revapi.Report;
import org.revapi.Reporter;

/**
 * @author Lukas Krejci
 *
 * @since 0.4.0
 *
 * @deprecated use {@link org.revapi.base.BaseReporter} instead
 */
@Deprecated
public abstract class SimpleReporter extends SimpleConfigurable implements Reporter {
    @Override
    public void report(@Nonnull Report report) {
    }
}


text:
import numpy as np
import scipy.sparse
import kmeans
import json

#Make sure we get consistent, reproducible results
np.random.seed(seed=1)
#Define the data directory (change if you place data elsewhere)
data_dir = "/home/bsprague/Projects/CS589/MovieLens/Data/"

#Load the training ratings
A       = np.load(data_dir + "train.npy")
A.shape = (1,)
Xtrain  = A[0]

#Load the validation ratings
A       = np.load(data_dir + "validate.npy")
A.shape = (1,)
Xval    = A[0]

#Load the test ratings
A       = np.load(data_dir + "test.npy")
A.shape = (1,)
Xtest   = A[0]

#Load the user, item, and genre information
Users   = np.load(data_dir + "users.npy")
Items   = np.load(data_dir + "items.npy")
Genres  = np.load(data_dir + "genres.npy")

def getRMSE(k):
  model = kmeans.kmeans(n_clusters=k)
  model.fit(Xtrain)

#Predict back the training ratings and compute the RMSE
  XtrainHat = model.predict(Xtrain,Xtrain)
  tr= model.rmse(Xtrain,XtrainHat)

#Predict the validation ratings and compute the RMSE
  XvalHat = model.predict(Xtrain,Xval)
  val= model.rmse(Xval,XvalHat)

  return (tr,val)

results = []
#Test k from 1 to 10
for k in range(1,11):
  results.append([])
  #Do 5 random restarts
  for runs in range(1,6):
    #Store the results
    results[k-1].append(getRMSE(k))

# Average, Max, and Min RMSE over k = 1 to 10 on training set
avg_tr = [np.mean([z[0] for z in y]) for y in results]
max_tr = [np.amax([z[0] for z in y]) for y in results]
min_tr = [np.amin([z[0] for z in y]) for y in results]

# Average, Max, and Min RMSE over k = 1 to 10 on validation set
avg_val = [np.mean([z[1] for z in y]) for y in results]
max_val = [np.amax([z[1] for z in y]) for y in results]
min_val = [np.amin([z[1] for z in y]) for y in results]

# Our actual model, with k=3
model = kmeans.kmeans(n_clusters=3)
model.fit(Xtrain)

clusters = model.cluster(Xtrain)

# Age, Gender, Occupation, and Address arrays for each cluster
resAge = [[],[],[]]
resGen = [[],[],[]]
resOcc = [[],[],[]]
resSt = [[],[],[]]

for i, x in enumerate(clusters):
    resAge[int(x)].append(Users[i][1])
    resGen[int(x)].append(Users[i][2])
    resOcc[int(x)].append(Users[i][3])
    resSt[int(x)].append(Users[i][4])

# 'zip.json' is a map from zip codes to states
with open('zip.json') as data_file:
    mapping = json.load(data_file)

for x in range(3):
    d = {}
    # Look at each zip code in the cluster and add it into our map
    for o in resSt[x]:
      if o in mapping:
        if mapping[o] in d:
            d[mapping[o]] += 1
        else:
            d[mapping[o]] = 1
      else:
        print("Couldn't find " + o)
    # Here, we'd build our pie chart

# centers is a k x 1682 array of ratings
centers = model.get_centers()

high = [list(reversed(sorted([(rating, Items[movie_id][1]) for movie_id, rating in enumerate(center)])))[:5] for center in centers]
low = [sorted([(rating, Items[movie_id][1]) for movie_id, rating in enumerate(center)])[:5] for center in centers]


text:
/*-------------------------------------------------------------------------*/
/**
   @file    SSL_Tiled.h
   @author  P. Batty
   @brief   Implements a Tiled .tmx map handler

   This module implements a way to load access and draw .tmx maps
*/
/*--------------------------------------------------------------------------*/

#ifndef SSL_TILED_READER_H_
#define SSL_TILED_READER_H_

/*---------------------------------------------------------------------------
                                Includes
 ---------------------------------------------------------------------------*/

#include "../data_structures/SSL_Hashmap.h"
#include "../data_structures/SSL_List.h"
#include "../graphics/SSL_Image.h"
#include "../graphics/SSL_Light.h"

/*---------------------------------------------------------------------------
                                New types
 ---------------------------------------------------------------------------*/

/*!--------------------------------------------------------------------------
  @brief    SSL_Map

  This object contains information about the map such as size, version ect

\----------------------------------------------------------------------------*/
typedef struct _SSL_MAP_ {
	char *version;						/**< Map version 	 	 	*/
	char *orientation;		   			/**< Map orientation	 	*/
	unsigned int map_width;	   			/**< Map width in tiles  	*/
	unsigned int map_height;			/**< Map height in tiles 	*/
	unsigned int tile_width;			/**< Tile width			 	*/
	unsigned int tile_height;			/**< Tile height		 	*/
	unsigned int total_layers;			/**< Total number of layers */
	unsigned int total_tilesets;		/**< Total tilesets			*/
	SSL_Hashmap *properties;			/**< The map properties 	*/
} SSL_Map;

/*!--------------------------------------------------------------------------
  @brief    SSL_Tile_Layer

  This object contains information about each layer

\----------------------------------------------------------------------------*/
typedef struct _SSL_Tile_Layer_ {
	char *name;
	unsigned int width;
	unsigned int height;
	float opacity;
	unsigned char visible;
	int *data;
	SSL_Hashmap *properties;
} SSL_Tile_Layer;

/*!--------------------------------------------------------------------------
  @brief    SSL_Tileset_Info

  This object contains information about the tilesets.

\----------------------------------------------------------------------------*/
typedef struct _SSL_Tileset_ {
	unsigned int firstGid;		/**< The id  	      */
	char *name;					/**< The name 	      */
	unsigned int tile_width;	/**< the tile width   */
	unsigned int tile_height;	/**< the tile height  */
	unsigned int spacing;		/**< the tile spacing */
	unsigned int margin;		/**< the tile margin  */
	SSL_Image *image;			/**< the tile image   */
	SSL_Hashmap *properties;	/**< the properties   */
	SSL_List *tiles;			/**< the tiles on set */
} SSL_Tileset;

/*!--------------------------------------------------------------------------
  @brief    SSL_Tile

  This object contains information about the tiles.

\----------------------------------------------------------------------------*/
typedef struct _SSL_Tile_ {
	unsigned int id;			/**< The id  	      			   */
	SSL_Image *image;			/**< the image containing the tile */
	SSL_Hashmap *properties;	/**< The properties on this tile   */
} SSL_Tile;

/*!--------------------------------------------------------------------------
  @brief    SSL_Tiled_Map

  The Main object all tiled maps will be made with this object, containing all the
  information on the map stored in it.

  Destroy with SSL_Tiled_Map_Destroy.

\----------------------------------------------------------------------------*/
typedef struct _SSL_Tiled_Map_ {
	SSL_Map	 map;					/**<  The map information */
	SSL_List *tilesets;				/**<  The tilesets */
	SSL_List *layers;				/**<  The layers */
	SSL_List *lights;				/**<  The lights */
	SDL_Color color;				/**<  Default light colour of the world */
} SSL_Tiled_Map;

/*---------------------------------------------------------------------------
                            Function prototypes
 ---------------------------------------------------------------------------*/

/*!--------------------------------------------------------------------------
  @brief    Loads and creates new Tiled map
  @param    file		 the path to the file
  @param    window       The renderer to use
  @return A SSL_Tiled_Map object

  Loads and creates new Tiled map.
  Destroy with SSL_Tiled_Map_Destroy.

\-----------------------------------------------------------------------------*/
SSL_Tiled_Map *SSL_Tiled_Map_Load(const char *file, SSL_Window *window);

/*!--------------------------------------------------------------------------
  @brief    Draws a loaded map to the screen
  @param    map			 the map to draw
  @param    xOffset		 X Offset to draw the map
  @param    yOffset		 y Offset to draw the map
  @param    window       The window to draw to
  @return A SSL_Tiled_Map object

  Draws the map to the given window.

\-----------------------------------------------------------------------------*/
void SSL_Tiled_Draw_Map(SSL_Tiled_Map *map, int xOffset, int yOffset, SSL_Window *window);

/*!--------------------------------------------------------------------------
  @brief    Draws a lights on the map
  @param    map			 the map to draw
  @param    xOffset		 X Offset to draw the map
  @param    yOffset		 y Offset to draw the map
  @param    window       The window to draw to
  @param	func		 The raytrace callback function to determine what's solid
  @return Void

  Draws the lights on the map

\-----------------------------------------------------------------------------*/
void SSL_Tiled_Draw_Lights(SSL_Tiled_Map *map, int xOffset, int yOffset, SSL_Window *window, int(*func)(int, int, void *));

/*!--------------------------------------------------------------------------
  @brief    Adds a light object to the map
  @param    map			 map to add the light to
  @param	light		 SSL_Light to add
  @return Void

  Adds a light object to the map

\-----------------------------------------------------------------------------*/
void SSL_Tiled_Add_Light(SSL_Tiled_Map *map, SSL_Light *light);

/*!--------------------------------------------------------------------------
  @brief    Changes the Lighting
  @param    map			 map to change the lighting on
  @param	color		 the lighting to change to
  @return Void

  Changes the defualt lighting color

\-----------------------------------------------------------------------------*/
void SSL_Tiled_Set_Lighting(SSL_Tiled_Map *map, SDL_Color color);
void SSL_Tiled_Set_TiledID(SSL_Tiled_Map *map, int layer, int x, int y, int id);
void show_layer(SSL_Tiled_Map *map, int layer_index);
void hide_layer(SSL_Tiled_Map *map, int layer_index);

/*!--------------------------------------------------------------------------
  @brief    Gets a SSL_Tileset
  @param    map			 map containing the tileset
  @param    gid			 gid of the tile set to get
  @return A SLL_Tileset object else -1

  Gets a SSL_Tileset object from the SSL_Map with the given gid else -1

\-----------------------------------------------------------------------------*/
SSL_Tileset *SSL_Tiled_Get_Tileset(SSL_Tiled_Map *map, int gid);

/*!--------------------------------------------------------------------------
  @brief    Gets the map height in tiles
  @param    map			 map to get the height of
  @return Map height in tiles

  Map height in tiles

\-----------------------------------------------------------------------------*/
unsigned int SSL_Tiled_Get_Height(SSL_Tiled_Map *map);

/*!--------------------------------------------------------------------------
  @brief    Gets the map width in tiles
  @param    map			 map to get the width of
  @return Map width in tiles

  Map width in tiles

\-----------------------------------------------------------------------------*/
unsigned int SSL_Tiled_Get_Width(SSL_Tiled_Map *map);

/*!--------------------------------------------------------------------------
  @brief    Gets the map height in pixels
  @param    map			 map to get the height of
  @return Map height in pixels

  Map height in pixels

\-----------------------------------------------------------------------------*/
int SSL_Tiled_Get_Height_px(SSL_Tiled_Map *map);

/*!--------------------------------------------------------------------------
  @brief    Gets the map width in pixels
  @param    map			 map to get the width of
  @return Map width in pixels

  Map width in pixels

\-----------------------------------------------------------------------------*/
int SSL_Tiled_Get_Width_px(SSL_Tiled_Map *map);

/*!--------------------------------------------------------------------------
  @brief    Gets the tile width in pixels
  @param    map			 map to get the tile width of
  @return Tile width in pixels

  Tile width in pixels

\-----------------------------------------------------------------------------*/
int SSL_Tiled_Get_Tile_Width(SSL_Tiled_Map *map);

/*!--------------------------------------------------------------------------
  @brief    Gets the tile height in pixels
  @param    map			 map to get the tile height of
  @return Tile height in pixels

  Tile height in pixels

\-----------------------------------------------------------------------------*/
int SSL_Tiled_Get_Tile_Height(SSL_Tiled_Map *map);

/*!--------------------------------------------------------------------------
  @brief    Gets the number of layers in the map
  @param    map			 map to get the number of layers
  @return Number of layers

  Number of layers

\-----------------------------------------------------------------------------*/
int SSL_Tiled_Get_Layercount(SSL_Tiled_Map *map);

/*!--------------------------------------------------------------------------
  @brief    Gets the number of tilesets in the map
  @param    map			 map to get the number of tilesets
  @return Number of tilesets

  Number of tilesets

\-----------------------------------------------------------------------------*/
int SSL_Tiled_Get_Tileset_Count(SSL_Tiled_Map *map);

/*!--------------------------------------------------------------------------
  @brief    Gets the tile id at the location specified
  @param    map			 map to get the number of tile id from
  @param	x			 x position of the tile
  @param	y			 y position of the tile
  @param	layer_index	 layer number position of the tile
  @return tile id at the location specified

  Tile id at the location specified

\-----------------------------------------------------------------------------*/
int SSL_Tiled_Get_TileId(SSL_Tiled_Map *map, int x, int y, int layer_index);

/*!--------------------------------------------------------------------------
  @brief    Gets the layer index on the map
  @param    map			 map to get the number of layer index from
  @param	name		 name of the layer
  @return layer index of the given layer name else -1

  Layer index of the given layer name else -1

\-----------------------------------------------------------------------------*/
int SSL_Tiled_Get_LayerIndex(SSL_Tiled_Map *map, char *name);

/*!--------------------------------------------------------------------------
  @brief    Removes a light from the map
  @param    map			 map to remove the light from
  @param	light		 The light to remove
  @return Void

  Removes a light from the map

\-----------------------------------------------------------------------------*/
void SSL_Tiled_Remove_Light(SSL_Tiled_Map *map, SSL_Light *light);

/*!--------------------------------------------------------------------------
  @brief    Gets the light on the map
  @param    map			 map to get the light from
  @param	n			 nth position of the light
  @return The SSL_Light else -1

  Gets the light on the map and return is else -1

\-----------------------------------------------------------------------------*/
SSL_Light *SSL_Tiled_Get_Light(SSL_Tiled_Map *map, int n);

/*!--------------------------------------------------------------------------
  @brief    Destroys the map
  @param    map		The map to destroy
  @return   void

  Destroys the map.

\-----------------------------------------------------------------------------*/
void SSL_Tiled_Map_Destroy(SSL_Tiled_Map *map);

#endif


text:
                    Edit

                    Admin Edit

                    Apply Now


text:
package org.sakaiproject.tool.assessment.qti.asi;

import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringEscapeUtils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.sakaiproject.tool.assessment.data.dao.assessment.Answer;
import org.sakaiproject.tool.assessment.data.dao.assessment.ItemText;
import org.sakaiproject.tool.assessment.data.ifc.assessment.AnswerIfc;
import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemAttachmentIfc;
import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemDataIfc;
import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemMetaDataIfc;
import org.sakaiproject.tool.assessment.data.ifc.assessment.ItemTextIfc;
import org.sakaiproject.tool.assessment.data.ifc.shared.TypeIfc;
import org.sakaiproject.tool.assessment.qti.constants.AuthoringConstantStrings;
import org.sakaiproject.tool.assessment.qti.constants.QTIConstantStrings;
import org.sakaiproject.tool.assessment.qti.constants.QTIVersion;
import org.sakaiproject.tool.assessment.qti.helper.QTIHelperFactory;
import org.sakaiproject.tool.assessment.qti.helper.item.ItemHelperIfc;

/**
 *
Copyright: Copyright (c) 2004

 *
Organization: Sakai Project

 * @author rshastri
 * @author Ed Smiley esmiley@stanford.edu
 * @version $Id$
 */
public class Item extends ASIBaseClass
{
  private static Log log = LogFactory.getLog(Item.class);
  private ItemHelperIfc helper;

  /**
   * Explicitly setting serialVersionUID insures future versions can be
     * successfully restored. It is essential this variable name not be changed
     * to SERIALVERSIONUID, as the default serialization methods expects this
   * exact name.
   */
  private static final long serialVersionUID = 1;
  private String basePath;
  private String identity;

  /**
   * Creates a new Item object.
   */
  public Item(int qtiVersion)
  {
    super();
    initVersion(qtiVersion);
  }

  /**
   * Creates a new Item object.
   *
   * @param document an item XML document
   */
  public Item(Document document, int qtiVersion)
  {
    super(document);
    initVersion(qtiVersion);
  }

  private void initVersion(int qtiVersion)
  {
    if (!QTIVersion.isValid(qtiVersion))
    {
      throw new IllegalArgumentException("Invalid Item QTI version.");
    }
    switch (qtiVersion)
    {
      case QTIVersion.VERSION_1_2:
        basePath = QTIConstantStrings.ITEM; // for v 1.2
        identity = QTIConstantStrings.IDENT;
        break;
      case QTIVersion.VERSION_2_0:
        basePath = QTIConstantStrings.ASSESSMENTITEM;// for v 2.0
        identity = QTIConstantStrings.AITEM_IDENT;
        break;
      default:
        basePath = QTIConstantStrings.ITEM; // DEFAULT
        identity = QTIConstantStrings.IDENT;
        break;
    }

    QTIHelperFactory factory = new QTIHelperFactory();
    helper = factory.getItemHelperInstance(qtiVersion);
    log.debug("Item XML class.initVersion(int qtiVersion)");
    log.debug("qtiVersion="+qtiVersion);
    log.debug("basePath="+basePath);
    log.debug("identity="+identity);
  }

  /**
   * set identity attribute (ident/identity)
   * @param ident the value
   */

  public void setIdent(String ident)
  {
    String xpath = basePath;
    List<?> list = this.selectNodes(xpath);
    if (list.size() > 0)
    {
      Element element = (Element) list.get(0);
      element.setAttribute(identity, ident);
    }
  }

  /**
   * set title attribute
   * @param ident the value
   */
  public void setTitle(String title)
  {
    String xpath = basePath;
    List<?> list = this.selectNodes(xpath);
    if (list.size() > 0)
    {
      Element element = (Element) list.get(0);
      element.setAttribute(QTIConstantStrings.TITLE, escapeXml(title));
    }
  }

  /**
   * Update XML from persistence
   * @param item
   */
  public void update(ItemDataIfc item)
  {
    if(item == null) {
    	return;
    }

    // metadata
    setFieldentry("ITEM_OBJECTIVE",
      item.getItemMetaDataByLabel(ItemMetaDataIfc.OBJECTIVE ));
    setFieldentry("ITEM_KEYWORD",
      item.getItemMetaDataByLabel(ItemMetaDataIfc.KEYWORD));
    setFieldentry("ITEM_RUBRIC", item.getItemMetaDataByLabel(ItemMetaDataIfc.RUBRIC ));
    setFieldentry("ATTACHMENT", getAttachment(item));

    // set TIMEALLOWED and NUM_OF_ATTEMPTS for audio recording questions:
    if (item.getDuration()!=null){
    	setFieldentry("TIMEALLOWED",
    			item.getDuration().toString());
    }
    if (item.getTriesAllowed()!=null){
    	setFieldentry("NUM_OF_ATTEMPTS",
    			item.getTriesAllowed().toString());
    }
    //  rshastri: SAK-1824
    if((item.getTypeId().equals(TypeIfc.TRUE_FALSE) ||
    		item.getTypeId().equals(TypeIfc.MULTIPLE_CHOICE)||
    		item.getTypeId().equals(TypeIfc.MULTIPLE_CORRECT) ||
    		item.getTypeId().equals(TypeIfc.MULTIPLE_CORRECT_SINGLE_SELECTION)) && item.getHasRationale() !=null)
    {
    	setFieldentry("hasRationale", item.getHasRationale().toString());
    }
    if(item.getTypeId().equals(TypeIfc.MULTIPLE_CHOICE) && item.getPartialCreditFlag()){
    	setFieldentry("PARTIAL_CREDIT", "TRUE");

    }else{
    	setFieldentry("PARTIAL_CREDIT", "FALSE");
    }
    //  rshastri: SAK-1824
    // item data
    if (!this.isSurvey() && !this.isMXSURVEY()) //surveys are unscored
    {
      helper.addMaxScore(item.getScore(), this);
      helper.addMinScore(item.getDiscount(), this);
    }

    if(item !=null &&(item.getTypeId().equals(TypeIfc.FILL_IN_BLANK))) {
    	setFieldentry("MUTUALLY_EXCLUSIVE", item.getItemMetaDataByLabel(ItemMetaDataIfc.MUTUALLY_EXCLUSIVE_FOR_FIB ));
       	setFieldentry("CASE_SENSITIVE", item.getItemMetaDataByLabel(ItemMetaDataIfc.CASE_SENSITIVE_FOR_FIB ));
    }

    if(item !=null && (item.getTypeId().equals(TypeIfc.MULTIPLE_CHOICE) || item.getTypeId().equals(TypeIfc.MULTIPLE_CORRECT) ||item.getTypeId().equals(TypeIfc.MULTIPLE_CORRECT_SINGLE_SELECTION))) {
    	setFieldentry("RANDOMIZE", item.getItemMetaDataByLabel(ItemMetaDataIfc.RANDOMIZE ));
    	setFieldentry("MCMS_PARTIAL_CREDIT", item.getItemMetaDataByLabel(ItemMetaDataIfc.MCMS_PARTIAL_CREDIT ));
    }

    if (this.isMXSURVEY()) {
    	setFieldentry("FORCE_RANKING", item.getItemMetaDataByLabel(ItemMetaDataIfc.FORCE_RANKING));
    	setFieldentry("ADD_COMMENT_MATRIX", item.getItemMetaDataByLabel(ItemMetaDataIfc.ADD_COMMENT_MATRIX));
    	setFieldentry("MX_SURVEY_QUESTION_COMMENTFIELD", item.getItemMetaDataByLabel(ItemMetaDataIfc.MX_SURVEY_QUESTION_COMMENTFIELD));
    	setFieldentry("MX_SURVEY_RELATIVE_WIDTH", item.getItemMetaDataByLabel(ItemMetaDataIfc.MX_SURVEY_RELATIVE_WIDTH));
    }

    String instruction = item.getInstruction();
    if (this.isMatching() || this.isFIB() || this.isFIN() || this.isMXSURVEY() || this.isCalculatedQuestion()|| this.isImageMapQuestion())
    {
      if ( instruction != null)
        {
    	  helper.setItemText(instruction, this);
        }
    }

    if(this.isEMI()){
    	helper.setItemLabel(StringEscapeUtils.escapeXml(item.getThemeText()), this);
		helper.setPresentationLabel(item.getIsAnswerOptionsSimple()?"Simple":"Rich", this);
		String ident = "EMI" + item.getSequence();
		helper.setPresentationFlowResponseIdent(ident, this);
		//set attachments
		helper.setAttachments(item.getItemAttachmentSet(), this);
		//set the options
		if(item.getIsAnswerOptionsSimple()){
			setItemTexts(Collections.singletonList(
					item.getItemTextBySequence(ItemTextIfc.EMI_ANSWER_OPTIONS_SEQUENCE)));
		}else{
			ItemText it = new ItemText();
			it.setSequence(ItemTextIfc.EMI_ANSWER_OPTIONS_SEQUENCE);
			it.setText(item.getEmiAnswerOptionsRichText());
			Set<AnswerIfc> answerSet = new HashSet<AnswerIfc>();
			String labels = item.getEmiAnswerOptionLabels();
			for(int i = 0; i < item.getAnswerOptionsRichCount(); i++){
				Answer a = new Answer();
				a.setSequence(Long.valueOf(i));
				a.setLabel(labels.substring(i, i+1));
				answerSet.add(a);
			}
			it.setAnswerSet(answerSet);
			setItemTexts(Collections.singletonList((ItemTextIfc)it));
		}
		helper.setItemText(item.getLeadInText(), "Leadin", this);
		setAnswers(item.getEmiQuestionAnswerCombinations());
    	return;//already setting text and answers, EMI has no feedback.
    }
    List<ItemTextIfc> itemTexts = item.getItemTextArraySorted();

    setItemTexts(itemTexts);
    if (this.isTrueFalse()) // we know what the answers are (T/F)
    {
      Boolean isTrue = item.getIsTrue();
      if (isTrue == null)
        isTrue = Boolean.FALSE;
      setAnswerTrueFalse(isTrue.booleanValue());
    }
    else {
      setAnswers(itemTexts);
    }
    setFeedback(itemTexts);
  }

  /**
   * Set the answer texts for item.
   * @param itemTextList the text(s) for item
   */
  public void setAnswerTrueFalse(boolean isTrue)
  {
    log.debug("isTrue="+isTrue);
    if (isTrue)
    {
      helper.addCorrectAnswer("A", this);
      helper.addIncorrectAnswer("B", this);
    }
    else
    {
      helper.addCorrectAnswer("B", this);
      helper.addIncorrectAnswer("A", this);

    }
  }

  /**
   * method for meta data
   *
   * @param fieldlabel to get
   *
   * @return the value
   */
  public String getFieldentry(String fieldlabel)
  {
    if (log.isDebugEnabled())
    {
      log.debug("getFieldentry(String " + fieldlabel + ")");
    }
    String xpath = helper.getMetaLabelXPath(fieldlabel);
    return super.getFieldentry(xpath);
  }

  /**
   * method for meta data
   *
   * @param fieldlabel to get
   *
   * @param setValue the value
   */
  public void setFieldentry(String fieldlabel, String setValue)
  {
    if (log.isDebugEnabled())
    {
      log.debug(
        "setFieldentry(String " + fieldlabel + ", String " + setValue +
        ")");
    }

    String xpath = helper.getMetaLabelXPath(fieldlabel);
    super.setFieldentry(xpath, setValue);
  }

  /**
   * Create a metadata field entry
   *
   * @param fieldlabel the field label
   */
  public void createFieldentry(String fieldlabel)
  {
    if (log.isDebugEnabled())
    {
      log.debug("createFieldentry(String " + fieldlabel + ")");
    }

    String xpath = helper.getMetaXPath();
    super.createFieldentry(xpath, fieldlabel);
  }

  public String getItemType()
  {
    String type = this.getFieldentry("qmd_itemtype");

    return type;
  }

  /**
   * Set the item texts.
   * Valid for single and multiple texts.
   * @param itemText text to be updated
   */
  public void setItemTexts(List<ItemTextIfc> itemTextList)
  {
    helper.setItemTexts(itemTextList, this);
  }

  public boolean  isEssay()
  {
    boolean essay =
      AuthoringConstantStrings.ESSAY.equals(this.getItemType()) ||
      AuthoringConstantStrings.ESSAY_ALT.equals(this.getItemType());
    return essay ? true : false;
  }

  public boolean  isSurvey()
  {
    return AuthoringConstantStrings.SURVEY.equals(this.getItemType()) ? true : false;
  }

  public boolean isMXSURVEY()
  {
    return AuthoringConstantStrings.MATRIX.equals(this.getItemType()) ? true : false;
  }

  public boolean  isAudio()
  {
    return AuthoringConstantStrings.AUDIO.equals(this.getItemType()) ? true : false;
  }

  public boolean  isFile()
  {
    return AuthoringConstantStrings.FILE.equals(this.getItemType()) ? true : false;
  }

  public boolean  isMatching()
  {
    return AuthoringConstantStrings.MATCHING.equals(this.getItemType()) ? true : false;
  }

  public boolean  isFIB()
  {
    return AuthoringConstantStrings.FIB.equals(this.getItemType()) ? true : false;
  }

  public boolean  isFIN()
  {
    return AuthoringConstantStrings.FIN.equals(this.getItemType()) ? true : false;
  }

  public boolean  isMCMC()
  {
    return AuthoringConstantStrings.MCMC.equals(this.getItemType()) ? true : false;
  }

  public boolean  isMCMCSS()
  {
    return AuthoringConstantStrings.MCMCSS.equals(this.getItemType()) ? true : false;
  }

  public boolean  isMCSC()
  {
    return AuthoringConstantStrings.MCSC.equals(this.getItemType()) ? true : false;
  }

  private boolean isTrueFalse()
  {
    return AuthoringConstantStrings.TF.equals(this.getItemType()) ? true : false;
  }

  public boolean isEMI()
  {
	  return AuthoringConstantStrings.EMI.equals(this.getItemType()) ? true : false;
  }

  // CALCULATED_QUESTION
  public boolean isCalculatedQuestion()
  {
    return AuthoringConstantStrings.CALCQ.equals(this.getItemType()) ? true : false;
  }

  //IMAGEMAP_QUESTION
  public boolean isImageMapQuestion()
  {
	return AuthoringConstantStrings.IMAGMQ.equals(this.getItemType()) ? true : false;
  }

  /**
   * Set the answer texts for item.
   * @param itemTextList the text(s) for item
   */
  public void setAnswers(List<ItemTextIfc> itemTextList)
  {
    helper.setAnswers(itemTextList, this);
  }

  /**
   * Set the feedback texts for item.
   * @param itemTextList the text(s) for item
   */
  public void setFeedback(List<ItemTextIfc> itemTextList)
  {
    helper.setFeedback(itemTextList, this);
  }

  /**
   * Get the text for the item
   * @return the text
   */
  public String getItemText()
  {
    return helper.getText(this);
  }

  public String getBasePath()
  {
    return basePath;
  }

  public void setBasePath(String basePath)
  {
    this.basePath = basePath;
  }

  private String getAttachment(ItemDataIfc item) {
	  Set<ItemAttachmentIfc> attachmentSet = item.getItemAttachmentSet();
   	  if (attachmentSet != null && attachmentSet.size() != 0) {
   		Iterator<ItemAttachmentIfc> iter = attachmentSet.iterator();
   		ItemAttachmentIfc attachmentData = null;
   		StringBuilder attachment = new StringBuilder();
   		while (iter.hasNext())
   		{
   			attachmentData = iter.next();
   			attachment.append(attachmentData.getResourceId().replaceAll(" ", ""));
   			attachment.append("|");
   			attachment.append(attachmentData.getFilename());
   			attachment.append("|");
   			attachment.append(attachmentData.getMimeType());
   			attachment.append("\n");
   		}
   		return attachment.toString();
   	  }
   	  else {
   		return null;
   	  }
  }
}


text:
package com.twitter.finagle.netty4

import io.netty.buffer.ByteBuf
import io.netty.util.ResourceLeakDetector
import io.netty.util.ResourceLeakDetectorFactory
import org.scalatestplus.mockito.MockitoSugar
import org.mockito.Mockito._
import org.mockito.ArgumentMatchers._
import org.scalatest.funsuite.AnyFunSuite

class StatsLeakDetectorFactoryTest extends AnyFunSuite with MockitoSugar {
  test("counts netty resource leaks") {
    var leaks = 0

    val fac = new StatsLeakDetectorFactory(
      mock[ResourceLeakDetectorFactory], // not actually used
      { () => leaks += 1 }
    )
    val detector = fac.newResourceLeakDetector(classOf[ByteBuf])

    // netty's leak detection relies on references getting collected so rather than
    // introduce non-determinism into our test we grab the non-public
    // 'reportTracedLeak' method to fake a leak report.
    val reportLeakMeth =
      detector.getClass.getDeclaredMethod("reportTracedLeak", classOf[String], classOf[String])
    reportLeakMeth.setAccessible(true)
    reportLeakMeth.invoke(detector, "", "")
    assert(leaks == 1)
    reportLeakMeth.invoke(detector, "", "")
    assert(leaks == 2)
    reportLeakMeth.invoke(detector, "", "")
    assert(leaks == 3)
  }

  test("can load non-bytebuf resource trackers") {
    val parent = mock[ResourceLeakDetectorFactory]
    val expected = mock[ResourceLeakDetector[String]]

    when(parent.newResourceLeakDetector(same(classOf[String]), any[Int], any[Long]))
      .thenReturn(expected)

    val detectorFac = new StatsLeakDetectorFactory(parent, () => ())
    val detector = detectorFac.newResourceLeakDetector(classOf[String])
    assert(detector eq expected)
  }
}


text:
FOUNDATION_EXPORT double WeatherShareVersionNumber;

//! Project version string for WeatherShare.
FOUNDATION_EXPORT const unsigned char WeatherShareVersionString[];

// In this header, you should import all the public headers of your framework using statements like #import <WeatherShare/PublicHeader.h>


text:
using System.Collections.Generic;
using Fluent_CQRS.Sample.Contracts;

namespace Fluent_CQRS.Sample.Domain
{
    internal class SampleAggregate : Aggregate
    {
        public SampleAggregate(string id, IEnumerable<IAmAnEventMessage> history)
            : base(id, history) { }

        public void SampleAggregateMethod(string myValue)
        {
            Changes.Add(new SampleEventRaised{MyValue = myValue});
        }
    }
}


text:
import React from 'react';
import {pipeToNodeWritable} from 'react-dom/unstable-fizz';

import App from '../src/components/App';

let assets;
if (process.env.NODE_ENV === 'development') {
  // Use the bundle from create-react-app's server in development mode.
  assets = {
    'main.js': '/static/js/bundle.js',
    'main.css': '',
  };
} else {
  assets = require('../build/asset-manifest.json');
}

export default function render(url, res) {
  res.socket.on('error', error => {
    // Log fatal errors
    console.error('Fatal', error);
  });
  let didError = false;
  const {startWriting, abort} = pipeToNodeWritable(
    <App assets={assets} />,
    res,
    {
      onReadyToStream() {
        // If something errored before we started streaming, we set the error code appropriately.
        res.statusCode = didError ? 500 : 200;
        res.setHeader('Content-type', 'text/html');
        // There's no way to render a doctype in React so prepend manually.
        res.write('<!DOCTYPE html>');
        startWriting();
      },
      onError(x) {
        didError = true;
        console.error(x);
      },
    }
  );
  // Abandon and switch to client rendering after 5 seconds.
  // Try lowering this to see the client recover.
  setTimeout(abort, 5000);
}


text:
require 'spec_helper'

describe PollOption do
  pending "add some examples to (or delete) #{__FILE__}"
end


text:
#include <algorithm>
#include <string>
#include <sstream>

#include "ignite/common/bits.h"

#include "ignite/impl/binary/binary_utils.h"

#include "ignite/odbc/system/odbc_constants.h"
#include "ignite/odbc/app/application_data_buffer.h"
#include "ignite/odbc/utility.h"

namespace ignite
{
    namespace odbc
    {
        namespace app
        {
            using ignite::impl::binary::BinaryUtils;

            ApplicationDataBuffer::ApplicationDataBuffer() :
                type(type_traits::OdbcNativeType::AI_UNSUPPORTED),
                buffer(0),
                buflen(0),
                reslen(0),
                offset(0)
            {
                // No-op.
            }

            ApplicationDataBuffer::ApplicationDataBuffer(type_traits::OdbcNativeType::Type type,
                void* buffer, SqlLen buflen, SqlLen* reslen, int** offset) :
                type(type),
                buffer(buffer),
                buflen(buflen),
                reslen(reslen),
                offset(offset)
            {
                // No-op.
            }

            ApplicationDataBuffer::ApplicationDataBuffer(const ApplicationDataBuffer & other) :
                type(other.type),
                buffer(other.buffer),
                buflen(other.buflen),
                reslen(other.reslen),
                offset(other.offset)
            {
                // No-op.
            }

            ApplicationDataBuffer::~ApplicationDataBuffer()
            {
                // No-op.
            }

            ApplicationDataBuffer & ApplicationDataBuffer::operator=(const ApplicationDataBuffer & other)
            {
                type = other.type;
                buffer = other.buffer;
                buflen = other.buflen;
                reslen = other.reslen;
                offset = other.offset;

                return *this;
            }

            template<typename T>
            void ApplicationDataBuffer::PutNum(T value)
            {
                using namespace type_traits;

                SqlLen* resLenPtr = GetResLen();
                void* dataPtr = GetData();

                switch (type)
                {
                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    {
                        PutNumToNumBuffer<signed char>(value);
                        break;
                    }

                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    {
                        PutNumToNumBuffer<unsigned char>(value);
                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_SHORT:
                    {
                        PutNumToNumBuffer<short>(value);
                        break;
                    }

                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    {
                        PutNumToNumBuffer<unsigned short>(value);
                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_LONG:
                    {
                        PutNumToNumBuffer<long>(value);
                        break;
                    }

                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    {
                        PutNumToNumBuffer<unsigned long>(value);
                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    {
                        PutNumToNumBuffer<int64_t>(value);
                        break;
                    }

                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    {
                        PutNumToNumBuffer<uint64_t>(value);
                        break;
                    }

                    case OdbcNativeType::AI_FLOAT:
                    {
                        PutNumToNumBuffer<float>(value);
                        break;
                    }

                    case OdbcNativeType::AI_DOUBLE:
                    {
                        PutNumToNumBuffer<double>(value);
                        break;
                    }

                    case OdbcNativeType::AI_CHAR:
                    {
                        PutValToStrBuffer<char>(value);
                        break;
                    }

                    case OdbcNativeType::AI_WCHAR:
                    {
                        PutValToStrBuffer<wchar_t>(value);
                        break;
                    }

                    case OdbcNativeType::AI_NUMERIC:
                    {
                        if (dataPtr)
                        {
                            SQL_NUMERIC_STRUCT* out =
                                reinterpret_cast<SQL_NUMERIC_STRUCT*>(dataPtr);

                            uint64_t uval = static_cast<uint64_t>(value < 0 ? -value : value);

                            out->precision = common::bits::DigitLength(uval);
                            out->scale = 0;
                            out->sign = value < 0 ? 0 : 1;

                            memset(out->val, 0, SQL_MAX_NUMERIC_LEN);

                            memcpy(out->val, &uval, std::min<int>(SQL_MAX_NUMERIC_LEN, sizeof(uval)));
                        }

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_NUMERIC_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_BINARY:
                    case OdbcNativeType::AI_DEFAULT:
                    {
                        if (dataPtr)
                        {
                            if (buflen >= sizeof(value))
                            {
                                memcpy(dataPtr, &value, sizeof(value));

                                if (resLenPtr)
                                    *resLenPtr = sizeof(value);
                            }
                            else
                            {
                                memcpy(dataPtr, &value, static_cast<size_t>(buflen));

                                if (resLenPtr)
                                    *resLenPtr = SQL_NO_TOTAL;
                            }
                        }
                        else if (resLenPtr)
                            *resLenPtr = sizeof(value);

                        break;
                    }

                    case OdbcNativeType::AI_TDATE:
                    {
                        PutDate(Date(static_cast<int64_t>(value)));

                        break;
                    }

                    case OdbcNativeType::AI_TTIMESTAMP:
                    {
                        PutTimestamp(Timestamp(static_cast<int64_t>(value)));

                        break;
                    }

                    case OdbcNativeType::AI_TTIME:
                    {
                        PutTime(Time(static_cast<int64_t>(value)));

                        break;
                    }

                    default:
                    {
                        if (resLenPtr)
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }
            }

            template<typename Tbuf, typename Tin>
            void ApplicationDataBuffer::PutNumToNumBuffer(Tin value)
            {
                void* dataPtr = GetData();
                SqlLen* resLenPtr = GetResLen();

                if (dataPtr)
                {
                    Tbuf* out = reinterpret_cast<Tbuf*>(dataPtr);
                    *out = static_cast<Tbuf>(value);
                }

                if (resLenPtr)
                    *resLenPtr = static_cast<SqlLen>(sizeof(Tbuf));
            }

            template<typename CharT, typename Tin>
            void ApplicationDataBuffer::PutValToStrBuffer(const Tin & value)
            {
                typedef std::basic_stringstream<CharT> ConverterType;

                ConverterType converter;

                converter << value;

                PutStrToStrBuffer<CharT>(converter.str());
            }

            template<typename CharT>
            void ApplicationDataBuffer::PutValToStrBuffer(const int8_t & value)
            {
                typedef std::basic_stringstream<CharT> ConverterType;

                ConverterType converter;

                converter << static_cast<int>(value);

                PutStrToStrBuffer<CharT>(converter.str());
            }

            template<typename OutCharT, typename InCharT>
            void ApplicationDataBuffer::PutStrToStrBuffer(const std::basic_string<InCharT>& value)
            {
                SqlLen charSize = static_cast<SqlLen>(sizeof(OutCharT));

                SqlLen* resLenPtr = GetResLen();
                void* dataPtr = GetData();

                if (dataPtr)
                {
                    if (buflen >= charSize)
                    {
                        OutCharT* out = reinterpret_cast<OutCharT*>(dataPtr);

                        SqlLen outLen = (buflen / charSize) - 1;

                        SqlLen toCopy = std::min<size_t>(outLen, value.size());

                        for (SqlLen i = 0; i < toCopy; ++i)
                            out[i] = value[i];

                        out[toCopy] = 0;
                    }

                    if (resLenPtr)
                    {
                        if (buflen >= static_cast<SqlLen>((value.size() + 1) * charSize))
                            *resLenPtr = static_cast<SqlLen>(value.size());
                        else
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }
                else if (resLenPtr)
                    *resLenPtr = value.size();
            }

            void ApplicationDataBuffer::PutRawDataToBuffer(void *data, size_t len)
            {
                SqlLen ilen = static_cast<SqlLen>(len);

                SqlLen* resLenPtr = GetResLen();
                void* dataPtr = GetData();

                if (dataPtr)
                {
                    size_t toCopy = static_cast<size_t>(std::min(buflen, ilen));

                    memcpy(dataPtr, data, toCopy);

                    if (resLenPtr)
                    {
                        if (buflen >= ilen)
                            *resLenPtr = ilen;
                        else
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }
                else if (resLenPtr)
                    *resLenPtr = ilen;
            }

            void ApplicationDataBuffer::PutInt8(int8_t value)
            {
                PutNum(value);
            }

            void ApplicationDataBuffer::PutInt16(int16_t value)
            {
                PutNum(value);
            }

            void ApplicationDataBuffer::PutInt32(int32_t value)
            {
                PutNum(value);
            }

            void ApplicationDataBuffer::PutInt64(int64_t value)
            {
                PutNum(value);
            }

            void ApplicationDataBuffer::PutFloat(float value)
            {
                PutNum(value);
            }

            void ApplicationDataBuffer::PutDouble(double value)
            {
                PutNum(value);
            }

            int32_t ApplicationDataBuffer::PutString(const std::string& value)
            {
                using namespace type_traits;

                int32_t used = 0;

                switch (type)
                {
                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    case OdbcNativeType::AI_SIGNED_SHORT:
                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    case OdbcNativeType::AI_SIGNED_LONG:
                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    case OdbcNativeType::AI_NUMERIC:
                    {
                        std::stringstream converter;

                        converter << value;

                        int64_t numValue;

                        converter >> numValue;

                        PutNum(numValue);

                        used = static_cast<int32_t>(value.size());

                        break;
                    }

                    case OdbcNativeType::AI_FLOAT:
                    case OdbcNativeType::AI_DOUBLE:
                    {
                        std::stringstream converter;

                        converter << value;

                        double numValue;

                        converter >> numValue;

                        PutNum(numValue);

                        used = static_cast<int32_t>(value.size());

                        break;
                    }

                    case OdbcNativeType::AI_CHAR:
                    case OdbcNativeType::AI_BINARY:
                    case OdbcNativeType::AI_DEFAULT:
                    {
                        PutStrToStrBuffer<char>(value);

                        used = static_cast<int32_t>(GetSize()) - 1;

                        break;
                    }

                    case OdbcNativeType::AI_WCHAR:
                    {
                        PutStrToStrBuffer<wchar_t>(value);

                        used = (static_cast<int32_t>(GetSize()) / 2) - 1;

                        break;
                    }

                    default:
                    {
                        SqlLen* resLenPtr = GetResLen();

                        if (resLenPtr)
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }

                return used < 0 ? 0 : used;
            }

            void ApplicationDataBuffer::PutGuid(const Guid & value)
            {
                using namespace type_traits;

                SqlLen* resLenPtr = GetResLen();

                switch (type)
                {
                    case OdbcNativeType::AI_CHAR:
                    case OdbcNativeType::AI_BINARY:
                    case OdbcNativeType::AI_DEFAULT:
                    {
                        PutValToStrBuffer<char>(value);
                        break;
                    }

                    case OdbcNativeType::AI_WCHAR:
                    {
                        PutValToStrBuffer<wchar_t>(value);
                        break;
                    }

                    case OdbcNativeType::AI_GUID:
                    {
                        SQLGUID* guid = reinterpret_cast<SQLGUID*>(GetData());

                        guid->Data1 = static_cast<uint32_t>(value.GetMostSignificantBits() >> 32);
                        guid->Data2 = static_cast<uint16_t>(value.GetMostSignificantBits() >> 16);
                        guid->Data3 = static_cast<uint16_t>(value.GetMostSignificantBits());

                        uint64_t lsb = value.GetLeastSignificantBits();
                        for (size_t i = 0; i < sizeof(guid->Data4); ++i)
                            guid->Data4[i] = (lsb >> (sizeof(guid->Data4) - i - 1) * 8) & 0xFF;

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQLGUID));

                        break;
                    }

                    default:
                    {
                        if (resLenPtr)
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }
            }

            int32_t ApplicationDataBuffer::PutBinaryData(void *data, size_t len)
            {
                using namespace type_traits;

                int32_t used = 0;

                switch (type)
                {
                    case OdbcNativeType::AI_BINARY:
                    case OdbcNativeType::AI_DEFAULT:
                    {
                        PutRawDataToBuffer(data, len);

                        used = static_cast<int32_t>(GetSize());

                        break;
                    }

                    case OdbcNativeType::AI_CHAR:
                    {
                        std::stringstream converter;

                        uint8_t *dataBytes = reinterpret_cast<uint8_t*>(data);

                        for (size_t i = 0; i < len; ++i)
                        {
                            converter << std::hex
                                      << std::setfill('0')
                                      << std::setw(2)
                                      << static_cast<unsigned>(dataBytes[i]);
                        }

                        PutStrToStrBuffer<char>(converter.str());

                        used = static_cast<int32_t>(GetSize()) - 1;

                        break;
                    }

                    case OdbcNativeType::AI_WCHAR:
                    {
                        std::wstringstream converter;

                        uint8_t *dataBytes = reinterpret_cast<uint8_t*>(data);

                        for (size_t i = 0; i < len; ++i)
                        {
                            converter << std::hex
                                      << std::setfill<wchar_t>('0')
                                      << std::setw(2)
                                      << static_cast<unsigned>(dataBytes[i]);
                        }

                        PutStrToStrBuffer<wchar_t>(converter.str());

                        used = static_cast<int32_t>(GetSize() / 2) - 1;

                        break;
                    }

                    default:
                    {
                        SqlLen* resLenPtr = GetResLen();

                        if (resLenPtr)
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }

                return used < 0 ? 0 : used;
            }

            void ApplicationDataBuffer::PutNull()
            {
                SqlLen* resLenPtr = GetResLen();

                if (resLenPtr)
                    *resLenPtr = SQL_NULL_DATA;
            }

            void ApplicationDataBuffer::PutDecimal(const common::Decimal& value)
            {
                using namespace type_traits;

                SqlLen* resLenPtr = GetResLen();

                switch (type)
                {
                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    case OdbcNativeType::AI_SIGNED_SHORT:
                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    case OdbcNativeType::AI_SIGNED_LONG:
                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    {
                        PutNum<int64_t>(value.ToInt64());

                        break;
                    }

                    case OdbcNativeType::AI_FLOAT:
                    case OdbcNativeType::AI_DOUBLE:
                    {
                        PutNum<double>(value.ToDouble());

                        break;
                    }

                    case OdbcNativeType::AI_CHAR:
                    case OdbcNativeType::AI_WCHAR:
                    {
                        std::stringstream converter;

                        converter << value;

                        PutString(converter.str());

                        break;
                    }

                    case OdbcNativeType::AI_NUMERIC:
                    {
                        SQL_NUMERIC_STRUCT* numeric =
                            reinterpret_cast<SQL_NUMERIC_STRUCT*>(GetData());

                        common::Decimal zeroScaled;
                        value.SetScale(0, zeroScaled);

                        common::FixedSizeArray<int8_t> bytesBuffer;

                        const common::BigInteger& unscaled = zeroScaled.GetUnscaledValue();

                        unscaled.MagnitudeToBytes(bytesBuffer);

                        for (int32_t i = 0; i < SQL_MAX_NUMERIC_LEN; ++i)
                        {
                            int32_t bufIdx = bytesBuffer.GetSize() - 1 - i;
                            if (bufIdx >= 0)
                                numeric->val[i] = bytesBuffer[bufIdx];
                            else
                                numeric->val[i] = 0;
                        }

                        numeric->scale = 0;
                        numeric->sign = unscaled.GetSign() < 0 ? 0 : 1;
                        numeric->precision = unscaled.GetPrecision();

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_NUMERIC_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_DEFAULT:
                    case OdbcNativeType::AI_BINARY:
                    default:
                    {
                        if (resLenPtr)
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }
            }

            void ApplicationDataBuffer::PutDate(const Date& value)
            {
                using namespace type_traits;

                tm tmTime;

                common::DateToCTm(value, tmTime);

                SqlLen* resLenPtr = GetResLen();
                void* dataPtr = GetData();

                switch (type)
                {
                    case OdbcNativeType::AI_CHAR:
                    {
                        char* buffer = reinterpret_cast<char*>(dataPtr);

                        if (buffer)
                        {
                            strftime(buffer, GetSize(), "%Y-%m-%d", &tmTime);

                            if (resLenPtr)
                                *resLenPtr = strlen(buffer);
                        }
                        else if (resLenPtr)
                            *resLenPtr = sizeof("HHHH-MM-DD") - 1;

                        break;
                    }

                    case OdbcNativeType::AI_WCHAR:
                    {
                        SQLWCHAR* buffer = reinterpret_cast<SQLWCHAR*>(dataPtr);

                        if (buffer)
                        {
                            std::string tmp(GetSize(), 0);

                            strftime(&tmp[0], GetSize(), "%Y-%m-%d", &tmTime);

                            SqlLen toCopy = std::min(static_cast<SqlLen>(strlen(tmp.c_str()) + 1), GetSize());

                            for (SqlLen i = 0; i < toCopy; ++i)
                                buffer[i] = tmp[i];

                            buffer[toCopy] = 0;

                            if (resLenPtr)
                                *resLenPtr = toCopy;
                        }
                        else if (resLenPtr)
                            *resLenPtr = sizeof("HHHH-MM-DD") - 1;

                        break;
                    }

                    case OdbcNativeType::AI_TDATE:
                    {
                        SQL_DATE_STRUCT* buffer = reinterpret_cast<SQL_DATE_STRUCT*>(dataPtr);

                        buffer->year = tmTime.tm_year + 1900;
                        buffer->month = tmTime.tm_mon + 1;
                        buffer->day = tmTime.tm_mday;

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_DATE_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_TTIME:
                    {
                        SQL_TIME_STRUCT* buffer = reinterpret_cast<SQL_TIME_STRUCT*>(dataPtr);

                        buffer->hour = tmTime.tm_hour;
                        buffer->minute = tmTime.tm_min;
                        buffer->second = tmTime.tm_sec;

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_TIME_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_TTIMESTAMP:
                    {
                        SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<SQL_TIMESTAMP_STRUCT*>(dataPtr);

                        buffer->year = tmTime.tm_year + 1900;
                        buffer->month = tmTime.tm_mon + 1;
                        buffer->day = tmTime.tm_mday;
                        buffer->hour = tmTime.tm_hour;
                        buffer->minute = tmTime.tm_min;
                        buffer->second = tmTime.tm_sec;
                        buffer->fraction = 0;

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_TIMESTAMP_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_BINARY:
                    case OdbcNativeType::AI_DEFAULT:
                    {
                        if (dataPtr)
                            memcpy(dataPtr, &value, std::min(static_cast<size_t>(buflen), sizeof(value)));

                        if (resLenPtr)
                            *resLenPtr = sizeof(value);

                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    case OdbcNativeType::AI_SIGNED_SHORT:
                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    case OdbcNativeType::AI_SIGNED_LONG:
                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    case OdbcNativeType::AI_FLOAT:
                    case OdbcNativeType::AI_DOUBLE:
                    case OdbcNativeType::AI_NUMERIC:
                    default:
                    {
                        if (resLenPtr)
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }
            }

            void ApplicationDataBuffer::PutTimestamp(const Timestamp& value)
            {
                using namespace type_traits;

                tm tmTime;

                common::TimestampToCTm(value, tmTime);

                SqlLen* resLenPtr = GetResLen();
                void* dataPtr = GetData();

                switch (type)
                {
                    case OdbcNativeType::AI_CHAR:
                    {
                        char* buffer = reinterpret_cast<char*>(dataPtr);

                        if (buffer)
                        {
                            strftime(buffer, GetSize(), "%Y-%m-%d %H:%M:%S", &tmTime);

                            if (resLenPtr)
                                *resLenPtr = strlen(buffer);
                        }
                        else if (resLenPtr)
                            *resLenPtr = sizeof("HHHH-MM-DD HH:MM:SS") - 1;

                        break;
                    }

                    case OdbcNativeType::AI_WCHAR:
                    {
                        SQLWCHAR* buffer = reinterpret_cast<SQLWCHAR*>(dataPtr);

                        if (buffer)
                        {
                            std::string tmp(GetSize(), 0);

                            strftime(&tmp[0], GetSize(), "%Y-%m-%d %H:%M:%S", &tmTime);

                            SqlLen toCopy = std::min(static_cast<SqlLen>(strlen(tmp.c_str()) + 1), GetSize());

                            for (SqlLen i = 0; i < toCopy; ++i)
                                buffer[i] = tmp[i];

                            buffer[toCopy] = 0;

                            if (resLenPtr)
                                *resLenPtr = toCopy;
                        }
                        else if (resLenPtr)
                            *resLenPtr = sizeof("HHHH-MM-DD HH:MM:SS") - 1;

                        break;
                    }

                    case OdbcNativeType::AI_TDATE:
                    {
                        SQL_DATE_STRUCT* buffer = reinterpret_cast<SQL_DATE_STRUCT*>(dataPtr);

                        buffer->year = tmTime.tm_year + 1900;
                        buffer->month = tmTime.tm_mon + 1;
                        buffer->day = tmTime.tm_mday;

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_DATE_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_TTIME:
                    {
                        SQL_TIME_STRUCT* buffer = reinterpret_cast<SQL_TIME_STRUCT*>(dataPtr);

                        buffer->hour = tmTime.tm_hour;
                        buffer->minute = tmTime.tm_min;
                        buffer->second = tmTime.tm_sec;

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_TIME_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_TTIMESTAMP:
                    {
                        SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<SQL_TIMESTAMP_STRUCT*>(dataPtr);

                        buffer->year = tmTime.tm_year + 1900;
                        buffer->month = tmTime.tm_mon + 1;
                        buffer->day = tmTime.tm_mday;
                        buffer->hour = tmTime.tm_hour;
                        buffer->minute = tmTime.tm_min;
                        buffer->second = tmTime.tm_sec;
                        buffer->fraction = value.GetSecondFraction();

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_TIMESTAMP_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_BINARY:
                    case OdbcNativeType::AI_DEFAULT:
                    {
                        if (dataPtr)
                            memcpy(dataPtr, &value, std::min(static_cast<size_t>(buflen), sizeof(value)));

                        if (resLenPtr)
                            *resLenPtr = sizeof(value);

                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    case OdbcNativeType::AI_SIGNED_SHORT:
                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    case OdbcNativeType::AI_SIGNED_LONG:
                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    case OdbcNativeType::AI_FLOAT:
                    case OdbcNativeType::AI_DOUBLE:
                    case OdbcNativeType::AI_NUMERIC:
                    default:
                    {
                        if (resLenPtr)
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }
            }

            void ApplicationDataBuffer::PutTime(const Time& value)
            {
                using namespace type_traits;

                tm tmTime;

                common::TimeToCTm(value, tmTime);

                SqlLen* resLenPtr = GetResLen();
                void* dataPtr = GetData();

                switch (type)
                {
                    case OdbcNativeType::AI_CHAR:
                    {
                        char* buffer = reinterpret_cast<char*>(dataPtr);

                        if (buffer)
                        {
                            strftime(buffer, GetSize(), "%H:%M:%S", &tmTime);

                            if (resLenPtr)
                                *resLenPtr = strlen(buffer);
                        }
                        else if (resLenPtr)
                            *resLenPtr = sizeof("HH:MM:SS") - 1;

                        break;
                    }

                    case OdbcNativeType::AI_WCHAR:
                    {
                        SQLWCHAR* buffer = reinterpret_cast<SQLWCHAR*>(dataPtr);

                        if (buffer)
                        {
                            std::string tmp(GetSize(), 0);

                            strftime(&tmp[0], GetSize(), "%H:%M:%S", &tmTime);

                            SqlLen toCopy = std::min(static_cast<SqlLen>(strlen(tmp.c_str()) + 1), GetSize());

                            for (SqlLen i = 0; i < toCopy; ++i)
                                buffer[i] = tmp[i];

                            buffer[toCopy] = 0;

                            if (resLenPtr)
                                *resLenPtr = toCopy;
                        }
                        else if (resLenPtr)
                            *resLenPtr = sizeof("HH:MM:SS") - 1;

                        break;
                    }

                    case OdbcNativeType::AI_TTIME:
                    {
                        SQL_TIME_STRUCT* buffer = reinterpret_cast<SQL_TIME_STRUCT*>(dataPtr);

                        buffer->hour = tmTime.tm_hour;
                        buffer->minute = tmTime.tm_min;
                        buffer->second = tmTime.tm_sec;

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_TIME_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_TTIMESTAMP:
                    {
                        SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<SQL_TIMESTAMP_STRUCT*>(dataPtr);

                        buffer->year = tmTime.tm_year + 1900;
                        buffer->month = tmTime.tm_mon + 1;
                        buffer->day = tmTime.tm_mday;
                        buffer->hour = tmTime.tm_hour;
                        buffer->minute = tmTime.tm_min;
                        buffer->second = tmTime.tm_sec;
                        buffer->fraction = 0;

                        if (resLenPtr)
                            *resLenPtr = static_cast<SqlLen>(sizeof(SQL_TIMESTAMP_STRUCT));

                        break;
                    }

                    case OdbcNativeType::AI_BINARY:
                    case OdbcNativeType::AI_DEFAULT:
                    {
                        if (dataPtr)
                            memcpy(dataPtr, &value, std::min(static_cast<size_t>(buflen), sizeof(value)));

                        if (resLenPtr)
                            *resLenPtr = sizeof(value);

                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    case OdbcNativeType::AI_SIGNED_SHORT:
                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    case OdbcNativeType::AI_SIGNED_LONG:
                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    case OdbcNativeType::AI_FLOAT:
                    case OdbcNativeType::AI_DOUBLE:
                    case OdbcNativeType::AI_NUMERIC:
                    case OdbcNativeType::AI_TDATE:
                    default:
                    {
                        if (resLenPtr)
                            *resLenPtr = SQL_NO_TOTAL;
                    }
                }
            }

            std::string ApplicationDataBuffer::GetString(size_t maxLen) const
            {
                using namespace type_traits;
                std::string res;

                switch (type)
                {
                    case OdbcNativeType::AI_CHAR:
                    {
                        size_t paramLen = GetInputSize();

                        if (!paramLen)
                            break;

                        res = utility::SqlStringToString(
                            reinterpret_cast<const unsigned char*>(GetData()), static_cast<int32_t>(paramLen));

                        if (res.size() > maxLen)
                            res.resize(maxLen);

                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    case OdbcNativeType::AI_SIGNED_SHORT:
                    case OdbcNativeType::AI_SIGNED_LONG:
                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    {
                        std::stringstream converter;

                        converter << GetNum<int64_t>();

                        res = converter.str();

                        break;
                    }

                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    {
                        std::stringstream converter;

                        converter << GetNum<uint64_t>();

                        res = converter.str();

                        break;
                    }

                    case OdbcNativeType::AI_FLOAT:
                    {
                        std::stringstream converter;

                        converter << GetNum<float>();

                        res = converter.str();

                        break;
                    }

                    case OdbcNativeType::AI_NUMERIC:
                    case OdbcNativeType::AI_DOUBLE:
                    {
                        std::stringstream converter;

                        converter << GetNum<double>();

                        res = converter.str();

                        break;
                    }

                    default:
                        break;
                }

                return res;
            }

            int8_t ApplicationDataBuffer::GetInt8() const
            {
                return GetNum<int8_t>();
            }

            int16_t ApplicationDataBuffer::GetInt16() const
            {
                return GetNum<int16_t>();
            }

            int32_t ApplicationDataBuffer::GetInt32() const
            {
                return GetNum<int32_t>();
            }

            int64_t ApplicationDataBuffer::GetInt64() const
            {
                return GetNum<int64_t>();
            }

            float ApplicationDataBuffer::GetFloat() const
            {
                return GetNum<float>();
            }

            double ApplicationDataBuffer::GetDouble() const
            {
                return GetNum<double>();
            }

            Guid ApplicationDataBuffer::GetGuid() const
            {
                using namespace type_traits;

                Guid res;

                switch (type)
                {
                    case OdbcNativeType::AI_CHAR:
                    {
                        SqlLen paramLen = GetInputSize();

                        if (!paramLen)
                            break;

                        std::string str = utility::SqlStringToString(
                            reinterpret_cast<const unsigned char*>(GetData()), static_cast<int32_t>(paramLen));

                        std::stringstream converter;

                        converter << str;

                        converter >> res;

                        break;
                    }

                    case OdbcNativeType::AI_GUID:
                    {
                        const SQLGUID* guid = reinterpret_cast<const SQLGUID*>(GetData());

                        uint64_t msb = static_cast<uint64_t>(guid->Data1) << 32 |
                                       static_cast<uint64_t>(guid->Data2) << 16 |
                                       static_cast<uint64_t>(guid->Data3);

                        uint64_t lsb = 0;

                        for (size_t i = 0; i < sizeof(guid->Data4); ++i)
                            lsb = guid->Data4[i] << (sizeof(guid->Data4) - i - 1) * 8;

                        res = Guid(msb, lsb);

                        break;
                    }

                    default:
                        break;
                }

                return res;
            }

            const void* ApplicationDataBuffer::GetData() const
            {
                return ApplyOffset(buffer);
            }

            const SqlLen* ApplicationDataBuffer::GetResLen() const
            {
                return ApplyOffset(reslen);
            }

            void* ApplicationDataBuffer::GetData()
            {
                return ApplyOffset(buffer);
            }

            SqlLen* ApplicationDataBuffer::GetResLen()
            {
                return ApplyOffset(reslen);
            }

            template<typename T>
            T ApplicationDataBuffer::GetNum() const
            {
                using namespace type_traits;

                T res = T();

                switch (type)
                {
                    case OdbcNativeType::AI_CHAR:
                    {
                        SqlLen paramLen = GetInputSize();

                        if (!paramLen)
                            break;

                        std::string str = GetString(paramLen);

                        std::stringstream converter;

                        converter << str;

                        // Workaround for char types which are recognised as
                        // symbolyc types and not numeric types.
                        if (sizeof(T) == 1)
                        {
                            short tmp;

                            converter >> tmp;

                            res = static_cast<T>(tmp);
                        }
                        else
                            converter >> res;

                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    {
                        res = static_cast<T>(*reinterpret_cast<const signed char*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    {
                        res = static_cast<T>(*reinterpret_cast<const unsigned char*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_SHORT:
                    {
                        res = static_cast<T>(*reinterpret_cast<const signed short*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    {
                        res = static_cast<T>(*reinterpret_cast<const unsigned short*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_LONG:
                    {
                        res = static_cast<T>(*reinterpret_cast<const signed long*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    {
                        res = static_cast<T>(*reinterpret_cast<const unsigned long*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    {
                        res = static_cast<T>(*reinterpret_cast<const int64_t*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    {
                        res = static_cast<T>(*reinterpret_cast<const uint64_t*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_FLOAT:
                    {
                        res = static_cast<T>(*reinterpret_cast<const float*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_DOUBLE:
                    {
                        res = static_cast<T>(*reinterpret_cast<const double*>(GetData()));
                        break;
                    }

                    case OdbcNativeType::AI_NUMERIC:
                    {
                        const SQL_NUMERIC_STRUCT* numeric =
                            reinterpret_cast<const SQL_NUMERIC_STRUCT*>(GetData());

                        common::Decimal dec(reinterpret_cast<const int8_t*>(numeric->val),
                            SQL_MAX_NUMERIC_LEN, numeric->scale, numeric->sign ? 1 : -1, false);

                        res = static_cast<T>(dec.ToInt64());

                        break;
                    }

                    default:
                        break;
                }

                return res;
            }

            Date ApplicationDataBuffer::GetDate() const
            {
                using namespace type_traits;

                tm tmTime = { 0 };

                switch (type)
                {
                    case OdbcNativeType::AI_TDATE:
                    {
                        const SQL_DATE_STRUCT* buffer = reinterpret_cast<const SQL_DATE_STRUCT*>(GetData());

                        tmTime.tm_year = buffer->year - 1900;
                        tmTime.tm_mon = buffer->month - 1;
                        tmTime.tm_mday = buffer->day;

                        break;
                    }

                    case OdbcNativeType::AI_TTIME:
                    {
                        const SQL_TIME_STRUCT* buffer = reinterpret_cast<const SQL_TIME_STRUCT*>(GetData());

                        tmTime.tm_year = 70;
                        tmTime.tm_mday = 1;
                        tmTime.tm_hour = buffer->hour;
                        tmTime.tm_min = buffer->minute;
                        tmTime.tm_sec = buffer->second;

                        break;
                    }

                    case OdbcNativeType::AI_TTIMESTAMP:
                    {
                        const SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<const SQL_TIMESTAMP_STRUCT*>(GetData());

                        tmTime.tm_year = buffer->year - 1900;
                        tmTime.tm_mon = buffer->month - 1;
                        tmTime.tm_mday = buffer->day;
                        tmTime.tm_hour = buffer->hour;
                        tmTime.tm_min = buffer->minute;
                        tmTime.tm_sec = buffer->second;

                        break;
                    }

                    case OdbcNativeType::AI_CHAR:
                    {
                        SqlLen paramLen = GetInputSize();

                        if (!paramLen)
                            break;

                        std::string str = utility::SqlStringToString(
                            reinterpret_cast<const unsigned char*>(GetData()), static_cast<int32_t>(paramLen));

                        sscanf(str.c_str(), "%d-%d-%d %d:%d:%d", &tmTime.tm_year, &tmTime.tm_mon,
                            &tmTime.tm_mday, &tmTime.tm_hour, &tmTime.tm_min, &tmTime.tm_sec);

                        tmTime.tm_year = tmTime.tm_year - 1900;
                        tmTime.tm_mon = tmTime.tm_mon - 1;

                        break;
                    }

                    default:
                        break;
                }

                return common::CTmToDate(tmTime);
            }

            Timestamp ApplicationDataBuffer::GetTimestamp() const
            {
                using namespace type_traits;

                tm tmTime = { 0 };

                int32_t nanos = 0;

                switch (type)
                {
                    case OdbcNativeType::AI_TDATE:
                    {
                        const SQL_DATE_STRUCT* buffer = reinterpret_cast<const SQL_DATE_STRUCT*>(GetData());

                        tmTime.tm_year = buffer->year - 1900;
                        tmTime.tm_mon = buffer->month - 1;
                        tmTime.tm_mday = buffer->day;

                        break;
                    }

                    case OdbcNativeType::AI_TTIME:
                    {
                        const SQL_TIME_STRUCT* buffer = reinterpret_cast<const SQL_TIME_STRUCT*>(GetData());

                        tmTime.tm_year = 70;
                        tmTime.tm_mday = 1;
                        tmTime.tm_hour = buffer->hour;
                        tmTime.tm_min = buffer->minute;
                        tmTime.tm_sec = buffer->second;

                        break;
                    }

                    case OdbcNativeType::AI_TTIMESTAMP:
                    {
                        const SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<const SQL_TIMESTAMP_STRUCT*>(GetData());

                        tmTime.tm_year = buffer->year - 1900;
                        tmTime.tm_mon = buffer->month - 1;
                        tmTime.tm_mday = buffer->day;
                        tmTime.tm_hour = buffer->hour;
                        tmTime.tm_min = buffer->minute;
                        tmTime.tm_sec = buffer->second;

                        nanos = buffer->fraction;

                        break;
                    }

                    case OdbcNativeType::AI_CHAR:
                    {
                        SqlLen paramLen = GetInputSize();

                        if (!paramLen)
                            break;

                        std::string str = utility::SqlStringToString(
                            reinterpret_cast<const unsigned char*>(GetData()), static_cast<int32_t>(paramLen));

                        sscanf(str.c_str(), "%d-%d-%d %d:%d:%d", &tmTime.tm_year, &tmTime.tm_mon,
                            &tmTime.tm_mday, &tmTime.tm_hour, &tmTime.tm_min, &tmTime.tm_sec);

                        tmTime.tm_year = tmTime.tm_year - 1900;
                        tmTime.tm_mon = tmTime.tm_mon - 1;

                        break;
                    }

                    default:
                        break;
                }

                return common::CTmToTimestamp(tmTime, nanos);
            }

            Time ApplicationDataBuffer::GetTime() const
            {
                using namespace type_traits;

                tm tmTime = { 0 };

                tmTime.tm_year = 70;
                tmTime.tm_mon = 0;
                tmTime.tm_mday = 1;

                switch (type)
                {
                    case OdbcNativeType::AI_TTIME:
                    {
                        const SQL_TIME_STRUCT* buffer = reinterpret_cast<const SQL_TIME_STRUCT*>(GetData());

                        tmTime.tm_hour = buffer->hour;
                        tmTime.tm_min = buffer->minute;
                        tmTime.tm_sec = buffer->second;

                        break;
                    }

                    case OdbcNativeType::AI_TTIMESTAMP:
                    {
                        const SQL_TIMESTAMP_STRUCT* buffer = reinterpret_cast<const SQL_TIMESTAMP_STRUCT*>(GetData());

                        tmTime.tm_hour = buffer->hour;
                        tmTime.tm_min = buffer->minute;
                        tmTime.tm_sec = buffer->second;

                        break;
                    }

                    case OdbcNativeType::AI_CHAR:
                    {
                        SqlLen paramLen = GetInputSize();

                        if (!paramLen)
                            break;

                        std::string str = utility::SqlStringToString(
                            reinterpret_cast<const unsigned char*>(GetData()), static_cast<int32_t>(paramLen));

                        sscanf(str.c_str(), "%d:%d:%d", &tmTime.tm_hour, &tmTime.tm_min, &tmTime.tm_sec);

                        break;
                    }

                    default:
                        break;
                }

                return common::CTmToTime(tmTime);
            }

            void ApplicationDataBuffer::GetDecimal(common::Decimal& val) const
            {
                using namespace type_traits;

                switch (type)
                {
                    case OdbcNativeType::AI_CHAR:
                    {
                        SqlLen paramLen = GetInputSize();

                        if (!paramLen)
                            break;

                        std::string str = GetString(paramLen);

                        std::stringstream converter;

                        converter << str;

                        converter >> val;

                        break;
                    }

                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_SIGNED_SHORT:
                    case OdbcNativeType::AI_SIGNED_LONG:
                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    {
                        val.AssignInt64(GetNum<int64_t>());

                        break;
                    }

                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                    case OdbcNativeType::AI_UNSIGNED_LONG:
                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                    {
                        val.AssignUint64(GetNum<uint64_t>());

                        break;
                    }

                    case OdbcNativeType::AI_FLOAT:
                    case OdbcNativeType::AI_DOUBLE:
                    {
                        val.AssignDouble(GetNum<double>());

                        break;
                    }

                    case OdbcNativeType::AI_NUMERIC:
                    {
                        const SQL_NUMERIC_STRUCT* numeric =
                            reinterpret_cast<const SQL_NUMERIC_STRUCT*>(GetData());

                        common::Decimal dec(reinterpret_cast<const int8_t*>(numeric->val),
                            SQL_MAX_NUMERIC_LEN, numeric->scale, numeric->sign ? 1 : -1, false);

                        val.Swap(dec);

                        break;
                    }

                    default:
                    {
                        val.AssignInt64(0);

                        break;
                    }
                }
            }

            template<typename T>
            T* ApplicationDataBuffer::ApplyOffset(T* ptr) const
            {
                if (!ptr || !offset || !*offset)
                    return ptr;

                return utility::GetPointerWithOffset(ptr, **offset);
            }

            bool ApplicationDataBuffer::IsDataAtExec() const
            {
                const SqlLen* resLenPtr = GetResLen();

                if (!resLenPtr)
                    return false;

                int32_t ilen = static_cast<int32_t>(*resLenPtr);

                return ilen <= SQL_LEN_DATA_AT_EXEC_OFFSET || ilen == SQL_DATA_AT_EXEC;
            }

            SqlLen ApplicationDataBuffer::GetDataAtExecSize() const
            {
                using namespace type_traits;

                switch (type)
                {
                    case OdbcNativeType::AI_WCHAR:
                    case OdbcNativeType::AI_CHAR:
                    case OdbcNativeType::AI_BINARY:
                    {
                        const SqlLen* resLenPtr = GetResLen();

                        if (!resLenPtr)
                            return 0;

                        int32_t ilen = static_cast<int32_t>(*resLenPtr);

                        if (ilen <= SQL_LEN_DATA_AT_EXEC_OFFSET)
                            ilen = SQL_LEN_DATA_AT_EXEC(ilen);
                        else
                            ilen = 0;

                        if (type == OdbcNativeType::AI_WCHAR)
                            ilen *= 2;

                        return ilen;
                    }

                    case OdbcNativeType::AI_SIGNED_SHORT:
                    case OdbcNativeType::AI_UNSIGNED_SHORT:
                        return static_cast<SqlLen>(sizeof(short));

                    case OdbcNativeType::AI_SIGNED_LONG:
                    case OdbcNativeType::AI_UNSIGNED_LONG:
                        return static_cast<SqlLen>(sizeof(long));

                    case OdbcNativeType::AI_FLOAT:
                        return static_cast<SqlLen>(sizeof(float));

                    case OdbcNativeType::AI_DOUBLE:
                        return static_cast<SqlLen>(sizeof(double));

                    case OdbcNativeType::AI_BIT:
                    case OdbcNativeType::AI_SIGNED_TINYINT:
                    case OdbcNativeType::AI_UNSIGNED_TINYINT:
                        return static_cast<SqlLen>(sizeof(char));

                    case OdbcNativeType::AI_SIGNED_BIGINT:
                    case OdbcNativeType::AI_UNSIGNED_BIGINT:
                        return static_cast<SqlLen>(sizeof(SQLBIGINT));

                    case OdbcNativeType::AI_TDATE:
                        return static_cast<SqlLen>(sizeof(SQL_DATE_STRUCT));

                    case OdbcNativeType::AI_TTIME:
                        return static_cast<SqlLen>(sizeof(SQL_TIME_STRUCT));

                    case OdbcNativeType::AI_TTIMESTAMP:
                        return static_cast<SqlLen>(sizeof(SQL_TIMESTAMP_STRUCT));

                    case OdbcNativeType::AI_NUMERIC:
                        return static_cast<SqlLen>(sizeof(SQL_NUMERIC_STRUCT));

                    case OdbcNativeType::AI_GUID:
                        return static_cast<SqlLen>(sizeof(SQLGUID));

                    case OdbcNativeType::AI_DEFAULT:
                    case OdbcNativeType::AI_UNSUPPORTED:
                    default:
                        break;
                }

                return 0;
            }

            SqlLen ApplicationDataBuffer::GetInputSize() const
            {
                if (!IsDataAtExec())
                {
                    const SqlLen *len = GetResLen();

                    return len ? *len : SQL_DEFAULT_PARAM;
                }

                return GetDataAtExecSize();
            }
        }
    }
}


text:
@interface YPPushAnimator : YPBaseAnimator <UIViewControllerAnimatedTransitioning>

@end


text:
#ifndef HostWindow_h
#define HostWindow_h

#include "platform/PlatformExport.h"
#include "platform/graphics/paint/DisplayItemClient.h"
#include "wtf/FastAllocBase.h"
#include "wtf/Noncopyable.h"

namespace blink {
class IntRect;
struct WebScreenInfo;

class PLATFORM_EXPORT HostWindow {
    WTF_MAKE_NONCOPYABLE(HostWindow); WTF_MAKE_FAST_ALLOCATED;
public:
    HostWindow() { }
    virtual ~HostWindow() { }

    // Requests the host invalidate the contents.
    virtual void invalidateRect(const IntRect& updateRect) = 0;

    // Requests the host to invalidate display items, if owned by the host
    // window. At present Chrome does not (display items are owned by the
    // GraphicsLayer instead), but PopupContainerClient does.
    virtual void invalidateDisplayItemClient(DisplayItemClient) { }
    virtual void invalidateAllDisplayItems() { }

    // Converts from the window coordinates to screen coordinates.
    virtual IntRect viewportToScreen(const IntRect&) const = 0;

    virtual WebScreenInfo screenInfo() const = 0;

    virtual void scheduleAnimation() = 0;
};

} // namespace blink

#endif // HostWindow_h


text:
package edu.jhu.prim.iter;

public class IntArrayIter implements IntIter {

    private final int[] values;
    private int cur;

    /**
     * Constructs a new IntIter which ranges from start (inclusive) to end (exclusive) by steps of incr.
     *
     * @param values The values over which to iterate.
     * @param incr The increment value.
     */
    public IntArrayIter(int... values) {
        this.values = values;
        this.cur = 0;
    }

    @Override
    public int next() {
        if (!hasNext()) {
            throw new IllegalStateException();
        }
        return values[cur++];
    }

    @Override
    public boolean hasNext() {
        return cur < values.length;
    }

    @Override
    public void reset() {
        this.cur = 0;
    }

}


text:
package gemlite.maven.plugin.support;

import gemlite.maven.plugin.support.mapper.MapperToolProcessor;
import gemlite.maven.plugin.support.serialize.DataSerializeProcessor;
import gemlite.maven.plugin.support.serialize.PdxSerializeProcessor;

import java.util.HashMap;
import java.util.Map;

public class AnnotationProcessorFactory implements DomainMojoConstant
{

  private final static Map<String, ClassProcessor> processorMap = new HashMap<>();
  static
  {
    ClassProcessor process = new DataSerializeProcessor();
    processorMap.put(AN_AutoSerialize_Ds, process);

    process = new PdxSerializeProcessor();
    processorMap.put(AN_AutoSerialize_Pdx, process);

    process = new MapperToolProcessor();
    processorMap.put(AN_Table, process);
    processorMap.put(AN_Region, process);
    processorMap.put(AN_Key, process);

  }

  public final static ClassProcessor getProcessor(String annDesc)
  {
    return processorMap.get(annDesc);
  }

}


text:
package org.sweble.wikitext.engine.nodes;

import org.sweble.wikitext.parser.nodes.CompleteWikitextVisitorNoReturn;

public interface CompleteEngineVisitorNoReturn
		extends
			CompleteWikitextVisitorNoReturn
{
	public void visit(EngProcessedPage n);

	public void visit(EngNowiki n);

	public void visit(EngPage n);

	public void visit(EngSoftErrorNode n);
}


text:
package com.cbooy.cakes.jdk.atomic.test;

/**
 * AtomicReferenceFieldUpdater练习
 *
 * 对指定类的指定的volatile引用字段进行原子更新,字段不可为private
 *
 * @author haoc
 */
public class AtomicReferenceFieldUpdaterTest {

}