text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="30dp"
    android:gravity="center">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="horizontal">

        <android.support.v7.widget.CardView
            style="@style/cardview"
            android:layout_marginEnd="10dp"
            android:layout_marginRight="10dp"
            app:cardElevation="@dimen/card_elevation">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/cocas"
                    style="@style/department_type"
                    android:background="@color/ew_card_color"
                    android:text="@string/type_cocas" />

                <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/cocas_image"
                    style="@style/circle_imageview"
                    android:layout_below="@+id/cocas"
                    app:civ_border_color="#FF000000"
                    app:civ_border_width="2dp" />

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/cocas"
                    android:layout_toEndOf="@+id/cocas_image"
                    android:layout_toRightOf="@+id/cocas_image"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/cocas_name"
                        style="@style/profile_name"
                        android:text="@string/cocas_name" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/cocas_name"
                        android:layout_centerInParent="true"
                        android:orientation="horizontal">

                        <ImageButton
                            android:id="@+id/mail_cocas"
                            style="@style/image_button"
                            android:layout_marginEnd="@dimen/image_button_margin"
                            android:layout_marginRight="@dimen/image_button_margin"
                            android:src="@drawable/ic_email_black_24dp" />

                        <ImageButton
                            android:id="@+id/phone_cocas"
                            style="@style/image_button"
                            android:src="@drawable/ic_phone_black_24dp" />

                    </LinearLayout>

                </RelativeLayout>

            </RelativeLayout>

        </android.support.v7.widget.CardView>

        <android.support.v7.widget.CardView
            style="@style/cardview"
            app:cardElevation="@dimen/card_elevation">

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

                <TextView
                    android:id="@+id/has"
                    style="@style/department_type"
                    android:background="@color/ew_card_color"
                    android:text="@string/type_has" />

                <de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
                    android:id="@+id/has_image"
                    style="@style/circle_imageview"
                    android:layout_below="@+id/has"
                    app:civ_border_color="#FF000000"
                    app:civ_border_width="2dp" />

                <RelativeLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/has"
                    android:layout_toEndOf="@+id/has_image"
                    android:layout_toRightOf="@+id/has_image"
                    android:gravity="center">

                    <TextView
                        android:id="@+id/has_name"
                        style="@style/profile_name"
                        android:text="@string/has_name" />

                    <LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@+id/has_name"
                        android:layout_centerInParent="true"
                        android:orientation="horizontal">

                        <ImageButton
                            android:id="@+id/mail_has"
                            style="@style/image_button"
                            android:layout_marginEnd="@dimen/image_button_margin"
                            android:layout_marginRight="@dimen/image_button_margin"
                            android:src="@drawable/ic_email_black_24dp" />

                        <ImageButton
                            android:id="@+id/phone_has"
                            style="@style/image_button"
                            android:src="@drawable/ic_phone_black_24dp" />

                    </LinearLayout>

                </RelativeLayout>
            </RelativeLayout>

        </android.support.v7.widget.CardView>

    </LinearLayout>
</RelativeLayout>


text:
/*****************************************************************************************************************************************
Author: Michael Shoots
Email: michael.shoots@live.com
Project: Open Space 4x
License: MIT License
Notes:
******************************************************************************************************************************************/

using UnityEngine;
using System.Collections.Generic;

public class HardPoints : MonoBehaviour
{
    public List<HardPointSet> foreWeaponHardPoints;
    public List<HardPointSet> aftWeaponHardPoints;
    public List<HardPointSet> portWeaponHardPoints;
    public List<HardPointSet> starboardWeaponHardPoints;
    public List<GameObject> damageHardPoints = new List<GameObject>();

    public void DestroyAllObjects()
    {
        foreach(HardPointSet set in foreWeaponHardPoints)
        {
            set.DestroyChildren();
            Destroy(set.gameObject);
        }

        foreach (HardPointSet set in aftWeaponHardPoints)
        {
            set.DestroyChildren();
            Destroy(set.gameObject);
        }

        foreach (HardPointSet set in portWeaponHardPoints)
        {
            set.DestroyChildren();
            Destroy(set.gameObject);
        }

        foreach (HardPointSet set in starboardWeaponHardPoints)
        {
            set.DestroyChildren();
            Destroy(set.gameObject);
        }

        foreach (GameObject point in damageHardPoints)
        {
            Destroy(point);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package net.violet.platform.util.cache;

public class GenerationException extends Exception {

	public GenerationException(String message, Throwable cause) {
		super(message, cause);
	}

	public GenerationException(Throwable cause) {
		super(cause);
	}

	public GenerationException(String message) {
		super(message);
	}

}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<title>WebFilter (Servlet 3.1 API Documentation - Apache Tomcat 8.0.14)</title>
<meta name="date" content="2014-09-24">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">

JavaScript is disabled on your browser.

Overview

Package

Class

Tree

Deprecated

Index

Help

Servlet 3.1 - Apache Tomcat 8.0.14

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Required |

Optional

Detail:

Element

javax.servlet.annotation

Annotation Type WebFilter

@Target(value=TYPE)
@Retention(value=RUNTIME)
@Documented
public @interface WebFilter

The annotation used to declare a Servlet Filter.

 This annotation will be processed by the container during deployment, the
 Filter class in which it is found will be created as per the configuration
 and applied to the URL patterns, Servlets and
 DispatcherTypes.

 If the name attribute is not defined, the fully qualified name of the class
 is used.

 At least one URL pattern MUST be declared in either the value or
 urlPattern attribute of the annotation, but not both.

 The value attribute is recommended for use when the URL pattern is
 the only attribute being set, otherwise the urlPattern attribute
 should be used.

 The annotated class MUST implement Filter.

 E.g.

 @WebFilter("/path/*")

 public class AnExampleFilter implements Filter { ...

Since:

Servlet 3.0 (Section 8.1.2)

Optional Element Summary

Optional Elements

Modifier and Type
Optional Element and Description

boolean
asyncSupported

java.lang.String
description

DispatcherType[]
dispatcherTypes

java.lang.String
displayName

java.lang.String
filterName

WebInitParam[]
initParams

java.lang.String
largeIcon

java.lang.String[]
servletNames

java.lang.String
smallIcon

java.lang.String[]
urlPatterns

java.lang.String[]
value

A convenience method, to allow extremely simple annotation of a class.

Element Detail

description

public abstract java.lang.String description

Returns:

description of the Filter, if present

Default:

""

displayName

public abstract java.lang.String displayName

Returns:

display name of the Filter, if present

Default:

""

initParams

public abstract WebInitParam[] initParams

Returns:

array of initialization params for this Filter

Default:

{}

filterName

public abstract java.lang.String filterName

Returns:

name of the Filter, if present

Default:

""

smallIcon

public abstract java.lang.String smallIcon

Returns:

small icon for this Filter, if present

Default:

""

largeIcon

public abstract java.lang.String largeIcon

Returns:

the large icon for this Filter, if present

Default:

""

servletNames

public abstract java.lang.String[] servletNames

Returns:

array of Servlet names to which this Filter applies

Default:

{}

value

public abstract java.lang.String[] value

A convenience method, to allow extremely simple annotation of a class.

Returns:

array of URL patterns

See Also:

urlPatterns()

Default:

{}

urlPatterns

public abstract java.lang.String[] urlPatterns

Returns:

array of URL patterns to which this Filter applies

Default:

{}

dispatcherTypes

public abstract DispatcherType[] dispatcherTypes

Returns:

array of DispatcherTypes to which this filter applies

Default:

javax.servlet.DispatcherType.REQUEST

asyncSupported

public abstract boolean asyncSupported

Returns:

asynchronous operation supported by this Filter

Default:

false

Overview

Package

Class

Tree

Deprecated

Index

Help

Servlet 3.1 - Apache Tomcat 8.0.14

Prev Class

Next Class

Frames

No Frames

All Classes

Summary:

Required |

Optional

Detail:

Element

Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.


text:
package Paws::StorageGateway::ListVolumesOutput;
  use Moose;
  has GatewayARN => (is => 'ro', isa => 'Str');
  has Marker => (is => 'ro', isa => 'Str');
  has VolumeInfos => (is => 'ro', isa => 'ArrayRef[Paws::StorageGateway::VolumeInfo]');

  has _request_id => (is => 'ro', isa => 'Str');

### main pod documentation begin ###

=head1 NAME

Paws::StorageGateway::ListVolumesOutput

=head1 ATTRIBUTES

=head2 GatewayARN => Str

=head2 Marker => Str

=head2 VolumeInfos => ArrayRef[L<Paws::StorageGateway::VolumeInfo>]

=head2 _request_id => Str

=cut

1;


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Jewelry Shop</title>
<link rel="stylesheet" type="text/css" href="style.css" />

home

about us

jewels

specials jewels

my accout

register

prices

contact

            home >> category name

Category jewels

                        product name

                        product name

                        product name

                        product name

                        product name

                        product name

                        product name

                        product name

                        product name

                        product name

                        product name

            <<123…1011>>

            Languages:

                Currency:
                GBP
                EUR
                USD

My cart

                  3 x items | TOTAL: 100$

                  view cart

About Our Shop

             Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud.

Promotions

                        product name

                        product name

                        product name

Categories

accesories

jewel gifts

specials

hollidays gifts

accesories

jewel gifts

specials

hollidays gifts

accesories

jewel gifts

specials

Partners

accesories

jewel gifts

specials

hollidays gifts

accesories

jewel gifts

specials

hollidays gifts

accesories

        home
        about us
        services
        privacy policy
        contact us

Powered by premium Flash Templates


text: Домашние задания по курсу http://software-testing.ru/trainings/schedule?task=3&


text:
package jp.scriptkidie.datacopy.sql.model.cosmos;

public class Musnhhc {
    private Long gmtSetNo;

    private String ssyaCd;

    private String egsCd;

    private String kitiCd;

    private Integer recRegYmd;

    private Integer recUpdYmd;

    private Short recUpdJnjNo;

    private String n1TekiyoCd;

    public Long getGmtSetNo() {
        return gmtSetNo;
    }

    public void setGmtSetNo(Long gmtSetNo) {
        this.gmtSetNo = gmtSetNo;
    }

    public String getSsyaCd() {
        return ssyaCd;
    }

    public void setSsyaCd(String ssyaCd) {
        this.ssyaCd = ssyaCd == null ? null : ssyaCd.trim();
    }

    public String getEgsCd() {
        return egsCd;
    }

    public void setEgsCd(String egsCd) {
        this.egsCd = egsCd == null ? null : egsCd.trim();
    }

    public String getKitiCd() {
        return kitiCd;
    }

    public void setKitiCd(String kitiCd) {
        this.kitiCd = kitiCd == null ? null : kitiCd.trim();
    }

    public Integer getRecRegYmd() {
        return recRegYmd;
    }

    public void setRecRegYmd(Integer recRegYmd) {
        this.recRegYmd = recRegYmd;
    }

    public Integer getRecUpdYmd() {
        return recUpdYmd;
    }

    public void setRecUpdYmd(Integer recUpdYmd) {
        this.recUpdYmd = recUpdYmd;
    }

    public Short getRecUpdJnjNo() {
        return recUpdJnjNo;
    }

    public void setRecUpdJnjNo(Short recUpdJnjNo) {
        this.recUpdJnjNo = recUpdJnjNo;
    }

    public String getN1TekiyoCd() {
        return n1TekiyoCd;
    }

    public void setN1TekiyoCd(String n1TekiyoCd) {
        this.n1TekiyoCd = n1TekiyoCd == null ? null : n1TekiyoCd.trim();
    }
}


text:
#include "2d/CCTMXObjectGroup.h"
#include "base/ccMacros.h"

NS_CC_BEGIN

//implementation TMXObjectGroup

TMXObjectGroup::TMXObjectGroup()
    : _groupName("")
{
}

TMXObjectGroup::~TMXObjectGroup()
{
    CCLOGINFO("deallocing TMXObjectGroup: %p", this);
}

ValueMap TMXObjectGroup::getObject(const std::string& objectName) const
{
    if (!_objects.empty())
    {
        for (const auto& v : _objects)
        {
            const ValueMap& dict = v.asValueMap();
            if (dict.find("name") != dict.end())
            {
                if (dict.at("name").asString() == objectName)
                    return dict;
            }
        }
    }

    // object not found
    return ValueMap();
}

Value TMXObjectGroup::getProperty(const std::string& propertyName) const
{
    if (_properties.find(propertyName) != _properties.end())
        return _properties.at(propertyName);

    return Value();
}

NS_CC_END


text:
deployments = "/opt/torquebox-current/jboss/standalone/deployments"

def initialize(*args)
  super
  @action ||= :deploy
end

action :deploy do
  execute "torquebox deploy #{new_resource.path}" do
    creates "#{deployments}/#{new_resource.name}-knob.yml.deployed"
  end
end

action :undeploy do
  execute "torquebox undeploy #{new_resource.path}" do
    creates "#{deployments}/#{new_resource.name}-knob.yml.undeployed"
  end
end


text:
<?php

/**
 * GdgGearman\Controller\Worker\AbstractPrototype
 *
 * @author Gab Amba <gamba@gabbydgab.com>
 * @package GdgGearman\Controller\Worker
 */

namespace GdgGearman\Controller\Worker;

use GdgGearman\Worker\Adapter\WorkerStrategyAdapter;
use GearmanJob;

abstract class AbstractPrototype implements AwareInterface
{
    private $_functionName = "";

    private $_callableFunction = "_doWork";

    /**
     * @var GearmanWorker
     */
    private $_worker;

    /**
     * @var \GdgGearman\Worker\Adapter\WorkerStrategyAdapter
     */
    private $_adapter;

    /**
     * Sets the name of a function to register with the job server
     *
     * @param String $functionName
     */
    public function setFunctionName($functionName)
    {
        $this->_functionName = $functionName;
    }

    /**
     * Gets the name of a function to register with the job server
     *
     * @return String $_functionName
     */
    public function getFunctionName()
    {
        return $this->_functionName;
    }

    /**
     * Adapter implementation for worker strategies
     *
     * @param \GdgGearman\Worker\Adapter\WorkerStrategyAdapter $adapter
     */
    public function setAdapter(WorkerStrategyAdapter $adapter)
    {
        $this->_adapter = $adapter;
    }

    /**
     *
     * @return \GdgGearman\Worker\Adapter\WorkerStrategyAdapter
     */
    public function getAdapter()
    {
        return $this->_adapter;
    }

    public function setGearmanWorker(\GearmanWorker $worker)
    {
        $this->_worker = $worker;
    }

    public function getGearmanWorker()
    {
        return $this->_worker;
    }

    /**
     * @return void
     */
    public function performWorkAction()
    {
        $this->getGearmanWorker()->addFunction(
            $this->getFunctionName(),
            [$this, $this->_callableFunction]
        );

        while (true) {
            $this->getGearmanWorker()->work();
            if ($this->getGearmanWorker()->returnCode() != "GEARMAN_SUCCESS") {
                break;
            }
        }
    }

    private function _doWork(\GearmanJob $job)
    {
        $this->_payload = [];
        $this->getAdapter()->init($this->_payload);

        return $this->getAdapter()->executeWork();
    }
}


text:
package org.hisp.dhis.android.dashboard.api.models;

import com.raizlabs.android.dbflow.annotation.Column;
import com.raizlabs.android.dbflow.annotation.Table;
import com.raizlabs.android.dbflow.sql.builder.Condition;
import com.raizlabs.android.dbflow.sql.language.Select;

import org.hisp.dhis.android.dashboard.api.models.meta.DbDhis;

@Table(databaseName = DbDhis.NAME)
public final class DataMap extends BaseIdentifiableObject {
    @Column(name = "basemap")
    private String basemap;
    @Column(name = "latitude")
    private String latitude;
    @Column(name = "longitude")
    private String longitude;
    @Column(name = "zoom")
    private String zoom;

    public String getBasemap() {
        return basemap;
    }

    public void setBasemap(String basemap) {
        this.basemap = basemap;
    }

    public String getLatitude() {
        return latitude;
    }

    public void setLatitude(String latitude) {
        this.latitude = latitude;
    }

    public String getLongitude() {
        return longitude;
    }

    public void setLongitude(String longitude) {
        this.longitude = longitude;
    }

    public String getZoom() {
        return zoom;
    }

    public void setZoom(String zoom) {
        this.zoom = zoom;
    }

    public static DataMap getById(String uid) {
        return new Select()
                .from(DataMap.class)
                .where(Condition.column(DataMap$Table
                        .UID).is(uid))
                .querySingle();
    }
}


text:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;

namespace MongoDB.Bson.IO
{
    /// <summary>
    /// Represents a BSON reader for a JSON string.
    /// </summary>
    public class JsonReader : BsonReader
    {
        // private fields
        private readonly JsonBuffer _buffer;
        private readonly JsonReaderSettings _jsonReaderSettings; // same value as in base class just declared as derived class
        private JsonReaderContext _context;
        private JsonToken _currentToken;
        private BsonValue _currentValue;
        private JsonToken _pushedToken;

        // constructors
        /// <summary>
        /// Initializes a new instance of the JsonReader class.
        /// </summary>
        /// <param name="json">The JSON string.</param>
        public JsonReader(string json)
            : this(json, JsonReaderSettings.Defaults)
        {
        }

        /// <summary>
        /// Initializes a new instance of the JsonReader class.
        /// </summary>
        /// <param name="json">The JSON string.</param>
        /// <param name="settings">The reader settings.</param>
        public JsonReader(string json, JsonReaderSettings settings)
            : this(new JsonBuffer(json), settings)
        {
        }

        /// <summary>
        /// Initializes a new instance of the JsonReader class.
        /// </summary>
        /// <param name="textReader">The TextReader.</param>
        public JsonReader(TextReader textReader)
            : this(textReader, JsonReaderSettings.Defaults)
        {
        }

        /// <summary>
        /// Initializes a new instance of the JsonReader class.
        /// </summary>
        /// <param name="textReader">The TextReader.</param>
        /// <param name="settings">The reader settings.</param>
        public JsonReader(TextReader textReader, JsonReaderSettings settings)
            : this(new JsonBuffer(textReader), settings)
        {
        }

        private JsonReader(JsonBuffer buffer, JsonReaderSettings settings)
            : base(settings)
        {
            _buffer = buffer;
            _jsonReaderSettings = settings; // already frozen by base class
            _context = new JsonReaderContext(null, ContextType.TopLevel);
        }

        // public methods
        /// <summary>
        /// Closes the reader.
        /// </summary>
        public override void Close()
        {
            // Close can be called on Disposed objects
            State = BsonReaderState.Closed;
        }

        /// <summary>
        /// Gets a bookmark to the reader's current position and state.
        /// </summary>
        /// <returns>A bookmark.</returns>
        public override BsonReaderBookmark GetBookmark()
        {
            return new JsonReaderBookmark(State, CurrentBsonType, CurrentName, _context, _currentToken, _currentValue, _pushedToken, _buffer.Position);
        }

        /// <summary>
        /// Determines whether this reader is at end of file.
        /// </summary>
        /// <returns>
        /// Whether this reader is at end of file.
        /// </returns>
        public override bool IsAtEndOfFile()
        {
            int c;
            while ((c = _buffer.Read()) != -1)
            {
                if (!char.IsWhiteSpace((char)c))
                {
                    _buffer.UnRead(c);
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// Reads BSON binary data from the reader.
        /// </summary>
        /// <returns>A BsonBinaryData.</returns>
        public override BsonBinaryData ReadBinaryData()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadBinaryData", BsonType.Binary);
            State = GetNextState();
            return _currentValue.AsBsonBinaryData;
        }

        /// <summary>
        /// Reads a BSON boolean from the reader.
        /// </summary>
        /// <returns>A Boolean.</returns>
        public override bool ReadBoolean()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadBoolean", BsonType.Boolean);
            State = GetNextState();
            return _currentValue.AsBoolean;
        }

        /// <summary>
        /// Reads a BsonType from the reader.
        /// </summary>
        /// <returns>A BsonType.</returns>
        public override BsonType ReadBsonType()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            if (State == BsonReaderState.Initial || State == BsonReaderState.Done || State == BsonReaderState.ScopeDocument)
            {
                if (State == BsonReaderState.Initial || State == BsonReaderState.Done)
                {
                    _buffer.ResetBuffer();
                }

                // in JSON the top level value can be of any type so fall through
                State = BsonReaderState.Type;
            }
            if (State != BsonReaderState.Type)
            {
                ThrowInvalidState("ReadBsonType", BsonReaderState.Type);
            }

            if (_context.ContextType == ContextType.Document)
            {
                var nameToken = PopToken();
                switch (nameToken.Type)
                {
                    case JsonTokenType.String:
                    case JsonTokenType.UnquotedString:
                        CurrentName = nameToken.StringValue;
                        break;
                    case JsonTokenType.EndObject:
                        State = BsonReaderState.EndOfDocument;
                        return BsonType.EndOfDocument;
                    default:
                        var message = string.Format("JSON reader was expecting a name but found '{0}'.", nameToken.Lexeme);
                        throw new FileFormatException(message);
                }

                var colonToken = PopToken();
                if (colonToken.Type != JsonTokenType.Colon)
                {
                    var message = string.Format("JSON reader was expecting ':' but found '{0}'.", colonToken.Lexeme);
                    throw new FileFormatException(message);
                }
            }

            var valueToken = PopToken();
            if (_context.ContextType == ContextType.Array && valueToken.Type == JsonTokenType.EndArray)
            {
                State = BsonReaderState.EndOfArray;
                return BsonType.EndOfDocument;
            }

            var noValueFound = false;
            switch (valueToken.Type)
            {
                case JsonTokenType.BeginArray:
                    CurrentBsonType = BsonType.Array;
                    break;
                case JsonTokenType.BeginObject:
                    CurrentBsonType = ParseExtendedJson();
                    break;
                case JsonTokenType.DateTime:
                    CurrentBsonType = BsonType.DateTime;
                    _currentValue = valueToken.DateTimeValue;
                    break;
                case JsonTokenType.Double:
                    CurrentBsonType = BsonType.Double;
                    _currentValue = valueToken.DoubleValue;
                    break;
                case JsonTokenType.EndOfFile:
                    CurrentBsonType = BsonType.EndOfDocument;
                    break;
                case JsonTokenType.Int32:
                    CurrentBsonType = BsonType.Int32;
                    _currentValue = valueToken.Int32Value;
                    break;
                case JsonTokenType.Int64:
                    CurrentBsonType = BsonType.Int64;
                    _currentValue = valueToken.Int64Value;
                    break;
                case JsonTokenType.ObjectId:
                    CurrentBsonType = BsonType.ObjectId;
                    _currentValue = valueToken.ObjectIdValue;
                    break;
                case JsonTokenType.RegularExpression:
                    CurrentBsonType = BsonType.RegularExpression;
                    _currentValue = valueToken.RegularExpressionValue;
                    break;
                case JsonTokenType.String:
                    CurrentBsonType = BsonType.String;
                    _currentValue = valueToken.StringValue;
                    break;
                case JsonTokenType.UnquotedString:
                    switch (valueToken.Lexeme)
                    {
                        case "false":
                        case "true":
                            CurrentBsonType = BsonType.Boolean;
                            _currentValue = XmlConvert.ToBoolean(valueToken.Lexeme);
                            break;
                        case "Infinity":
                            CurrentBsonType = BsonType.Double;
                            _currentValue = double.PositiveInfinity;
                            break;
                        case "NaN":
                            CurrentBsonType = BsonType.Double;
                            _currentValue = double.NaN;
                            break;
                        case "null":
                            CurrentBsonType = BsonType.Null;
                            break;
                        case "undefined":
                            CurrentBsonType = BsonType.Undefined;
                            break;
                        case "BinData":
                            CurrentBsonType = BsonType.Binary;
                            _currentValue = ParseBinDataConstructor();
                            break;
                        case "Date":
                            CurrentBsonType = BsonType.String;
                            _currentValue = ParseDateTimeConstructor(false); // withNew = false
                            break;
                        case "HexData":
                            CurrentBsonType = BsonType.Binary;
                            _currentValue = ParseHexDataConstructor();
                            break;
                        case "ISODate":
                            CurrentBsonType = BsonType.DateTime;
                            _currentValue = ParseISODateTimeConstructor();
                            break;
                        case "NumberLong":
                            CurrentBsonType = BsonType.Int64;
                            _currentValue = ParseNumberLongConstructor();
                            break;
                        case "ObjectId":
                            CurrentBsonType = BsonType.ObjectId;
                            _currentValue = ParseObjectIdConstructor();
                            break;
                        case "RegExp":
                            CurrentBsonType = BsonType.RegularExpression;
                            _currentValue = ParseRegularExpressionConstructor();
                            break;
                        case "UUID":
                        case "GUID":
                        case "CSUUID":
                        case "CSGUID":
                        case "JUUID":
                        case "JGUID":
                        case "PYUUID":
                        case "PYGUID":
                            CurrentBsonType = BsonType.Binary;
                            _currentValue = ParseUUIDConstructor(valueToken.Lexeme);
                            break;
                        case "new":
                            CurrentBsonType = ParseNew(out _currentValue);
                            break;
                        default:
                            noValueFound = true;
                            break;
                    }
                    break;
                default:
                    noValueFound = true;
                    break;
            }
            if (noValueFound)
            {
                var message = string.Format("JSON reader was expecting a value but found '{0}'.", valueToken.Lexeme);
                throw new FileFormatException(message);
            }
            _currentToken = valueToken;

            if (_context.ContextType == ContextType.Array || _context.ContextType == ContextType.Document)
            {
                var commaToken = PopToken();
                if (commaToken.Type != JsonTokenType.Comma)
                {
                    PushToken(commaToken);
                }
            }

            switch (_context.ContextType)
            {
                case ContextType.Document:
                case ContextType.ScopeDocument:
                default:
                    State = BsonReaderState.Name;
                    break;
                case ContextType.Array:
                case ContextType.JavaScriptWithScope:
                case ContextType.TopLevel:
                    State = BsonReaderState.Value;
                    break;
            }
            return CurrentBsonType;
        }

        /// <summary>
        /// Reads BSON binary data from the reader.
        /// </summary>
        /// <returns>A byte array.</returns>
        public override byte[] ReadBytes()
        {
#pragma warning disable 618
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadBinaryData", BsonType.Binary);
            State = GetNextState();
            var binaryData = _currentValue.AsBsonBinaryData;

            var subType = binaryData.SubType;
            if (subType != BsonBinarySubType.Binary && subType != BsonBinarySubType.OldBinary)
            {
                var message = string.Format("ReadBytes requires the binary sub type to be Binary, not {2}.", subType);
                throw new FileFormatException(message);
            }

            return binaryData.Bytes;
#pragma warning restore
        }

        /// <summary>
        /// Reads a BSON DateTime from the reader.
        /// </summary>
        /// <returns>The number of milliseconds since the Unix epoch.</returns>
        public override long ReadDateTime()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadDateTime", BsonType.DateTime);
            State = GetNextState();
            return _currentValue.AsBsonDateTime.MillisecondsSinceEpoch;
        }

        /// <summary>
        /// Reads a BSON Double from the reader.
        /// </summary>
        /// <returns>A Double.</returns>
        public override double ReadDouble()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadDouble", BsonType.Double);
            State = GetNextState();
            return _currentValue.AsDouble;
        }

        /// <summary>
        /// Reads the end of a BSON array from the reader.
        /// </summary>
        public override void ReadEndArray()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            if (_context.ContextType != ContextType.Array)
            {
                ThrowInvalidContextType("ReadEndArray", _context.ContextType, ContextType.Array);
            }
            if (State == BsonReaderState.Type)
            {
                ReadBsonType(); // will set state to EndOfArray if at end of array
            }
            if (State != BsonReaderState.EndOfArray)
            {
                ThrowInvalidState("ReadEndArray", BsonReaderState.EndOfArray);
            }

            _context = _context.PopContext();
            switch (_context.ContextType)
            {
                case ContextType.Array: State = BsonReaderState.Type; break;
                case ContextType.Document: State = BsonReaderState.Type; break;
                case ContextType.TopLevel: State = BsonReaderState.Done; break;
                default: throw new BsonInternalException("Unexpected ContextType.");
            }

            if (_context.ContextType == ContextType.Array || _context.ContextType == ContextType.Document)
            {
                var commaToken = PopToken();
                if (commaToken.Type != JsonTokenType.Comma)
                {
                    PushToken(commaToken);
                }
            }
        }

        /// <summary>
        /// Reads the end of a BSON document from the reader.
        /// </summary>
        public override void ReadEndDocument()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            if (_context.ContextType != ContextType.Document && _context.ContextType != ContextType.ScopeDocument)
            {
                ThrowInvalidContextType("ReadEndDocument", _context.ContextType, ContextType.Document, ContextType.ScopeDocument);
            }
            if (State == BsonReaderState.Type)
            {
                ReadBsonType(); // will set state to EndOfDocument if at end of document
            }
            if (State != BsonReaderState.EndOfDocument)
            {
                ThrowInvalidState("ReadEndDocument", BsonReaderState.EndOfDocument);
            }

            _context = _context.PopContext();
            if (_context != null && _context.ContextType == ContextType.JavaScriptWithScope)
            {
                _context = _context.PopContext(); // JavaScriptWithScope
                VerifyToken("}"); // outermost closing bracket for JavaScriptWithScope
            }
            switch (_context.ContextType)
            {
                case ContextType.Array: State = BsonReaderState.Type; break;
                case ContextType.Document: State = BsonReaderState.Type; break;
                case ContextType.TopLevel: State = BsonReaderState.Done; break;
                default: throw new BsonInternalException("Unexpected ContextType");
            }

            if (_context.ContextType == ContextType.Array || _context.ContextType == ContextType.Document)
            {
                var commaToken = PopToken();
                if (commaToken.Type != JsonTokenType.Comma)
                {
                    PushToken(commaToken);
                }
            }
        }

        /// <summary>
        /// Reads a BSON Int32 from the reader.
        /// </summary>
        /// <returns>An Int32.</returns>
        public override int ReadInt32()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadInt32", BsonType.Int32);
            State = GetNextState();
            return _currentValue.AsInt32;
        }

        /// <summary>
        /// Reads a BSON Int64 from the reader.
        /// </summary>
        /// <returns>An Int64.</returns>
        public override long ReadInt64()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadInt64", BsonType.Int64);
            State = GetNextState();
            return _currentValue.AsInt64;
        }

        /// <summary>
        /// Reads a BSON JavaScript from the reader.
        /// </summary>
        /// <returns>A string.</returns>
        public override string ReadJavaScript()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadJavaScript", BsonType.JavaScript);
            State = GetNextState();
            return _currentValue.AsString;
        }

        /// <summary>
        /// Reads a BSON JavaScript with scope from the reader (call ReadStartDocument next to read the scope).
        /// </summary>
        /// <returns>A string.</returns>
        public override string ReadJavaScriptWithScope()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadJavaScriptWithScope", BsonType.JavaScriptWithScope);
            _context = new JsonReaderContext(_context, ContextType.JavaScriptWithScope);
            State = BsonReaderState.ScopeDocument;
            return _currentValue.AsString;
        }

        /// <summary>
        /// Reads a BSON MaxKey from the reader.
        /// </summary>
        public override void ReadMaxKey()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadMaxKey", BsonType.MaxKey);
            State = GetNextState();
        }

        /// <summary>
        /// Reads a BSON MinKey from the reader.
        /// </summary>
        public override void ReadMinKey()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadMinKey", BsonType.MinKey);
            State = GetNextState();
        }

        /// <summary>
        /// Reads the name of an element from the reader.
        /// </summary>
        /// <returns>
        /// The name of the element.
        /// </returns>
        public override string ReadName()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            if (State == BsonReaderState.Type)
            {
                ReadBsonType();
            }
            if (State != BsonReaderState.Name)
            {
                ThrowInvalidState("ReadName", BsonReaderState.Name);
            }

            State = BsonReaderState.Value;
            return CurrentName;
        }

        /// <summary>
        /// Reads a BSON null from the reader.
        /// </summary>
        public override void ReadNull()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadNull", BsonType.Null);
            State = GetNextState();
        }

        /// <summary>
        /// Reads a BSON ObjectId from the reader.
        /// </summary>
        /// <returns>An ObjectId.</returns>
        public override ObjectId ReadObjectId()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadObjectId", BsonType.ObjectId);
            State = GetNextState();
            return _currentValue.AsObjectId;
        }

        /// <summary>
        /// Reads a BSON regular expression from the reader.
        /// </summary>
        /// <returns>A BsonRegularExpression.</returns>
        public override BsonRegularExpression ReadRegularExpression()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadRegularExpression", BsonType.RegularExpression);
            State = GetNextState();
            return _currentValue.AsBsonRegularExpression;
        }

        /// <summary>
        /// Reads the start of a BSON array.
        /// </summary>
        public override void ReadStartArray()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadStartArray", BsonType.Array);

            _context = new JsonReaderContext(_context, ContextType.Array);
            State = BsonReaderState.Type;
        }

        /// <summary>
        /// Reads the start of a BSON document.
        /// </summary>
        public override void ReadStartDocument()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadStartDocument", BsonType.Document);

            _context = new JsonReaderContext(_context, ContextType.Document);
            State = BsonReaderState.Type;
        }

        /// <summary>
        /// Reads a BSON string from the reader.
        /// </summary>
        /// <returns>A String.</returns>
        public override string ReadString()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadString", BsonType.String);
            State = GetNextState();
            return _currentValue.AsString;
        }

        /// <summary>
        /// Reads a BSON symbol from the reader.
        /// </summary>
        /// <returns>A string.</returns>
        public override string ReadSymbol()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadSymbol", BsonType.Symbol);
            State = GetNextState();
            return _currentValue.AsString;
        }

        /// <summary>
        /// Reads a BSON timestamp from the reader.
        /// </summary>
        /// <returns>The combined timestamp/increment.</returns>
        public override long ReadTimestamp()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadTimestamp", BsonType.Timestamp);
            State = GetNextState();
            var timestamp = _currentValue.AsBsonTimestamp;
            return timestamp.Value;
        }

        /// <summary>
        /// Reads a BSON undefined from the reader.
        /// </summary>
        public override void ReadUndefined()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            VerifyBsonType("ReadUndefined", BsonType.Undefined);
            State = GetNextState();
        }

        /// <summary>
        /// Returns the reader to previously bookmarked position and state.
        /// </summary>
        /// <param name="bookmark">The bookmark.</param>
        public override void ReturnToBookmark(BsonReaderBookmark bookmark)
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            var jsonReaderBookmark = (JsonReaderBookmark)bookmark;
            State = jsonReaderBookmark.State;
            CurrentBsonType = jsonReaderBookmark.CurrentBsonType;
            CurrentName = jsonReaderBookmark.CurrentName;
            _context = jsonReaderBookmark.CloneContext();
            _currentToken = jsonReaderBookmark.CurrentToken;
            _currentValue = jsonReaderBookmark.CurrentValue;
            _pushedToken = jsonReaderBookmark.PushedToken;
            _buffer.Position = jsonReaderBookmark.Position;
        }

        /// <summary>
        /// Skips the name (reader must be positioned on a name).
        /// </summary>
        public override void SkipName()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            if (State != BsonReaderState.Name)
            {
                ThrowInvalidState("SkipName", BsonReaderState.Name);
            }

            State = BsonReaderState.Value;
        }

        /// <summary>
        /// Skips the value (reader must be positioned on a value).
        /// </summary>
        public override void SkipValue()
        {
            if (Disposed) { ThrowObjectDisposedException(); }
            if (State != BsonReaderState.Value)
            {
                ThrowInvalidState("SkipValue", BsonReaderState.Value);
            }

            switch (CurrentBsonType)
            {
                case BsonType.Array:
                    ReadStartArray();
                    while (ReadBsonType() != BsonType.EndOfDocument)
                    {
                        SkipValue();
                    }
                    ReadEndArray();
                    break;
                case BsonType.Binary:
                    ReadBinaryData();
                    break;
                case BsonType.Boolean:
                    ReadBoolean();
                    break;
                case BsonType.DateTime:
                    ReadDateTime();
                    break;
                case BsonType.Document:
                    ReadStartDocument();
                    while (ReadBsonType() != BsonType.EndOfDocument)
                    {
                        SkipName();
                        SkipValue();
                    }
                    ReadEndDocument();
                    break;
                case BsonType.Double:
                    ReadDouble();
                    break;
                case BsonType.Int32:
                    ReadInt32();
                    break;
                case BsonType.Int64:
                    ReadInt64();
                    break;
                case BsonType.JavaScript:
                    ReadJavaScript();
                    break;
                case BsonType.JavaScriptWithScope:
                    ReadJavaScriptWithScope();
                    ReadStartDocument();
                    while (ReadBsonType() != BsonType.EndOfDocument)
                    {
                        SkipName();
                        SkipValue();
                    }
                    ReadEndDocument();
                    break;
                case BsonType.MaxKey:
                    ReadMaxKey();
                    break;
                case BsonType.MinKey:
                    ReadMinKey();
                    break;
                case BsonType.Null:
                    ReadNull();
                    break;
                case BsonType.ObjectId:
                    ReadObjectId();
                    break;
                case BsonType.RegularExpression:
                    ReadRegularExpression();
                    break;
                case BsonType.String:
                    ReadString();
                    break;
                case BsonType.Symbol:
                    ReadSymbol();
                    break;
                case BsonType.Timestamp:
                    ReadTimestamp();
                    break;
                case BsonType.Undefined:
                    ReadUndefined();
                    break;
                default:
                    throw new BsonInternalException("Invalid BsonType.");
            }
        }

        // protected methods
        /// <summary>
        /// Disposes of any resources used by the reader.
        /// </summary>
        /// <param name="disposing">True if called from Dispose.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                try
                {
                    Close();
                }
                catch { } // ignore exceptions
            }
            base.Dispose(disposing);
        }

        // private methods
        private string FormatInvalidTokenMessage(JsonToken token)
        {
            return string.Format("Invalid JSON token: '{0}'", token.Lexeme);
        }

        private string FormatJavaScriptDateTimeString(DateTime dateTime)
        {
            var utc = BsonUtils.ToUniversalTime(dateTime);
            var local = BsonUtils.ToLocalTime(utc);
            var offset = local - utc;
            var offsetSign = "+";
            if (offset < TimeSpan.Zero)
            {
                offset = -offset;
                offsetSign = "-";
            }
            var timeZone = TimeZone.CurrentTimeZone;
            var timeZoneName = local.IsDaylightSavingTime() ? timeZone.DaylightName : timeZone.StandardName;
            var dateTimeString = string.Format(
                "{0} GMT{1}{2:D2}{3:D2} ({4})",
                local.ToString("ddd MMM dd yyyy HH:mm:ss"), offsetSign, offset.Hours, offset.Minutes, timeZoneName);
            return dateTimeString;
        }

        private BsonReaderState GetNextState()
        {
            switch (_context.ContextType)
            {
                case ContextType.Array:
                case ContextType.Document:
                    return BsonReaderState.Type;
                case ContextType.TopLevel:
                    return BsonReaderState.Done;
                default:
                    throw new BsonInternalException("Unexpected ContextType.");
            }
        }

        private BsonValue ParseBinDataConstructor()
        {
            VerifyToken("(");
            var subTypeToken = PopToken();
            if (subTypeToken.Type != JsonTokenType.Int32)
            {
                var message = string.Format("JSON reader expected a binary subtype but found '{0}'.", subTypeToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(",");
            var bytesToken = PopToken();
            if (bytesToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", bytesToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(")");
            var bytes = Convert.FromBase64String(bytesToken.StringValue);
            var subType = (BsonBinarySubType)subTypeToken.Int32Value;
            GuidRepresentation guidRepresentation;
            switch (subType)
            {
                case BsonBinarySubType.UuidLegacy: guidRepresentation = _jsonReaderSettings.GuidRepresentation; break;
                case BsonBinarySubType.UuidStandard: guidRepresentation = GuidRepresentation.Standard; break;
                default: guidRepresentation = GuidRepresentation.Unspecified; break;
            }
            return new BsonBinaryData(bytes, subType, guidRepresentation);
        }

        private BsonValue ParseBinDataExtendedJson()
        {
            VerifyToken(":");
            var bytesToken = PopToken();
            if (bytesToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", bytesToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(",");
            VerifyString("$type");
            VerifyToken(":");
            var subTypeToken = PopToken();
            if (subTypeToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", subTypeToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken("}");
            var bytes = Convert.FromBase64String(bytesToken.StringValue);
            var subType = (BsonBinarySubType)Convert.ToInt32(subTypeToken.StringValue, 16);
            GuidRepresentation guidRepresentation;
            switch (subType)
            {
                case BsonBinarySubType.UuidLegacy: guidRepresentation = _jsonReaderSettings.GuidRepresentation; break;
                case BsonBinarySubType.UuidStandard: guidRepresentation = GuidRepresentation.Standard; break;
                default: guidRepresentation = GuidRepresentation.Unspecified; break;
            }
            return new BsonBinaryData(bytes, subType, guidRepresentation);
        }

        private BsonValue ParseHexDataConstructor()
        {
            VerifyToken("(");
            var subTypeToken = PopToken();
            if (subTypeToken.Type != JsonTokenType.Int32)
            {
                var message = string.Format("JSON reader expected a binary subtype but found '{0}'.", subTypeToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(",");
            var bytesToken = PopToken();
            if (bytesToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", bytesToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(")");
            var bytes = BsonUtils.ParseHexString(bytesToken.StringValue);
            var subType = (BsonBinarySubType)subTypeToken.Int32Value;
            GuidRepresentation guidRepresentation;
            switch (subType)
            {
                case BsonBinarySubType.UuidLegacy: guidRepresentation = _jsonReaderSettings.GuidRepresentation; break;
                case BsonBinarySubType.UuidStandard: guidRepresentation = GuidRepresentation.Standard; break;
                default: guidRepresentation = GuidRepresentation.Unspecified; break;
            }
            return new BsonBinaryData(bytes, subType, guidRepresentation);
        }

        private BsonType ParseJavaScriptExtendedJson(out BsonValue value)
        {
            VerifyToken(":");
            var codeToken = PopToken();
            if (codeToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", codeToken.Lexeme);
                throw new FileFormatException(message);
            }
            var nextToken = PopToken();
            switch (nextToken.Type)
            {
                case JsonTokenType.Comma:
                    VerifyString("$scope");
                    VerifyToken(":");
                    State = BsonReaderState.Value;
                    value = codeToken.StringValue;
                    return BsonType.JavaScriptWithScope;
                case JsonTokenType.EndObject:
                    value = codeToken.StringValue;
                    return BsonType.JavaScript;
                default:
                    var message = string.Format("JSON reader expected ',' or '}' but found '{0}'.", codeToken.Lexeme);
                    throw new FileFormatException(message);
            }
        }

        private BsonValue ParseISODateTimeConstructor()
        {
            VerifyToken("(");
            var valueToken = PopToken();
            if (valueToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", valueToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(")");
            var formats = new string[] { "yyyy-MM-ddK", "yyyy-MM-ddTHH:mm:ssK", "yyyy-MM-ddTHH:mm:ss.FFFFFFFK" };
            var utcDateTime = DateTime.ParseExact(valueToken.StringValue, formats, null, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal);
            return new BsonDateTime(utcDateTime);
        }

        private BsonValue ParseDateTimeExtendedJson()
        {
            VerifyToken(":");
            var valueToken = PopToken();

            long millisecondsSinceEpoch;
            if (valueToken.Type == JsonTokenType.Int32 || valueToken.Type == JsonTokenType.Int64)
            {
                millisecondsSinceEpoch = valueToken.Int64Value;
            }
            else if (valueToken.Type == JsonTokenType.String)
            {
                DateTime dateTime;
                if (!DateTime.TryParse(valueToken.StringValue, out dateTime))
                {
                    var message = string.Format("Invalid $date string: '{0}'.", valueToken.StringValue);
                    throw new FileFormatException(message);
                }
                millisecondsSinceEpoch = BsonUtils.ToMillisecondsSinceEpoch(dateTime);
            }
            else
            {
                var message = string.Format("JSON reader expected an integer or an ISO 8601 string for $date but found a '{0}'.", valueToken.Lexeme);
                throw new FileFormatException(message);
            }

            VerifyToken("}");
            return new BsonDateTime(millisecondsSinceEpoch);
        }

        private BsonValue ParseDateTimeConstructor(bool withNew)
        {
            VerifyToken("(");

            // Date when used without "new" behaves differently (JavaScript has some weird parts)
            if (!withNew)
            {
                VerifyToken(")");
                var dateTimeString = FormatJavaScriptDateTimeString(DateTime.UtcNow);
                return new BsonString(dateTimeString);
            }

            var token = PopToken();
            if (token.Lexeme == ")")
            {
                return new BsonDateTime(DateTime.UtcNow);
            }
            else if (token.Type == JsonTokenType.String)
            {
                VerifyToken(")");
                var dateTimeString = token.StringValue;
                var dateTime = ParseJavaScriptDateTimeString(dateTimeString);
                return new BsonDateTime(dateTime);
            }
            else if (token.Type == JsonTokenType.Int32 || token.Type == JsonTokenType.Int64)
            {
                var args = new List<long>();
                while (true)
                {
                    args.Add(token.Int64Value);
                    token = PopToken();
                    if (token.Lexeme == ")")
                    {
                        break;
                    }
                    if (token.Lexeme != ",")
                    {
                        var message = string.Format("JSON reader expected a ',' or a ')' but found '{0}'.", token.Lexeme);
                        throw new FileFormatException(message);
                    }
                    token = PopToken();
                    if (token.Type != JsonTokenType.Int32 && token.Type != JsonTokenType.Int64)
                    {
                        var message = string.Format("JSON reader expected an integer but found '{0}'.", token.Lexeme);
                        throw new FileFormatException(message);
                    }
                }
                switch (args.Count)
                {
                    case 1:
                        return new BsonDateTime(args[0]);
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                        var year = (int)args[0];
                        var month = (int)args[1] + 1; // JavaScript starts at 0 but .NET starts at 1
                        var day = (int)args[2];
                        var hours = (args.Count >= 4) ? (int)args[3] : 0;
                        var minutes = (args.Count >= 5) ? (int)args[4] : 0;
                        var seconds = (args.Count >= 6) ? (int)args[5] : 0;
                        var milliseconds = (args.Count == 7) ? (int)args[6] : 0;
                        var dateTime = new DateTime(year, month, day, hours, minutes, seconds, milliseconds, DateTimeKind.Utc);
                        return new BsonDateTime(dateTime);
                    default:
                        var message = string.Format("JSON reader expected 1 or 3-7 integers but found {0}.", args.Count);
                        throw new FileFormatException(message);
                }
            }
            else
            {
                var message = string.Format("JSON reader expected an integer or a string but found '{0}'.", token.Lexeme);
                throw new FileFormatException(message);
            }
        }

        private BsonType ParseExtendedJson()
        {
            var nameToken = PopToken();
            if (nameToken.Type == JsonTokenType.String || nameToken.Type == JsonTokenType.UnquotedString)
            {
                switch (nameToken.StringValue)
                {
                    case "$binary": _currentValue = ParseBinDataExtendedJson(); return BsonType.Binary;
                    case "$code": return ParseJavaScriptExtendedJson(out _currentValue);
                    case "$date": _currentValue = ParseDateTimeExtendedJson(); return BsonType.DateTime;
                    case "$maxkey": _currentValue = ParseMaxKeyExtendedJson(); return BsonType.MaxKey;
                    case "$minkey": _currentValue = ParseMinKeyExtendedJson(); return BsonType.MinKey;
                    case "$oid": _currentValue = ParseObjectIdExtendedJson(); return BsonType.ObjectId;
                    case "$regex": _currentValue = ParseRegularExpressionExtendedJson(); return BsonType.RegularExpression;
                    case "$symbol": _currentValue = ParseSymbolExtendedJson(); return BsonType.Symbol;
                    case "$timestamp": _currentValue = ParseTimestampExtendedJson(); return BsonType.Timestamp;
                }
            }
            PushToken(nameToken);
            return BsonType.Document;
        }

        private DateTime ParseJavaScriptDateTimeString(string dateTimeString)
        {
            // if DateTime.TryParse succeeds we're done, otherwise assume it's an RFC 822 formatted DateTime string
            DateTime dateTime;
            if (DateTime.TryParse(dateTimeString, out dateTime))
            {
                return dateTime;
            }
            else
            {
                var rfc822DateTimePattern =
                    @"^((?<dayOfWeek>(Mon|Tue|Wed|Thu|Fri|Sat|Sun)), )?" +
                    @"(?<day>\d{1,2}) +" +
                    @"(?<monthName>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) " +
                    @"(?<year>\d{2}|\d{4}) " +
                    @"(?<hour>\d{1,2}):" +
                    @"(?<minutes>\d{1,2}):" +
                    @"(?<seconds>\d{1,2}(.\d{1,7})?) " +
                    @"(?<zone>UT|GMT|EST|EDT|CST|CDT|MST|MDT|PST|PDT|[A-Z]|([+-]\d{4}))$";
                var match = Regex.Match(dateTimeString, rfc822DateTimePattern);
                if (match.Success)
                {
                    var day = int.Parse(match.Groups["day"].Value);

                    int month;
                    var monthName = match.Groups["monthName"].Value;
                    switch (monthName)
                    {
                        case "Jan": month = 1; break;
                        case "Feb": month = 2; break;
                        case "Mar": month = 3; break;
                        case "Apr": month = 4; break;
                        case "May": month = 5; break;
                        case "Jun": month = 6; break;
                        case "Jul": month = 7; break;
                        case "Aug": month = 8; break;
                        case "Sep": month = 9; break;
                        case "Oct": month = 10; break;
                        case "Nov": month = 11; break;
                        case "Dec": month = 12; break;
                        default:
                            var message = string.Format("\"{0}\" is not a valid RFC 822 month name.", monthName);
                            throw new FileFormatException(message);
                    }

                    var yearString = match.Groups["year"].Value;
                    int year = int.Parse(yearString);
                    if (yearString.Length == 2)
                    {
                        year += 2000;
                        if (year - DateTime.UtcNow.Year >= 19) { year -= 100; }
                    }

                    var hour = int.Parse(match.Groups["hour"].Value);
                    var minutes = int.Parse(match.Groups["minutes"].Value);
                    var secondsString = match.Groups["seconds"].Value;
                    int seconds;
                    double milliseconds;
                    if (secondsString.IndexOf('.') != -1)
                    {
                        var timeSpan = TimeSpan.FromSeconds(double.Parse(secondsString));
                        seconds = timeSpan.Seconds;
                        milliseconds = timeSpan.TotalMilliseconds - seconds * 1000;
                    }
                    else
                    {
                        seconds = int.Parse(secondsString);
                        milliseconds = 0;
                    }

                    dateTime = new DateTime(year, month, day, hour, minutes, seconds, DateTimeKind.Utc).AddMilliseconds(milliseconds);

                    // check day of week before converting to UTC
                    var dayOfWeekString = match.Groups["dayOfWeek"].Value;
                    if (dayOfWeekString != "")
                    {
                        DayOfWeek dayOfWeek;
                        switch (dayOfWeekString)
                        {
                            case "Mon": dayOfWeek = DayOfWeek.Monday; break;
                            case "Tue": dayOfWeek = DayOfWeek.Tuesday; break;
                            case "Wed": dayOfWeek = DayOfWeek.Wednesday; break;
                            case "Thu": dayOfWeek = DayOfWeek.Thursday; break;
                            case "Fri": dayOfWeek = DayOfWeek.Friday; break;
                            case "Sat": dayOfWeek = DayOfWeek.Saturday; break;
                            case "Sun": dayOfWeek = DayOfWeek.Sunday; break;
                            default:
                                var message = string.Format("\"{0}\" is not a valid RFC 822 day name.", dayOfWeekString);
                                throw new FileFormatException(message);
                        }
                        if (dateTime.DayOfWeek != dayOfWeek)
                        {
                            var message = string.Format("\"{0}\" is not the right day of the week for {1}.", dayOfWeekString, dateTime.ToString("o"));
                            throw new FileFormatException(message);
                        }
                    }

                    TimeSpan offset;
                    var zone = match.Groups["zone"].Value;
                    switch (zone)
                    {
                        case "UT": case "GMT": case "Z": offset = TimeSpan.Zero; break;
                        case "EST": offset = TimeSpan.FromHours(-5); break;
                        case "EDT": offset = TimeSpan.FromHours(-4); break;
                        case "CST": offset = TimeSpan.FromHours(-6); break;
                        case "CDT": offset = TimeSpan.FromHours(-5); break;
                        case "MST": offset = TimeSpan.FromHours(-7); break;
                        case "MDT": offset = TimeSpan.FromHours(-6); break;
                        case "PST": offset = TimeSpan.FromHours(-8); break;
                        case "PDT": offset = TimeSpan.FromHours(-7); break;
                        case "A": offset = TimeSpan.FromHours(-1); break;
                        case "B": offset = TimeSpan.FromHours(-2); break;
                        case "C": offset = TimeSpan.FromHours(-3); break;
                        case "D": offset = TimeSpan.FromHours(-4); break;
                        case "E": offset = TimeSpan.FromHours(-5); break;
                        case "F": offset = TimeSpan.FromHours(-6); break;
                        case "G": offset = TimeSpan.FromHours(-7); break;
                        case "H": offset = TimeSpan.FromHours(-8); break;
                        case "I": offset = TimeSpan.FromHours(-9); break;
                        case "K": offset = TimeSpan.FromHours(-10); break;
                        case "L": offset = TimeSpan.FromHours(-11); break;
                        case "M": offset = TimeSpan.FromHours(-12); break;
                        case "N": offset = TimeSpan.FromHours(1); break;
                        case "O": offset = TimeSpan.FromHours(2); break;
                        case "P": offset = TimeSpan.FromHours(3); break;
                        case "Q": offset = TimeSpan.FromHours(4); break;
                        case "R": offset = TimeSpan.FromHours(5); break;
                        case "S": offset = TimeSpan.FromHours(6); break;
                        case "T": offset = TimeSpan.FromHours(7); break;
                        case "U": offset = TimeSpan.FromHours(8); break;
                        case "V": offset = TimeSpan.FromHours(9); break;
                        case "W": offset = TimeSpan.FromHours(10); break;
                        case "X": offset = TimeSpan.FromHours(11); break;
                        case "Y": offset = TimeSpan.FromHours(12); break;
                        default:
                            var offsetSign = zone.Substring(0);
                            var offsetHours = zone.Substring(1, 2);
                            var offsetMinutes = zone.Substring(3, 2);
                            offset = TimeSpan.FromHours(int.Parse(offsetHours)) + TimeSpan.FromMinutes(int.Parse(offsetMinutes));
                            if (offsetSign == "-")
                            {
                                offset = -offset;
                            }
                            break;
                    }

                    return dateTime.Add(-offset);
                }
                else
                {
                    var message = string.Format("The DateTime string \"{0}\" is not a valid DateTime string for either .NET or JavaScript.", dateTimeString);
                    throw new FileFormatException(message);
                }
            }
        }

        private BsonValue ParseMaxKeyExtendedJson()
        {
            VerifyToken(":");
            VerifyToken("1");
            VerifyToken("}");
            return BsonMaxKey.Value;
        }

        private BsonValue ParseMinKeyExtendedJson()
        {
            VerifyToken(":");
            VerifyToken("1");
            VerifyToken("}");
            return BsonMinKey.Value;
        }

        private BsonType ParseNew(out BsonValue value)
        {
            var typeToken = PopToken();
            if (typeToken.Type != JsonTokenType.UnquotedString)
            {
                var message = string.Format("JSON reader expected a type name but found '{0}'.", typeToken.Lexeme);
                throw new FileFormatException(message);
            }
            switch (typeToken.Lexeme)
            {
                case "BinData":
                    value = ParseBinDataConstructor();
                    return BsonType.Binary;
                case "Date":
                    value = ParseDateTimeConstructor(true); // withNew = true
                    return BsonType.DateTime;
                case "HexData":
                    value = ParseHexDataConstructor();
                    return BsonType.Binary;
                case "ISODate":
                    value = ParseISODateTimeConstructor();
                    return BsonType.DateTime;
                case "NumberLong":
                    value = ParseNumberLongConstructor();
                    return BsonType.Int64;
                case "ObjectId":
                    value = ParseObjectIdConstructor();
                    return BsonType.ObjectId;
                case "RegExp":
                    value = ParseRegularExpressionConstructor();
                    return BsonType.RegularExpression;
                case "UUID":
                case "GUID":
                case "CSUUID":
                case "CSGUID":
                case "JUUID":
                case "JGUID":
                case "PYUUID":
                case "PYGUID":
                    value = ParseUUIDConstructor(typeToken.Lexeme);
                    return BsonType.Binary;
                default:
                    var message = string.Format("JSON reader expected a type name but found '{0}'.", typeToken.Lexeme);
                    throw new FileFormatException(message);
            }
        }

        private BsonValue ParseNumberLongConstructor()
        {
            VerifyToken("(");
            var valueToken = PopToken();
            long value;
            if (valueToken.Type == JsonTokenType.Int32 || valueToken.Type == JsonTokenType.Int64)
            {
                value = valueToken.Int64Value;
            }
            else if (valueToken.Type == JsonTokenType.String)
            {
                value = long.Parse(valueToken.StringValue);
            }
            else
            {
                var message = string.Format("JSON reader expected an integer or a string but found '{0}'.", valueToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(")");
            return new BsonInt64(value);
        }

        private BsonValue ParseObjectIdConstructor()
        {
            VerifyToken("(");
            var valueToken = PopToken();
            if (valueToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", valueToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(")");
            return new BsonObjectId(ObjectId.Parse(valueToken.StringValue));
        }

        private BsonValue ParseObjectIdExtendedJson()
        {
            VerifyToken(":");
            var valueToken = PopToken();
            if (valueToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", valueToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken("}");
            return new BsonObjectId(ObjectId.Parse(valueToken.StringValue));
        }

        private BsonValue ParseRegularExpressionConstructor()
        {
            VerifyToken("(");
            var patternToken = PopToken();
            if (patternToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", patternToken.Lexeme);
                throw new FileFormatException(message);
            }
            var options = "";
            var commaToken = PopToken();
            if (commaToken.Lexeme == ",")
            {
                var optionsToken = PopToken();
                if (optionsToken.Type != JsonTokenType.String)
                {
                    var message = string.Format("JSON reader expected a string but found '{0}'.", optionsToken.Lexeme);
                    throw new FileFormatException(message);
                }
                options = optionsToken.StringValue;
            }
            else
            {
                PushToken(commaToken);
            }
            VerifyToken(")");
            return new BsonRegularExpression(patternToken.StringValue, options);
        }

        private BsonValue ParseRegularExpressionExtendedJson()
        {
            VerifyToken(":");
            var patternToken = PopToken();
            if (patternToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", patternToken.Lexeme);
                throw new FileFormatException(message);
            }
            var options = "";
            var commaToken = PopToken();
            if (commaToken.Lexeme == ",")
            {
                VerifyString("$options");
                VerifyToken(":");
                var optionsToken = PopToken();
                if (optionsToken.Type != JsonTokenType.String)
                {
                    var message = string.Format("JSON reader expected a string but found '{0}'.", optionsToken.Lexeme);
                    throw new FileFormatException(message);
                }
                options = optionsToken.StringValue;
            }
            else
            {
                PushToken(commaToken);
            }
            VerifyToken("}");
            return new BsonRegularExpression(patternToken.StringValue, options);
        }

        private BsonValue ParseSymbolExtendedJson()
        {
            VerifyToken(":");
            var nameToken = PopToken();
            if (nameToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", nameToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken("}");
            return new BsonString(nameToken.StringValue); // will be converted to a BsonSymbol at a higher level
        }

        private BsonValue ParseTimestampExtendedJson()
        {
            VerifyToken(":");
            var valueToken = PopToken();
            long value;
            if (valueToken.Type == JsonTokenType.Int32 || valueToken.Type == JsonTokenType.Int64)
            {
                value = valueToken.Int64Value;
            }
            else if (valueToken.Type == JsonTokenType.UnquotedString && valueToken.Lexeme == "NumberLong")
            {
                value = ParseNumberLongConstructor().AsInt64;
            }
            else
            {
                var message = string.Format("JSON reader expected an integer but found '{0}'.", valueToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken("}");
            return new BsonTimestamp(value);
        }

        private BsonValue ParseUUIDConstructor(string uuidConstructorName)
        {
            VerifyToken("(");
            var bytesToken = PopToken();
            if (bytesToken.Type != JsonTokenType.String)
            {
                var message = string.Format("JSON reader expected a string but found '{0}'.", bytesToken.Lexeme);
                throw new FileFormatException(message);
            }
            VerifyToken(")");
            var hexString = bytesToken.StringValue.Replace("{", "").Replace("}", "").Replace("-", "");
            var bytes = BsonUtils.ParseHexString(hexString);
            var guid = GuidConverter.FromBytes(bytes, GuidRepresentation.Standard);
            GuidRepresentation guidRepresentation;
            switch (uuidConstructorName)
            {
                case "CSUUID":
                case "CSGUID":
                    guidRepresentation = GuidRepresentation.CSharpLegacy;
                    break;
                case "JUUID":
                case "JGUID":
                    guidRepresentation = GuidRepresentation.JavaLegacy;
                    break;
                case "PYUUID":
                case "PYGUID":
                    guidRepresentation = GuidRepresentation.PythonLegacy;
                    break;
                case "UUID":
                case "GUID":
                    guidRepresentation = GuidRepresentation.Standard;
                    break;
                default:
                    throw new BsonInternalException("Unexpected uuidConstructorName");
            }
            bytes = GuidConverter.ToBytes(guid, guidRepresentation);
            var subType = (guidRepresentation == GuidRepresentation.Standard) ? BsonBinarySubType.UuidStandard : BsonBinarySubType.UuidLegacy;
            return new BsonBinaryData(bytes, subType, guidRepresentation);
        }

        private JsonToken PopToken()
        {
            if (_pushedToken != null)
            {
                var token = _pushedToken;
                _pushedToken = null;
                return token;
            }
            else
            {
                return JsonScanner.GetNextToken(_buffer);
            }
        }

        private void PushToken(JsonToken token)
        {
            if (_pushedToken == null)
            {
                _pushedToken = token;
            }
            else
            {
                throw new BsonInternalException("There is already a pending token.");
            }
        }

        private void VerifyString(string expectedString)
        {
            var token = PopToken();
            if ((token.Type != JsonTokenType.String && token.Type != JsonTokenType.UnquotedString) || token.StringValue != expectedString)
            {
                var message = string.Format("JSON reader expected '{0}' but found '{1}'.", expectedString, token.StringValue);
                throw new FileFormatException(message);
            }
        }

        private void VerifyToken(string expectedLexeme)
        {
            var token = PopToken();
            if (token.Lexeme != expectedLexeme)
            {
                var message = string.Format("JSON reader expected '{0}' but found '{1}'.", expectedLexeme, token.Lexeme);
                throw new FileFormatException(message);
            }
        }
    }
}


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
          "http://www.w3.org/TR/html4/strict.dtd">

  <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>AddressSanitizer, a fast memory error detector</title>
  <link type="text/css" rel="stylesheet" href="../menu.css">
  <link type="text/css" rel="stylesheet" href="../content.css">

AddressSanitizer

 Introduction

 How to Build

 Usage

 __has_feature(address_sanitizer)

        __attribute__((no_address_safety_analysis))

 Supported Platforms

 Limitations

 Current Status

 More Information

Introduction

AddressSanitizer is a fast memory error detector.
It consists of a compiler instrumentation module and a run-time library.
The tool can detect the following types of bugs:

 Out-of-bounds accesses to  heap, stack and globals

 Use-after-free

 Use-after-return (to some extent)

 Double-free, invalid free

Typical slowdown introduced by AddressSanitizer is 2x.

How to build

Follow the clang build instructions.

Usage

Simply compile and link your program with <tt>-faddress-sanitizer</tt> flag.

To get a reasonable performance add <tt>-O1</tt> or higher.

To get nicer stack traces in error messages add
<tt>-fno-omit-frame-pointer</tt>.

To get perfect stack traces you may need to disable inlining (just use <tt>-O1</tt>) and tail call
elimination (</tt>-fno-optimize-sibling-calls</tt>).

% cat example_UseAfterFree.cc
int main(int argc, char **argv) {
  int *array = new int[100];
  delete [] array;
  return array[argc];  // BOOM
}

% clang -O1 -g -faddress-sanitizer -fno-omit-frame-pointer example_UseAfterFree.cc

If a bug is detected, the program will print an error message to stderr and exit with a
non-zero exit code.
Currently, AddressSanitizer does not symbolize its output, so you may need to use a
separate script to symbolize the result offline (this will be fixed in future).

% ./a.out 2> log
% projects/compiler-rt/lib/asan/scripts/asan_symbolize.py / < log | c++filt
==9442== ERROR: AddressSanitizer heap-use-after-free on address 0x7f7ddab8c084 at pc 0x403c8c bp 0x7fff87fb82d0 sp 0x7fff87fb82c8
READ of size 4 at 0x7f7ddab8c084 thread T0
    #0 0x403c8c in main example_UseAfterFree.cc:4
    #1 0x7f7ddabcac4d in __libc_start_main ??:0
0x7f7ddab8c084 is located 4 bytes inside of 400-byte region [0x7f7ddab8c080,0x7f7ddab8c210)
freed by thread T0 here:
    #0 0x404704 in operator delete[](void*) ??:0
    #1 0x403c53 in main example_UseAfterFree.cc:4
    #2 0x7f7ddabcac4d in __libc_start_main ??:0
previously allocated by thread T0 here:
    #0 0x404544 in operator new[](unsigned long) ??:0
    #1 0x403c43 in main example_UseAfterFree.cc:2
    #2 0x7f7ddabcac4d in __libc_start_main ??:0
==9442== ABORTING

__has_feature(address_sanitizer)

In some cases one may need to execute different code depending on whether
AddressSanitizer is enabled.
__has_feature
can be used for this purpose.

#if defined(__has_feature)
# if __has_feature(address_sanitizer)
  code that builds only under AddressSanitizer
# endif
#endif

__attribute__((no_address_safety_analysis))

Some code should not be instrumentated by AddressSanitizer.
One may use the function attribute

  <tt>no_address_safety_analysis</tt>
to disable instrumentation of a particular function.
This attribute may not be supported by other compilers, so we suggest to
use it together with <tt>__has_feature(address_sanitizer)</tt>.
Note: currently, this attribute will be lost if the function is inlined.

Supported Platforms

AddressSanitizer is supported on

Linux x86_64 (tested on Ubuntu 10.04).

MacOS 10.6, 10.7 and 10.8 (i386/x86_64).

Support for Linux i386/ARM is in progress
(it may work, but is not guaranteed too).

Limitations

 AddressSanitizer uses more real memory than a native run.
How much -- depends on the allocations sizes. The smaller the
allocations you make the bigger the overhead.

 AddressSanitizer uses more stack memory. We have seen up to 3x increase.

 On 64-bit platforms AddressSanitizer maps (but not reserves)
16+ Terabytes of virtual address space.
This means that tools like <tt>ulimit</tt> may not work as usually expected.

 Static linking is not supported.

Current Status

AddressSanitizer is fully functional on supported platforms starting from LLVM 3.1.
The test suite is integrated into CMake build (can be run with "make
check-asan" command).

More Information

http://code.google.com/p/address-sanitizer.


text:
//------------------------------------------------------------------------------
/// \unit
///
/// !!!Purpose
///
/// Utility for BMP
///
//------------------------------------------------------------------------------

#ifndef BMP_H
#define BMP_H

/// BMP magic number ('BM').
#define BMP_TYPE       0x4D42

/// headerSize must be set to 40
#define BITMAPINFOHEADER   40

//------------------------------------------------------------------------------
//         Exported types
//------------------------------------------------------------------------------

#ifdef __ICCARM__          // IAR
#pragma pack(1)            // IAR
#define __attribute__(...) // IAR
#endif                     // IAR

// BMP (Windows) Header Format
struct BMPHeader {
    /// signature, must be 4D42 hex
    unsigned short type;
    /// size of BMP file in bytes (unreliable)
    unsigned int fileSize;
    /// reserved, must be zero
    unsigned short reserved1;
    /// reserved, must be zero
    unsigned short reserved2;
    /// offset to start of image data in bytes
    unsigned int offset;
    /// size of BITMAPINFOHEADER structure, must be 40
    unsigned int headerSize;
    /// image width in pixels
    unsigned int width;
    /// image height in pixels
    unsigned int height;
    /// number of planes in the image, must be 1
    unsigned short planes;
    /// number of bits per pixel (1, 4, 8, 16, 24, 32)
    unsigned short bits;
    /// compression type (0=none, 1=RLE-8, 2=RLE-4)
    unsigned int compression;
    /// size of image data in bytes (including padding)
    unsigned int imageSize;
    /// horizontal resolution in pixels per meter (unreliable)
    unsigned int xresolution;
    /// vertical resolution in pixels per meter (unreliable)
    unsigned int yresolution;
    /// number of colors in image, or zero
    unsigned int ncolours;
    /// number of important colors, or zero
    unsigned int importantcolours;

} __attribute__ ((packed)); // GCC

#ifdef __ICCARM__          // IAR
#pragma pack()             // IAR
#endif                     // IAR

//------------------------------------------------------------------------------
//         Exported functions
//------------------------------------------------------------------------------

extern unsigned char BMP_IsValid(void *file);

extern unsigned int BMP_GetFileSize(void *file);

extern unsigned char BMP_Decode(
    void *file,
    unsigned char *buffer,
    unsigned int width,
    unsigned int height,
    unsigned char bpp);

extern void WriteBMPheader(unsigned int* pAddressHeader,
                    unsigned int  bmpHSize,
                    unsigned int  bmpVSize,
                    unsigned char bmpRgb,
                    unsigned char nbByte_Pixels);

extern void BMP_displayHeader(unsigned int* pAddressHeader);

extern void RGB565toBGR555(
    unsigned char *fileSource,
    unsigned char *fileDestination,
    unsigned int width,
    unsigned int height,
    unsigned char bpp);

#endif //#ifndef BMP_H


text:
Flutter Examples
================

This directory contains several examples of using Flutter.  Each of these is an
individual Dart application package.  If you wish to run them with `sky_tool`
then you will want to run `pub get` inside their directory before running
`./packages/sky/sky_tool start`.

1. *Hello, world.* The [hello world app](hello_world) is a basic app that shows
   the text "hello, world."

2. *Stocks.* The [stocks app](stocks) is an example of a typical mobile app
   built using Flutter. The app shows a list of all the stocks in the NASDAQ.

3. *Widgets.* The [widgets app](widgets) contains a number of Flutter widgets so
   you can experiment with them in a simple container.


text:
package cgeo.geocaching.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.RelativeLayout;

public class RelativeLayoutWithInterceptTouchEventPossibility extends RelativeLayout {
    private OnInterceptTouchEventListener onInterceptTouchEventListener = null;

    public RelativeLayoutWithInterceptTouchEventPossibility(final Context context) {
        super(context);
    }

    public RelativeLayoutWithInterceptTouchEventPossibility(final Context context, final AttributeSet attrs) {
        super(context, attrs);
    }

    public RelativeLayoutWithInterceptTouchEventPossibility(final Context context, final AttributeSet attrs, final int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public RelativeLayoutWithInterceptTouchEventPossibility(final Context context, final AttributeSet attrs, final int defStyleAttr, final int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    public boolean onInterceptTouchEvent(final MotionEvent ev) {
        if (onInterceptTouchEventListener != null && onInterceptTouchEventListener.onTouchEvent(ev)) {
            return true;
        }
        return super.onInterceptTouchEvent(ev);
    }

    public void setOnInterceptTouchEventListener(final OnInterceptTouchEventListener listener) {
        onInterceptTouchEventListener = listener;
    }

    public interface OnInterceptTouchEventListener {
        /**
         * Called when the view group is touched.
         *
         * @param ev The motion event
         * @return true if the touch event should be intercepted, otherwise false.
         */
        boolean onTouchEvent(MotionEvent ev);
    }
}