text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

	<!-- for releasing to Maven Central / OSS Sonatype -->
	<parent>
		<groupId>org.sonatype.oss</groupId>
		<artifactId>oss-parent</artifactId>
		<version>9</version>
	</parent>

	<modelVersion>4.0.0</modelVersion>
	<groupId>org.rcsb</groupId>
	<artifactId>mmtf</artifactId>
	<packaging>pom</packaging>
	<version>1.0.8-SNAPSHOT</version>
	<name>mmtf</name>
	<description>MMTF is a compressed, fast and useful format for serving macromolecular data.
    </description>
	<url>https://github.com/rcsb</url>
	<organization>
		<name>RCSB PDB</name>
		<url>http://www.rcsb.org/</url>
	</organization>
	<licenses>
		<license>
			<name>Apache 2.0</name>
			<url>https://www.apache.org/licenses/LICENSE-2.0</url>
			<distribution>repo</distribution>
		</license>
	</licenses>
	<properties>
		<jdk.version>1.8</jdk.version>
		<maven.enforcer.jdk-version>1.8</maven.enforcer.jdk-version>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.build.targetEncoding>UTF-8</project.build.targetEncoding>
		<maxmem>512M</maxmem>
		<slf4j.version>1.7.21</slf4j.version>
		<log4j.version>2.6.2</log4j.version>
	</properties>
	<scm>
		<connection>scm:git:git://github.com:rcsb/mmtf-java.git</connection>
		<developerConnection>scm:git:git@github.com:rcsb/mmtf-java.git</developerConnection>
		<url>https://github.com/rcsb/mmtf-java</url>

		<tag>HEAD</tag>
	</scm>
	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>org.apache.maven.plugins</groupId>
										<artifactId>maven-enforcer-plugin</artifactId>
										<versionRange>[1.0.0,)</versionRange>
										<goals>
											<goal>enforce</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore />
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
				<plugin>
					<artifactId>maven-clean-plugin</artifactId>
					<version>3.0.0</version>
				</plugin>
				<plugin>
					<artifactId>maven-compiler-plugin</artifactId>
					<version>3.5.1</version>
					<configuration>
						<source>${jdk.version}</source>
						<target>${jdk.version}</target>
					</configuration>
				</plugin>
				<plugin>
					<artifactId>maven-dependency-plugin</artifactId>
					<version>2.10</version>
				</plugin>
				<plugin>
					<artifactId>maven-jar-plugin</artifactId>
					<version>3.0.2</version>
				</plugin>
				<plugin>
					<artifactId>maven-scm-plugin</artifactId>
					<version>1.9.5</version>
				</plugin>
				<plugin>
					<artifactId>maven-source-plugin</artifactId>
					<version>3.0.1</version>
				</plugin>
				<plugin>
					<artifactId>maven-failsafe-plugin</artifactId>
					<version>2.19.1</version>
				</plugin>
				<plugin>
					<groupId>net.sf</groupId>
					<artifactId>stat-scm</artifactId>
					<version>1.2.0</version>
				</plugin>
				<plugin>
					<groupId>org.jvnet.jaxb2.maven2</groupId>
					<artifactId>maven-jaxb2-plugin</artifactId>
					<version>0.13.1</version>
				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-release-plugin</artifactId>
					<version>2.5.3</version>
					<configuration>
						<remoteTagging>true</remoteTagging>
						<preparationGoals>clean install</preparationGoals>
						<autoVersionSubmodules>true</autoVersionSubmodules>
						<!-- work around for GPG hanging issue http://jira.codehaus.org/browse/MGPG-9 -->
						<mavenExecutorId>forked-path</mavenExecutorId>
					</configuration>

				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-javadoc-plugin</artifactId>
					<version>2.10.4</version>
					<configuration>
						<maxmemory>256m</maxmemory>
					</configuration>

				</plugin>
				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-shade-plugin</artifactId>
					<version>2.4.3</version>
				</plugin>
				<plugin>
					<artifactId>maven-assembly-plugin</artifactId>
					<version>2.6</version>
					<configuration>
						<descriptors>
							<descriptor>src/main/assembly/assembly.xml</descriptor>
						</descriptors>
					</configuration>

					<!-- Attach the creation of the assembly to the package phase. -->
					<executions>
						<execution>
							<id>assemble</id>
							<phase>package</phase>
							<goals>
								<goal>single</goal>
							</goals>
						</execution>
					</executions>

				</plugin>
				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>findbugs-maven-plugin</artifactId>
					<version>3.0.4</version>
				</plugin>

				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>buildnumber-maven-plugin</artifactId>
					<version>1.4</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-checkstyle-plugin</artifactId>
					<version>2.17</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-resources-plugin</artifactId>
					<version>3.0.1</version>
				</plugin>

				<plugin>
					<artifactId>maven-enforcer-plugin</artifactId>
					<version>1.4.1</version>
					<executions>
						<execution>
							<id>enforce-java</id>
							<goals>
								<goal>enforce</goal>
							</goals>
							<configuration>
								<rules>
									<requireJavaVersion>
										<version>${maven.enforcer.jdk-version}</version>
									</requireJavaVersion>
								</rules>
							</configuration>
						</execution>
					</executions>
				</plugin>

			</plugins>
		</pluginManagement>

		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>cobertura-maven-plugin</artifactId>
				<version>2.7</version>
				<configuration>
					<format>xml</format>
					<maxmem>256m</maxmem>
					<!-- aggregated reports for multi-module projects -->
					<aggregate>true</aggregate>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.eluder.coveralls</groupId>
				<artifactId>coveralls-maven-plugin</artifactId>
				<version>4.2.0</version>
			</plugin>
			<!-- for deployment on OSS Sonatype -->
			<plugin>
				<groupId>org.sonatype.plugins</groupId>
				<artifactId>nexus-staging-maven-plugin</artifactId>
				<version>1.6.7</version>
				<extensions>true</extensions>
				<configuration>
					<serverId>ossrh</serverId>
					<nexusUrl>https://oss.sonatype.org/</nexusUrl>
					<autoReleaseAfterClose>true</autoReleaseAfterClose>
				</configuration>
			</plugin>

			<!-- for digital signing of code -->
			<!--<plugin> -->
			<!--<groupId>org.apache.maven.plugins</groupId> -->
			<!--<artifactId>maven-gpg-plugin</artifactId> -->
			<!--<version>1.5</version> -->
			<!--<executions> -->
			<!--<execution> -->
			<!--<id>sign-artifacts</id> -->
			<!--<phase>verify</phase> -->
			<!--<goals> -->
			<!--<goal>sign</goal> -->
			<!--</goals> -->
			<!--</execution> -->
			<!--</executions> -->
			<!--</plugin> -->

			<!-- give more memory for junit tests -->
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>2.19.1</version>
				<configuration>
					<argLine>-Xmx1800M</argLine>
					<reuseForks>false</reuseForks>
					<forkCount>1</forkCount>
				</configuration>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>

				<configuration>
					<archive>
						<addMavenDescriptor>false</addMavenDescriptor>
						<manifest>
							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>

						</manifest>
						<manifestEntries>
							<Trusted-Library>true</Trusted-Library>
							<Permissions>all-permissions</Permissions>
							<Codebase>*</Codebase>
							<Application-Name>MMTF</Application-Name>
						</manifestEntries>
					</archive>
				</configuration>

			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>findbugs-maven-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<configuration>
					<!-- <enableFilesSummary>true</enableFilesSummary> <enableSeveritySummary>true</enableSeveritySummary> -->
					<enableRulesSummary>false</enableRulesSummary>
					<!-- <consoleOutput>true</consoleOutput> -->
				</configuration>
			</plugin>

			<plugin>
				<groupId>com.versioneye</groupId>
				<artifactId>versioneye-maven-plugin</artifactId>
				<version>3.10.2</version>
			</plugin>

		</plugins>

		<extensions>
			<extension>
				<groupId>org.apache.maven.wagon</groupId>
				<artifactId>wagon-ssh</artifactId>
				<version>2.6</version>
			</extension>
		</extensions>
	</build>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>uk.co.jemos.podam</groupId>
				<artifactId>podam</artifactId>
				<version>2.3.5.RELEASE</version>
				<scope>test</scope>
			</dependency>
			<dependency>
				<groupId>org.unitils</groupId>
				<artifactId>unitils-core</artifactId>
				<version>3.4.2</version>
				<scope>test</scope>
			</dependency>
			<dependency>
				<groupId>junit</groupId>
				<artifactId>junit</artifactId>
				<version>4.12</version>
				<scope>test</scope>
			</dependency>
			<dependency>
				<groupId>commons-beanutils</groupId>
				<artifactId>commons-beanutils</artifactId>
				<version>1.9.2</version>
				<scope>test</scope>
			</dependency>
			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-api</artifactId>
				<version>${slf4j.version}</version>
			</dependency>
			<!-- binding for log4j 2 -->
			<dependency>
				<groupId>org.apache.logging.log4j</groupId>
				<artifactId>log4j-slf4j-impl</artifactId>
				<version>${log4j.version}</version>
				<!-- runtime scope includes the test scope as well -->
				<scope>runtime</scope>
			</dependency>
			<!-- Log4j API and Core implementation required for binding -->
			<dependency>
				<groupId>org.apache.logging.log4j</groupId>
				<artifactId>log4j-api</artifactId>
				<version>${log4j.version}</version>
				<!-- runtime scope includes the test scope as well -->
				<scope>runtime</scope>
			</dependency>
			<dependency>
				<groupId>org.apache.logging.log4j</groupId>
				<artifactId>log4j-core</artifactId>
				<version>${log4j.version}</version>
				<!-- runtime scope includes the test scope as well -->
				<scope>runtime</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<reporting>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>2.10.4</version>
				<configuration>
					<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
					<docletArtifact>
						<groupId>org.umlgraph</groupId>
						<artifactId>umlgraph</artifactId>
						<version>5.6</version>
					</docletArtifact>
					<additionalparam>-views -all</additionalparam>
					<useStandardDocletOptions>true</useStandardDocletOptions>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>findbugs-maven-plugin</artifactId>
				<version>3.0.4</version>
			</plugin>
		</plugins>
	</reporting>
	<profiles>

		<!-- Note: before you can use this build profile you need to set up an
			environment that contains correctly signed keys. Configure the keystore properties
			and the profile in ~/.m2/settings.xml -->
		<profile>
			<id>codesigning</id>
			<activation>
				<activeByDefault>false</activeByDefault>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-jarsigner-plugin</artifactId>
						<version>1.4</version>
						<executions>
							<execution>
								<id>sign</id>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>

						<configuration>

							<verbose>true</verbose>
							<certs>true</certs>
							<storetype>${keystore.type}</storetype>
							<keystore>${keystore.path}</keystore>
							<alias>${keystore.alias}</alias>
							<storepass>${keystore.store.password}</storepass>
							<keypass>${keystore.key.password}</keypass>
							<signedjar>${project.build.directory}/${project.build.finalName}.jar</signedjar>
							<verify>true</verify>
							<verbose>true</verbose>
							<goal>sign</goal>
							<arguments>
								<argument>-tsa</argument>
								<argument>https://timestamp.geotrust.com/tsa</argument>
							</arguments>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>
		<profile>
			<id>release-sign-artifacts</id>
			<activation>
				<property>
					<name>performRelease</name>
					<value>true</value>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>1.6</version>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<phase>verify</phase>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

	<modules>
		<module>mmtf-serialization</module>
		<module>mmtf-api</module>
		<module>mmtf-codec</module>
	</modules>
	<inceptionYear>2015</inceptionYear>
	<issueManagement>
		<system>Github</system>
		<url>https://github.com/rcsb/mmtf-java/issues</url>
	</issueManagement>
	<ciManagement>
		<system>Travis</system>
		<url>https://travis-ci.org/</url>
	</ciManagement>
</project>


text:
package gocsv

import (
	"encoding/csv"
	"errors"
	"fmt"
	"io"
	"reflect"
)

// Decoder .
type Decoder interface {
	GetCSVRows() ([][]string, error)
}

// SimpleDecoder .
type SimpleDecoder interface {
	GetCSVRow() ([]string, error)
	GetCSVRows() ([][]string, error)
}

type CSVReader interface {
	Read() ([]string, error)
	ReadAll() ([][]string, error)
}

type csvDecoder struct {
	CSVReader
}

func newSimpleDecoderFromReader(r io.Reader) SimpleDecoder {
	return csvDecoder{getCSVReader(r)}
}

var (
	ErrEmptyCSVFile = errors.New("empty csv file given")
	ErrNoStructTags = errors.New("no csv struct tags found")
)

// NewSimpleDecoderFromCSVReader creates a SimpleDecoder, which may be passed
// to the UnmarshalDecoder* family of functions, from a CSV reader. Note that
// encoding/csv.Reader implements CSVReader, so you can pass one of those
// directly here.
func NewSimpleDecoderFromCSVReader(r CSVReader) SimpleDecoder {
	return csvDecoder{r}
}

func (c csvDecoder) GetCSVRows() ([][]string, error) {
	return c.ReadAll()
}

func (c csvDecoder) GetCSVRow() ([]string, error) {
	return c.Read()
}

func mismatchStructFields(structInfo []fieldInfo, headers []string) []string {
	missing := make([]string, 0)
	if len(structInfo) == 0 {
		return missing
	}

	headerMap := make(map[string]struct{}, len(headers))
	for idx := range headers {
		headerMap[headers[idx]] = struct{}{}
	}

	for _, info := range structInfo {
		found := false
		for _, key := range info.keys {
			if _, ok := headerMap[key]; ok {
				found = true
				break
			}
		}
		if !found {
			missing = append(missing, info.keys...)
		}
	}
	return missing
}

func mismatchHeaderFields(structInfo []fieldInfo, headers []string) []string {
	missing := make([]string, 0)
	if len(headers) == 0 {
		return missing
	}

	keyMap := make(map[string]struct{})
	for _, info := range structInfo {
		for _, key := range info.keys {
			keyMap[key] = struct{}{}
		}
	}

	for _, header := range headers {
		if _, ok := keyMap[header]; !ok {
			missing = append(missing, header)
		}
	}
	return missing
}

func maybeMissingStructFields(structInfo []fieldInfo, headers []string) error {
	missing := mismatchStructFields(structInfo, headers)
	if len(missing) != 0 {
		return fmt.Errorf("found unmatched struct field with tags %v", missing)
	}
	return nil
}

// Check that no header name is repeated twice
func maybeDoubleHeaderNames(headers []string) error {
	headerMap := make(map[string]bool, len(headers))
	for _, v := range headers {
		if _, ok := headerMap[v]; ok {
			return fmt.Errorf("repeated header name: %v", v)
		}
		headerMap[v] = true
	}
	return nil
}

// apply normalizer func to headers
func normalizeHeaders(headers []string) []string {
	out := make([]string, len(headers))
	for i, h := range headers {
		out[i] = normalizeName(h)
	}
	return out
}

func readTo(decoder Decoder, out interface{}) error {
	return readToWithErrorHandler(decoder, nil, out)
}

func readToWithErrorHandler(decoder Decoder, errHandler ErrorHandler, out interface{}) error {
	outValue, outType := getConcreteReflectValueAndType(out) // Get the concrete type (not pointer) (Slice<?> or Array<?>)
	if err := ensureOutType(outType); err != nil {
		return err
	}
	outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">)
	if err := ensureOutInnerType(outInnerType); err != nil {
		return err
	}
	csvRows, err := decoder.GetCSVRows() // Get the CSV csvRows
	if err != nil {
		return err
	}
	if len(csvRows) == 0 {
		return ErrEmptyCSVFile
	}
	if err := ensureOutCapacity(&outValue, len(csvRows)); err != nil { // Ensure the container is big enough to hold the CSV content
		return err
	}
	outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations
	if len(outInnerStructInfo.Fields) == 0 {
		return ErrNoStructTags
	}

	headers := normalizeHeaders(csvRows[0])
	body := csvRows[1:]

	csvHeadersLabels := make(map[int]*fieldInfo, len(outInnerStructInfo.Fields)) // Used to store the correspondance header <-> position in CSV

	headerCount := map[string]int{}
	for i, csvColumnHeader := range headers {
		curHeaderCount := headerCount[csvColumnHeader]
		if fieldInfo := getCSVFieldPosition(csvColumnHeader, outInnerStructInfo, curHeaderCount); fieldInfo != nil {
			csvHeadersLabels[i] = fieldInfo
			if ShouldAlignDuplicateHeadersWithStructFieldOrder {
				curHeaderCount++
				headerCount[csvColumnHeader] = curHeaderCount
			}
		}
	}

	if FailIfUnmatchedStructTags {
		if err := maybeMissingStructFields(outInnerStructInfo.Fields, headers); err != nil {
			return err
		}
	}
	if FailIfDoubleHeaderNames {
		if err := maybeDoubleHeaderNames(headers); err != nil {
			return err
		}
	}

	var withFieldsOK bool
	var fieldTypeUnmarshallerWithKeys TypeUnmarshalCSVWithFields

	for i, csvRow := range body {
		objectIface := reflect.New(outValue.Index(i).Type()).Interface()
		outInner := createNewOutInner(outInnerWasPointer, outInnerType)
		for j, csvColumnContent := range csvRow {
			if fieldInfo, ok := csvHeadersLabels[j]; ok { // Position found accordingly to header name

				if outInner.CanInterface() {
					fieldTypeUnmarshallerWithKeys, withFieldsOK = objectIface.(TypeUnmarshalCSVWithFields)
					if withFieldsOK {
						if err := fieldTypeUnmarshallerWithKeys.UnmarshalCSVWithFields(fieldInfo.getFirstKey(), csvColumnContent); err != nil {
							parseError := csv.ParseError{
								Line:   i + 2, //add 2 to account for the header & 0-indexing of arrays
								Column: j + 1,
								Err:    err,
							}
							return &parseError
						}
						continue
					}
				}
				value := csvColumnContent
				if value == "" {
					value = fieldInfo.defaultValue
				}
				if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, value, fieldInfo.omitEmpty); err != nil { // Set field of struct
					parseError := csv.ParseError{
						Line:   i + 2, //add 2 to account for the header & 0-indexing of arrays
						Column: j + 1,
						Err:    err,
					}
					if errHandler == nil || !errHandler(&parseError) {
						return &parseError
					}
				}
			}
		}

		if withFieldsOK {
			reflectedObject := reflect.ValueOf(objectIface)
			outInner = reflectedObject.Elem()
		}

		outValue.Index(i).Set(outInner)
	}
	return nil
}

func readEach(decoder SimpleDecoder, c interface{}) error {
	outValue, outType := getConcreteReflectValueAndType(c) // Get the concrete type (not pointer)
	if outType.Kind() != reflect.Chan {
		return fmt.Errorf("cannot use %v with type %s, only channel supported", c, outType)
	}
	defer outValue.Close()

	headers, err := decoder.GetCSVRow()
	if err != nil {
		return err
	}
	headers = normalizeHeaders(headers)

	outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">)
	if err := ensureOutInnerType(outInnerType); err != nil {
		return err
	}
	outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations
	if len(outInnerStructInfo.Fields) == 0 {
		return ErrNoStructTags
	}
	csvHeadersLabels := make(map[int]*fieldInfo, len(outInnerStructInfo.Fields)) // Used to store the correspondance header <-> position in CSV
	headerCount := map[string]int{}
	for i, csvColumnHeader := range headers {
		curHeaderCount := headerCount[csvColumnHeader]
		if fieldInfo := getCSVFieldPosition(csvColumnHeader, outInnerStructInfo, curHeaderCount); fieldInfo != nil {
			csvHeadersLabels[i] = fieldInfo
			if ShouldAlignDuplicateHeadersWithStructFieldOrder {
				curHeaderCount++
				headerCount[csvColumnHeader] = curHeaderCount
			}
		}
	}
	if err := maybeMissingStructFields(outInnerStructInfo.Fields, headers); err != nil {
		if FailIfUnmatchedStructTags {
			return err
		}
	}
	if FailIfDoubleHeaderNames {
		if err := maybeDoubleHeaderNames(headers); err != nil {
			return err
		}
	}
	i := 0
	for {
		line, err := decoder.GetCSVRow()
		if err == io.EOF {
			break
		} else if err != nil {
			return err
		}
		outInner := createNewOutInner(outInnerWasPointer, outInnerType)
		for j, csvColumnContent := range line {
			if fieldInfo, ok := csvHeadersLabels[j]; ok { // Position found accordingly to header name
				if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, csvColumnContent, fieldInfo.omitEmpty); err != nil { // Set field of struct
					return &csv.ParseError{
						Line:   i + 2, //add 2 to account for the header & 0-indexing of arrays
						Column: j + 1,
						Err:    err,
					}
				}
			}
		}
		outValue.Send(outInner)
		i++
	}
	return nil
}

func readEachWithoutHeaders(decoder SimpleDecoder, c interface{}) error {
	outValue, outType := getConcreteReflectValueAndType(c) // Get the concrete type (not pointer) (Slice<?> or Array<?>)
	if err := ensureOutType(outType); err != nil {
		return err
	}
	defer outValue.Close()

	outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">)
	if err := ensureOutInnerType(outInnerType); err != nil {
		return err
	}
	outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations
	if len(outInnerStructInfo.Fields) == 0 {
		return ErrNoStructTags
	}

	i := 0
	for {
		line, err := decoder.GetCSVRow()
		if err == io.EOF {
			break
		} else if err != nil {
			return err
		}
		outInner := createNewOutInner(outInnerWasPointer, outInnerType)
		for j, csvColumnContent := range line {
			fieldInfo := outInnerStructInfo.Fields[j]
			if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, csvColumnContent, fieldInfo.omitEmpty); err != nil { // Set field of struct
				return &csv.ParseError{
					Line:   i + 2, //add 2 to account for the header & 0-indexing of arrays
					Column: j + 1,
					Err:    err,
				}
			}
		}
		outValue.Send(outInner)
		i++
	}
	return nil
}

func readToWithoutHeaders(decoder Decoder, out interface{}) error {
	outValue, outType := getConcreteReflectValueAndType(out) // Get the concrete type (not pointer) (Slice<?> or Array<?>)
	if err := ensureOutType(outType); err != nil {
		return err
	}
	outInnerWasPointer, outInnerType := getConcreteContainerInnerType(outType) // Get the concrete inner type (not pointer) (Container<"?">)
	if err := ensureOutInnerType(outInnerType); err != nil {
		return err
	}
	csvRows, err := decoder.GetCSVRows() // Get the CSV csvRows
	if err != nil {
		return err
	}
	if len(csvRows) == 0 {
		return ErrEmptyCSVFile
	}
	if err := ensureOutCapacity(&outValue, len(csvRows)+1); err != nil { // Ensure the container is big enough to hold the CSV content
		return err
	}
	outInnerStructInfo := getStructInfo(outInnerType) // Get the inner struct info to get CSV annotations
	if len(outInnerStructInfo.Fields) == 0 {
		return ErrNoStructTags
	}

	for i, csvRow := range csvRows {
		outInner := createNewOutInner(outInnerWasPointer, outInnerType)
		for j, csvColumnContent := range csvRow {
			fieldInfo := outInnerStructInfo.Fields[j]
			if err := setInnerField(&outInner, outInnerWasPointer, fieldInfo.IndexChain, csvColumnContent, fieldInfo.omitEmpty); err != nil { // Set field of struct
				return &csv.ParseError{
					Line:   i + 1,
					Column: j + 1,
					Err:    err,
				}
			}
		}
		outValue.Index(i).Set(outInner)
	}

	return nil
}

// Check if the outType is an array or a slice
func ensureOutType(outType reflect.Type) error {
	switch outType.Kind() {
	case reflect.Slice:
		fallthrough
	case reflect.Chan:
		fallthrough
	case reflect.Array:
		return nil
	}
	return fmt.Errorf("cannot use " + outType.String() + ", only slice or array supported")
}

// Check if the outInnerType is of type struct
func ensureOutInnerType(outInnerType reflect.Type) error {
	switch outInnerType.Kind() {
	case reflect.Struct:
		return nil
	}
	return fmt.Errorf("cannot use " + outInnerType.String() + ", only struct supported")
}

func ensureOutCapacity(out *reflect.Value, csvLen int) error {
	switch out.Kind() {
	case reflect.Array:
		if out.Len() < csvLen-1 { // Array is not big enough to hold the CSV content (arrays are not addressable)
			return fmt.Errorf("array capacity problem: cannot store %d %s in %s", csvLen-1, out.Type().Elem().String(), out.Type().String())
		}
	case reflect.Slice:
		if !out.CanAddr() && out.Len() < csvLen-1 { // Slice is not big enough tho hold the CSV content and is not addressable
			return fmt.Errorf("slice capacity problem and is not addressable (did you forget &?)")
		} else if out.CanAddr() && out.Len() < csvLen-1 {
			out.Set(reflect.MakeSlice(out.Type(), csvLen-1, csvLen-1)) // Slice is not big enough, so grows it
		}
	}
	return nil
}

func getCSVFieldPosition(key string, structInfo *structInfo, curHeaderCount int) *fieldInfo {
	matchedFieldCount := 0
	for _, field := range structInfo.Fields {
		if field.matchesKey(key) {
			if matchedFieldCount >= curHeaderCount {
				return &field
			}
			matchedFieldCount++
		}
	}
	return nil
}

func createNewOutInner(outInnerWasPointer bool, outInnerType reflect.Type) reflect.Value {
	if outInnerWasPointer {
		return reflect.New(outInnerType)
	}
	return reflect.New(outInnerType).Elem()
}

func setInnerField(outInner *reflect.Value, outInnerWasPointer bool, index []int, value string, omitEmpty bool) error {
	oi := *outInner
	if outInnerWasPointer {
		// initialize nil pointer
		if oi.IsNil() {
			setField(oi, "", omitEmpty)
		}
		oi = outInner.Elem()
	}

	if oi.Kind() == reflect.Slice || oi.Kind() == reflect.Array {
		i := index[0]

		// grow slice when needed
		if i >= oi.Cap() {
			newcap := oi.Cap() + oi.Cap()/2
			if newcap < 4 {
				newcap = 4
			}
			newoi := reflect.MakeSlice(oi.Type(), oi.Len(), newcap)
			reflect.Copy(newoi, oi)
			oi.Set(newoi)
		}
		if i >= oi.Len() {
			oi.SetLen(i + 1)
		}

		item := oi.Index(i)
		if len(index) > 1 {
			return setInnerField(&item, false, index[1:], value, omitEmpty)
		}
		return setField(item, value, omitEmpty)
	}

	// because pointers can be nil need to recurse one index at a time and perform nil check
	if len(index) > 1 {
		nextField := oi.Field(index[0])
		return setInnerField(&nextField, nextField.Kind() == reflect.Ptr, index[1:], value, omitEmpty)
	}
	return setField(oi.FieldByIndex(index), value, omitEmpty)
}

redpajama_set_name: RedPajamaGithub


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Ephebe intricata Lamy

### Remarks
null


text:
namespace _03.PeriodicTable
{
    using System;
    using System.Collections.Generic;

    public class PeriodicTable
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var set = new SortedSet<string>();

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split();
                foreach (var element in input)
                {
                    set.Add(element);
                }
            }
            Console.WriteLine(string.Join(" ",set));
        }
    }
}


text:
import path from 'path'
import { expect } from 'chai'
import { analyze } from '../src/commands'

const expectedData = require('./expected.json')

describe('analyze.js', function() {
	before(function() {
		var blacklist = {
			files: ['blacklisted-file.asp'],
			functions: ['blacklistedsub', 'blacklistedfunction'],
		}
		return analyze(path.join(__dirname, 'analyze'), { blacklist }).then(actualData => {
			this.actualData = actualData
		})
	})

	it('should not find unexpected items', function() {
		var wronglyFound = this.actualData.filter(f => expectedData.find(ef => ef.path == f.path) == null)
		expect(wronglyFound).to.deep.equal([])
	})

	expectedData.forEach(file => {
		describe(`Analyzing file ${file.path}`, function() {
			beforeEach(function() {
				this.actualFile = this.actualData.find(f => f.path == file.path)
				if(this.actualFile == null) throw new Error('File was not parsed')
			})

			it('should find all includes', function() {
				expect(this.actualFile.includes).to.deep.equal(file.includes)
			})

			it('should find all aspClientCalls', function() {
				expect(this.actualFile.aspClientCalls).to.deep.equal(file.aspClientCalls)
			})

			it('should find all asp-calls', function() {
				expect(this.actualFile.calls).to.deep.equal(file.calls || [])
			})

			describe('and looking for functions', function() {
				it('should not find extra functions', function() {
					var extra = this.actualFile.funcs.filter(f => file.funcs.find(f1 => f.name == f1.name) == null)
					expect(extra).to.deep.equal([])
				})

				file.funcs.forEach(func => {
					it(`should find ${func.name}`, function() {
						expect(this.actualFile.funcs.find(f => f.name == func.name))
							.to.deep.equal(func)
					})
				})
			})

			describe('and looking for subs', function() {
				it('should not find extra subs', function() {
					var extra = this.actualFile.subs.filter(f => file.subs.find(f1 => f.name == f1.name) == null)
					expect(extra).to.deep.equal([])
				})

				file.subs.forEach(sub => {
					it(`should find ${sub.name}`, function() {
						expect(this.actualFile.subs.find(s => s.name == sub.name))
							.to.deep.equal(sub)
					})
				})
			})
		})
	})
})


text:
<?xml version="1.0" encoding="UTF-8"?><archetype>
<!--

    Copyright 2008 Marvin Herman Froeder
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
  <id>flexmojos-archetypes-modular-webapp</id>
  <!--
  <sources>
    <source>swc/src/main/flex/App.as</source>
  </sources>
  -->
  <resources>
    <resource>swc/src/main/flex/App.as</resource>
    <resource>swc/pom.xml</resource>
    <resource>swf/pom.xml</resource>
    <resource>war/pom.xml</resource>
    <resource>swf/src/main/flex/Main.mxml</resource>
    <resource>war/src/main/webapp/WEB-INF/web.xml</resource>
    <resource>swf/src/test/flex/TestApp.as</resource>
    <resource>swc/src/test/flex/TestApp.as</resource>
  </resources>
  <!--
  <testSources>
    <source>swf/src/test/flex/TestApp.as</source>
    <source>swc/src/test/flex/TestApp.as</source>
  </testSources>
  -->
</archetype>


text:
/* jslint node: true */
/* global describe, it, afterEach */
"use strict";

var fs = require('fs');
var path = require('path');
var assert = require("assert");
var FeatureParser = require('../lib/index').parsers.FeatureParser;
var Localisation = require('../lib/index').localisation;
var Language = require('../lib/index').localisation.Language;
var Pirate = require('../lib/index').localisation.Pirate;
var English = require('../lib/index').localisation.English;

describe('FeatureParser', function() {

    afterEach(function() {
        Localisation.default = English;
    });

    describe('(Features)', function() {

        it('should parse feature title', function() {
            var feature = parse_file('feature/simple_feature');
            assert.equal(feature.title, 'Simple Feature');
        });

        it('should parse feature descriptions', function() {
            var feature = parse_file('feature/feature_description');
            assert.equal(feature.title, 'Feature Description');
            assert.equal(feature.description.join(' - '), 'As a wood chopper - I want to maintain a sharp axe - So that I can chop wood');
        });

        it('should only allow a single feature', function() {
            assert.throws(function() {
                parse_file('feature/multiple_features');
            }, /Feature is unexpected/);
        });

        it('should report incomplete features', function() {
            assert.throws(function() {
                parse_file('feature/incomplete_feature');
            }, /Feature requires one or more scenarios/);
        });
    });

    describe('(Scenarios)', function() {

        it('should parse a simple scenario', function() {
            var scenarios = parse_file('scenario/simple_scenario').scenarios;
            assert.equal(scenarios.length, 1);
            assert.equal(scenarios[0].title, 'Simple Scenario');
            assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);
        });

        it('should parse a complex scenario', function() {
            var scenarios = parse_file('scenario/complex_scenario').scenarios;
            assert.equal(scenarios.length, 1);
            assert.equal(scenarios[0].title, 'Complex Scenario');
            assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);
        });

        it('should parse multiple scenarios', function() {
            var scenarios = parse_file('scenario/multiple_scenarios').scenarios;
            assert.equal(scenarios.length, 2);
            assert.equal(scenarios[0].title, 'First Scenario');
            assert.equal(scenarios[1].title, 'Second Scenario');
        });

        it('should reset scenarios between parses', function() {
            assert.equal(parse_file('scenario/simple_scenario').scenarios.length, 1);
            assert.equal(parse_file('scenario/simple_scenario').scenarios.length, 1);
        });

        it('should report incomplete scenarios', function() {
            assert.throws(function() {
                parse_file('scenario/incomplete_scenario_1');
            }, /Scenario requires one or more steps/);

            assert.throws(function() {
                parse_file('scenario/incomplete_scenario_2');
            }, /Scenario requires one or more steps/);

            assert.throws(function() {
                parse_file('scenario/incomplete_scenario_3');
            }, /Scenario requires one or more steps/);

            assert.throws(function() {
                parse_file('scenario/incomplete_scenario_4');
            }, /Scenario requires one or more steps/);
        });

        it('should report steps with no scenario', function() {
            assert.throws(function() {
                parse_file('scenario/missing_scenario');
            }, /A feature must contain one or more scenarios/);
        });

        it('should parse multline steps with no ending dash', function() {
            var scenarios = parse_file('scenario/multiline_step_scenario').scenarios;
            assert.equal(scenarios.length, 1);
            assert.equal(scenarios[0].title, 'Multiline Step');
            assert.equal(scenarios[0].steps[0], poem);
        });

        it('should parse multiline steps', function() {
            var scenarios = parse_file('scenario/multiline_step_scenario_with_ending_dash').scenarios;
            assert.equal(scenarios.length, 1);
            assert.equal(scenarios[0].title, 'Multiline Step With Ending Dash');
            assert.equal(scenarios[0].steps[0], poem);
        });

        it('should parse multiline steps with followers', function() {
            var scenarios = parse_file('scenario/multiline_step_scenario_with_followers').scenarios;
            assert.equal(scenarios.length, 5);
            assert.equal(scenarios[0].title, 'Multiline Step Followed By Scenario');
            console.log(scenarios[0].steps[0]);
            assert.equal(scenarios[0].steps[0], poem);

            assert.equal(scenarios[1].title, 'Another scenario');

            assert.equal(scenarios[2].title, 'Multiline Step Followed By Annotation');
            assert.equal(scenarios[2].steps[0], poem);

            assert.equal(scenarios[3].title, 'Another scenario');

            assert.equal(scenarios[4].title, 'Multiline Step Followed By Example Table');
            assert.equal(JSON.stringify(scenarios[4].steps[0]), JSON.stringify(poem));
        });

        it('should maintain indentation while parsing multiline steps', function() {
            var scenarios = parse_file('scenario/multiline_step_scenario_with_indentation').scenarios;
            assert.equal(scenarios.length, 1);
            assert.equal(scenarios[0].title, 'Multiline Step With Indentation');
            assert.equal(scenarios[0].steps[0], [
                'LOLCODE HAI',
                'CAN HAS STDIO?',
                'PLZ OPEN FILE "LOLCATS.TXT"?',
                '    AWSUM THX',
                '        VISIBLE FILE',
                '    O NOES',
                '        INVISIBLE "ERROR!"',
                'KTHXBYE'
            ].join('\n'));
        });

        it('should report malformed multiline steps', function() {

            assert.throws(function() {
                parse_file('scenario/malformed_multiline_scenario_1');
            }, /Dash is unexpected at this time/);

            assert.throws(function() {
                parse_file('scenario/malformed_multiline_scenario_2');
            }, /Indentation error/);

            assert.throws(function() {
                parse_file('scenario/malformed_multiline_scenario_3');
            }, /Dash is unexpected at this time/);

            assert.throws(function() {
                parse_file('scenario/malformed_multiline_scenario_4');
            }, /Examples is unexpected at this time/);

            assert.throws(function() {
                parse_file('scenario/malformed_multiline_scenario_5');
            }, /Annotation is unexpected at this time/);
        });
    });

    describe('(Annotations)', function() {
        it('should parse feature annotations', function() {
            var feature = parse_file('annotated/annotated_feature');
            assert.equal(feature.annotations.keyword1, 'value1');
            assert.equal(feature.annotations.keyword2, 'value2');
            assert(feature.annotations.keyword3);
            assert.equal(Object.keys(feature.scenarios[0].annotations).length, 0);
        });

        it('should trim feature annotations', function() {
            var feature = parse_file('annotated/untrimmed_annotated_feature');
            assert.equal(feature.annotations.keyword1, 'value1');
            assert.equal(feature.annotations.keyword2, 'value2');
            assert(feature.annotations.keyword3);
            assert.equal(Object.keys(feature.scenarios[0].annotations).length, 0);
        });

        it('should parse scenario annotations', function() {
            var feature = parse_file('annotated/annotated_scenario');
            assert.equal(Object.keys(feature.annotations).length, 0);
            assert.equal(feature.scenarios[0].annotations.keyword1, 'value1');
            assert.equal(feature.scenarios[0].annotations.keyword2, 'value2');
            assert(feature.scenarios[0].annotations.keyword3);
        });

        it('should trim scenario annotations', function() {
            var feature = parse_file('annotated/untrimmed_annotated_scenario');
            assert.equal(Object.keys(feature.annotations).length, 0);
            assert.equal(feature.scenarios[0].annotations.keyword1, 'value1');
            assert.equal(feature.scenarios[0].annotations.keyword2, 'value2');
            assert(feature.scenarios[0].annotations.keyword3);
        });

        it('should support annotations with non alphanumerics', function() {
            var feature = parse_file('annotated/annotated_feature_non_alphanumeric');
            assert.equal(feature.annotations['keyword+1'], 'value1');
            assert.equal(feature.scenarios[0].annotations['keyword-1'], 'value1');
        });

        it('should expand scenarios from annotated singleline example table', function() {
            var scenarios = parse_file('annotated/annotated_example_table').scenarios;
            assert.equal(scenarios.length, 4);
            assert.equal(scenarios[0].annotations.pending, true);
            assert.equal(scenarios[0].title, 'First Scenario');
            assert.equal(scenarios[0].steps[0], 'Step A11');
            assert.equal(scenarios[0].steps[1], 'Step 1AA');
            assert.equal(scenarios[1].annotations.pending, undefined);
            assert.equal(scenarios[1].title, 'Second Scenario');
            assert.equal(scenarios[1].steps[0], 'Step B22');
            assert.equal(scenarios[1].steps[1], 'Step 2BB');
            assert.equal(scenarios[2].annotations.pending, true);
            assert.equal(scenarios[2].title, 'Third Scenario');
            assert.equal(scenarios[2].steps[0], 'Step C33');
            assert.equal(scenarios[2].steps[1], 'Step 3CC');
        });

        it('should expand scenarios from annotated multiline example table', function() {
            var scenarios = parse_file('annotated/annotated_multiline_example_table').scenarios;
            assert.equal(scenarios.length, 4);
            assert.equal(scenarios[0].annotations.pending, true);
            assert.equal(scenarios[0].title, 'First Scenario');
            assert.equal(scenarios[0].steps[0], 'Step A11');
            assert.equal(scenarios[0].steps[1], 'Step 1AA');
            assert.equal(scenarios[1].annotations.pending, undefined);
            assert.equal(scenarios[1].title, 'Second Scenario');
            assert.equal(scenarios[1].steps[0], 'Step B22');
            assert.equal(scenarios[1].steps[1], 'Step 2BB');
            assert.equal(scenarios[2].annotations.pending, true);
            assert.equal(scenarios[2].title, 'Third Scenario');
            assert.equal(scenarios[2].steps[0], 'Step C33');
            assert.equal(scenarios[2].steps[1], 'Step 3CC');
        });

        it('should merge scenario annotations with example table annotations', function() {
            var scenarios = parse_file('annotated/annotated_example_table').scenarios;
            assert.equal(scenarios.length, 4);
            assert.equal(scenarios[0].annotations.pending, true);
            assert.equal(scenarios[0].annotations.only, true);
            assert.equal(scenarios[1].annotations.pending, undefined);
            assert.equal(scenarios[1].annotations.only, true);
            assert.equal(scenarios[2].annotations.pending, true);
            assert.equal(scenarios[2].annotations.only, true);

            delete scenarios[0].annotations.pending;
            assert.equal(scenarios[2].annotations.pending, true);
        });

        it('should not confuse example table annotations and scenario annotations', function() {
            var scenarios = parse_file('annotated/annotated_example_table').scenarios;
            assert.equal(scenarios.length, 4);
            assert.equal(scenarios[3].annotations.crystal, true);
        });

        it('should parse scenario annotations after background', function() {
            var feature = parse_file('annotated/annotated_scenario_after_background');
            assert.equal(feature.scenarios[0].steps[0], 'Given A');
        });
    });

    describe('(Single line Example Tables)', function() {

        it('should expand scenarios from example table', function() {
            var scenarios = parse_file('example_table/example_table').scenarios;
            assert.equal(scenarios.length, 2);
            assert.equal(scenarios[0].title, 'First Scenario');
            assert.equal(scenarios[0].steps[0], 'Step A11');
            assert.equal(scenarios[0].steps[1], 'Step 1AA');
            assert.equal(scenarios[1].title, 'Second Scenario');
            assert.equal(scenarios[1].steps[0], 'Step B22');
            assert.equal(scenarios[1].steps[1], 'Step 2BB');
        });

        it('should expand scenarios from example table using \\u2506 separator', function() {
            var scenarios = parse_file('example_table/example_table_2506').scenarios;
            assert.equal(scenarios.length, 2);
            assert.equal(scenarios[0].title, 'First Scenario');
            assert.equal(scenarios[0].steps[0], 'Step A11');
            assert.equal(scenarios[0].steps[1], 'Step 1AA');
            assert.equal(scenarios[1].title, 'Second Scenario');
            assert.equal(scenarios[1].steps[0], 'Step B22');
            assert.equal(scenarios[1].steps[1], 'Step 2BB');
        });

        it('should expand scenarios from example table with outer borders', function() {
            var scenarios = parse_file('example_table/example_table_with_outer_borders').scenarios;
            assert.equal(scenarios.length, 2);
            assert.equal(scenarios[0].title, 'First Scenario');
            assert.equal(scenarios[0].steps[0], 'Step A11');
            assert.equal(scenarios[0].steps[1], 'Step 1AA');
            assert.equal(scenarios[1].title, 'Second Scenario');
            assert.equal(scenarios[1].steps[0], 'Step B22');
            assert.equal(scenarios[1].steps[1], 'Step 2BB');
        });

        it('should report malformed singleline example tables', function() {

            assert.throws(function() {
                parse_file('example_table/malformed_example_table_1').scenarios;
            }, /Incorrect number of fields in example table/);

            assert.throws(function() {
                parse_file('example_table/malformed_example_table_2').scenarios;
            }, /Blank is unexpected at this time/);
        });

        it('should report incomplete example table', function() {

            assert.throws(function() {
                parse_file('example_table/incomplete_example_table_1');
            }, /Examples table requires one or more headings/);

            assert.throws(function() {
                parse_file('example_table/incomplete_example_table_2');
            }, /Examples table requires one or more rows/);

            assert.throws(function() {
                parse_file('example_table/incomplete_example_table_3');
            }, /Examples table requires one or more rows/);

            assert.throws(function() {
                parse_file('example_table/incomplete_example_table_4');
            }, /Examples table requires one or more rows/);
        });

        it('should expand feature background from example table', function() {
            var feature = parse_file('example_table/feature_with_background_and_example_table');
            assert.equal(feature.scenarios.length, 4);
            assert.equal(feature.scenarios[0].steps[0], 'BG A1');
            assert.equal(feature.scenarios[1].steps[0], 'BG B2');
            assert.equal(feature.scenarios[2].steps[0], 'BG X3');
            assert.equal(feature.scenarios[3].steps[0], 'BG Y4');
        });

        it('should add meta fields to example table', function() {
            var scenarios = parse_file('example_table/meta_fields').scenarios;
            assert.equal(scenarios.length, 2);
            assert.equal(scenarios[0].title, 'First Scenario');
            assert.equal(scenarios[0].steps[0], '1 First 9:5');
            assert.equal(scenarios[0].steps[1], '1 A 9:14');
            assert.equal(scenarios[0].steps[2], '1 1 9:23');
            assert.equal(scenarios[1].title, 'Second Scenario');
            assert.equal(scenarios[1].steps[0], '2 Second 10:5');
            assert.equal(scenarios[1].steps[1], '2 B 10:14');
            assert.equal(scenarios[1].steps[2], '2 2 10:23');
        });

        it('should expand multiline step scenarios from example table', function() {
            var scenarios = parse_file('example_table/multiline_step_example_table').scenarios;
            assert.equal(scenarios.length, 2);
            assert.equal(scenarios[0].title, 'First Scenario');
            assert.equal(scenarios[0].steps[0], 'Step A11\n1AA');
            assert.equal(scenarios[1].title, 'Second Scenario');
            assert.equal(scenarios[1].steps[0], 'Step B22\n2BB');
        });
    });

    describe('(Multiline Example Tables)', function() {

        it('should expand scenarios from simple multiline example table', function() {
            var scenarios = parse_file('example_table/simple_multiline_example_table').scenarios;
            assert.equal(scenarios.length, 2);

            assert.equal(scenarios[0].title, 'Simple Multiline Example Table');
            assert.equal(scenarios[0].steps.length, 2);
            assert.equal(scenarios[0].steps[0], 'Step left 1');
            assert.equal(scenarios[0].steps[1], ['Step right 1', 'right 2'].join('\n'));

            assert.equal(scenarios[1].title, 'Simple Multiline Example Table');
            assert.equal(scenarios[1].steps.length, 2);
            assert.equal(scenarios[1].steps[0], ['Step left 3', 'left 4'].join('\n'));
            assert.equal(scenarios[1].steps[1], 'Step right 3');
        });

        it('should expand scenarios from complex multiline examples', function() {
            var scenarios = parse_file('example_table/complex_multiline_example_table').scenarios;
            assert.equal(scenarios.length, 2);

            assert.equal(scenarios[0].title, 'Complex Multiline Example Table');
            assert.equal(scenarios[0].steps.length, 2);
            assert.equal(scenarios[0].steps[0], 'Step x {\n  y\n }');
            assert.equal(scenarios[0].steps[1], 'Step foo');

            assert.equal(scenarios[1].title, 'Complex Multiline Example Table');
            assert.equal(scenarios[0].steps.length, 2);
            assert.equal(scenarios[1].steps[0], 'Step ');
            assert.equal(scenarios[1].steps[1], 'Step x {\n  y\n }');
        });

        it('should expand scenarios from multiline example table with outer border', function() {
            var scenarios = parse_file('example_table/multiline_example_table_with_outer_border').scenarios;
            assert.equal(scenarios.length, 2);

            assert.equal(scenarios[0].title, 'Multiline Example Table With Outer Border');
            assert.equal(scenarios[0].steps.length, 2);
            assert.equal(scenarios[0].steps[0], 'Step left 1');
            assert.equal(scenarios[0].steps[1], ['Step right 1', 'right 2'].join('\n'));

            assert.equal(scenarios[1].title, 'Multiline Example Table With Outer Border');
            assert.equal(scenarios[1].steps.length, 2);
            assert.equal(scenarios[1].steps[0], ['Step left 3', 'left 4'].join('\n'));
            assert.equal(scenarios[1].steps[1], 'Step right 3');
        });

        it('should report malformed multiline examples', function() {
            assert.throws(function() {
                parse_file('example_table/malformed_multiline_example_table_1');
            }, /Dash is unexpected at this time/);

            assert.throws(function() {
                parse_file('example_table/malformed_multiline_example_table_2');
            }, /Indentation error/);

            assert.throws(function() {
                parse_file('example_table/malformed_multiline_example_table_3');
            }, /Dash is unexpected at this time/);
        });

        it('sshould add meta fields to multiline example table', function() {
            var scenarios = parse_file('example_table/meta_fields_multiline_example_table').scenarios;
            assert.equal(scenarios.length, 2);

            assert.equal(scenarios[0].title, 'Meta Fields Multiline Example Table');
            assert.equal(scenarios[0].steps.length, 2);
            assert.equal(scenarios[0].steps[0], '1 left 1 9:5');
            assert.equal(scenarios[0].steps[1], '1 right 1\nright 2 9:14');

            assert.equal(scenarios[1].title, 'Meta Fields Multiline Example Table');
            assert.equal(scenarios[1].steps.length, 2);
            assert.equal(scenarios[1].steps[0], '2 left 3\nleft 4 12:5');
            assert.equal(scenarios[1].steps[1], '2 right 3 12:14');
        });
    });

    describe('(Localisation)', function() {

        it('should support multiple languages', function() {
            var feature = parse_file('localisation/pirate_feature', Pirate);
            assert.equal(feature.title, 'Treasure Island');

            var scenarios = feature.scenarios;
            assert.equal(scenarios.length, 2);
            assert.equal(scenarios[0].title, 'The Black Spot');
            assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);

            assert(scenarios[1].annotations.brig, 'Localised scenario was not marked as pending');
        });

        it('should support changing the default language', function() {
            Localisation.default = Pirate;
            var feature = new FeatureParser().parse(load('localisation/pirate_feature'));

            assert.equal(feature.title, 'Treasure Island');

            var scenarios = feature.scenarios;
            assert.equal(scenarios.length, 2);
            assert.equal(scenarios[0].title, 'The Black Spot');
            assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);

            assert(scenarios[1].annotations.brig, 'Localised scenario was not marked as pending');
        });

        it('should report missing translations', function() {
            var language = new Language('Incomplete', {});
            assert.throws(function() {
                parse_file('feature/multiple_features', language);
            }, /Keyword "feature" has not been translated into Incomplete/);
        });
    });

    describe('(Feature Backgrounds)', function() {

        it('should parse feature background', function() {
            var feature = parse_file('background/feature_with_background');
            assert.equal(feature.scenarios[0].steps[0], 'Given A');
        });

        it('shoud parse multiline step background', function() {
            var scenarios = parse_file('background/background_with_multiline_step').scenarios;
            assert.equal(scenarios.length, 1);
            assert.equal(scenarios[0].title, 'Simple Scenario');
            assert.equal(scenarios[0].steps[0], poem);
            assert.equal(scenarios[0].steps[1], 'Given A');
        });

        it('should report background annotations', function() {
            assert.throws(function() {
                parse_file('background/malformed_background_annotated');
            }, /Background is unexpected at this time/);
        });
    });

    describe('(Comments)', function() {
        it('should support single line comments', function() {
            var feature = parse_file('comment/singleline_comment');
            var scenarios = feature.scenarios;
            assert.equal(feature.title, 'Single Line Comments Feature');
            assert.equal(scenarios.length, 1);
            assert.equal(scenarios[0].title, 'Single Line Comments Scenario');
            assert.deepEqual(scenarios[0].steps, ['Given A', 'When # B', 'Then C #']);
        });

        it('should parse multiline comments', function() {
            var feature = parse_file('comment/multiline_comment');
            var scenarios = feature.scenarios;
            assert.equal(feature.title, 'Simple Feature');
            assert.equal(scenarios.length, 1);
            assert.equal(scenarios[0].title, 'Simple Scenario');
            assert.deepEqual(scenarios[0].steps, ['Given A', 'When B', 'Then C']);
        });
    });

    function parse_file(filename, language) {
        return new FeatureParser(language).parse(load(filename));
    }

    function load(filename) {
        return fs.readFileSync(path.join(__dirname, 'features', filename + '.feature'), 'utf8');
    }

    var poem = [
        'Good Times May we go our separate ways,',
        'Finding fortune and new friends.',
        'But let us not forget these days,',
        'Or let the good times ever end.',
        '',
        'A poet with wiser words than mine,',
        'Wrote that nothing gold can stay.',
        'These are golden days we\'re in,',
        'And so are bound to fade away.'
    ].join('\n');
});


text:
pyswarms.utils.search package
================================

.. automodule:: pyswarms.utils.search

pyswarms.utils.search.base_search module
-----------------------------------------

.. automodule:: pyswarms.utils.search.base_search
   :members:
   :undoc-members:
   :show-inheritance:
   :private-members:
   :special-members: __init__

pyswarms.utils.search.grid_search module
-----------------------------------------

.. automodule:: pyswarms.utils.search.grid_search
   :members:
   :show-inheritance:
   :special-members: __init__

pyswarms.utils.search.random_search module
-------------------------------------------

.. automodule:: pyswarms.utils.search.random_search
   :members:
   :show-inheritance:
   :special-members:


text:
/*!
 * \file runtime/packed_func.h
 * \brief Type-erased function used across MXNET API.
 */
// Acknowledgement: This file originates from incubator-tvm
#ifndef MXNET_RUNTIME_PACKED_FUNC_H_
#define MXNET_RUNTIME_PACKED_FUNC_H_

#include <dmlc/logging.h>
#include <mxnet/runtime/c_runtime_api.h>
#include <mxnet/runtime/object.h>
#include <mxnet/runtime/ndarray.h>
#include <mxnet/runtime/container.h>
#include <mxnet/runtime/container_ext.h>
#include <mxnet/runtime/ndarray_handle.h>
#include <mxnet/runtime/ffi_helper.h>
#include <mxnet/runtime/data_type.h>
#include <mxnet/runtime/py_arg.h>
#include <mxnet/node/container.h>
#include <mxnet/ir/expr.h>
#include <mxnet/ndarray.h>
#include <mxnet/base.h>
#include <functional>
#include <tuple>
#include <vector>
#include <string>
#include <limits>
#include <memory>
#include <utility>
#include <type_traits>
#include <sstream>

namespace mxnet {
// forward declarations
// class Integer;
// class Expr;

namespace runtime {

/*!
 * \brief convert a string to TVM type.
 * \param s The string to be converted.
 * \return The corresponding tvm type.
 */
inline DLDataType String2DLDataType(std::string s);

// forward declarations
class MXNetArgs;
class MXNetArgValue;
class MXNetRetValue;
class MXNetArgsSetter;

/*!
 * \brief Packed function is a type-erased function.
 *  The arguments are passed by packed format.
 *
 *  This is an useful unified interface to call generated functions,
 *  It is the unified function function type of TVM.
 *  It corresponds to TVMFunctionHandle in C runtime API.
 */
class PackedFunc {
 public:
  /*!
   * \brief The internal std::function
   * \param args The arguments to the function.
   * \param rv The return value.
   *
   * \code
   *   // Example code on how to implemented FType
   *   void MyPackedFunc(MXNetArgs args, MXNetRetValue* rv) {
   *     // automatically convert arguments to desired type.
   *     int a0 = args[0];
   *     float a1 = args[1];
   *     ...
   *     // automatically assign values to rv
   *     std::string my_return_value = "x";
   *     *rv = my_return_value;
   *   }
   * \endcode
   */
  using FType = std::function<void(MXNetArgs args, MXNetRetValue* rv)>;
  /*! \brief default constructor */
  PackedFunc() {}
  /*! \brief constructor from null */
  PackedFunc(std::nullptr_t null) {}  // NOLINT(*)
  /*!
   * \brief constructing a packed function from a std::function.
   * \param body the internal container of packed function.
   */
  explicit PackedFunc(FType body) : body_(body) {}
  /*!
   * \brief Call packed function by directly passing in unpacked format.
   * \param args Arguments to be passed.
   * \tparam Args arguments to be passed.
   *
   * \code
   *   // Example code on how to call packed function
   *   void CallPacked(PackedFunc f) {
   *     // call like normal functions by pass in arguments
   *     // return value is automatically converted back
   *     int rvalue = f(1, 2.0);
   *   }
   * \endcode
   */
  template <typename... Args>
  inline MXNetRetValue operator()(Args&&... args) const;
  /*!
   * \brief Call the function in packed format.
   * \param args The arguments
   * \param rv The return value.
   */
  inline void CallPacked(MXNetArgs args, MXNetRetValue* rv) const;
  /*! \return the internal body function */
  inline FType body() const;
  /*! \return Whether the packed function is nullptr */
  bool operator==(std::nullptr_t null) const {
    return body_ == nullptr;
  }
  /*! \return Whether the packed function is not nullptr */
  bool operator!=(std::nullptr_t null) const {
    return body_ != nullptr;
  }

 private:
  /*! \brief internal container of packed function */
  FType body_;
};

/*!
 * \brief Please refer to \ref TypedPackedFuncAnchor "TypedPackedFunc<R(Args..)>"
 */
template <typename FType>
class TypedPackedFunc;

/*!
 * \anchor TypedPackedFuncAnchor
 * \brief A PackedFunc wrapper to provide typed function signature.
 * It is backed by a PackedFunc internally.
 *
 * TypedPackedFunc enables compile time type checking.
 * TypedPackedFunc works with the runtime system:
 * - It can be passed as an argument of PackedFunc.
 * - It can be assigned to MXNetRetValue.
 * - It can be directly converted to a type-erased PackedFunc.
 *
 * Developers should prefer TypedPackedFunc over PackedFunc in C++ code
 * as it enables compile time checking.
 * We can construct a TypedPackedFunc from a lambda function
 * with the same signature.
 *
 * \code
 *  // user defined lambda function.
 *  auto addone = [](int x)->int {
 *    return x + 1;
 *  };
 *  // We can directly convert
 *  // lambda function to TypedPackedFunc
 *  TypedPackedFunc<int(int)> ftyped(addone);
 *  // invoke the function.
 *  int y = ftyped(1);
 *  // Can be directly converted to PackedFunc
 *  PackedFunc packed = ftype;
 * \endcode
 * \tparam R The return value of the function.
 * \tparam Args The argument signature of the function.
 */
template <typename R, typename... Args>
class TypedPackedFunc<R(Args...)> {
 public:
  /*! \brief short hand for this function type */
  using TSelf = TypedPackedFunc<R(Args...)>;
  /*! \brief default constructor */
  TypedPackedFunc() {}
  /*! \brief constructor from null */
  TypedPackedFunc(std::nullptr_t null) {}  // NOLINT(*)
  /*!
   * \brief construct by wrap a PackedFunc
   *
   * Example usage:
   * \code
   * PackedFunc packed([](MXNetArgs args, MXNetRetValue *rv) {
   *   int x = args[0];
   *   *rv = x + 1;
   *  });
   * // construct from packed function
   * TypedPackedFunc<int(int)> ftyped(packed);
   * // call the typed version.
   * CHECK_EQ(ftyped(1), 2);
   * \endcode
   *
   * \param packed The packed function
   */
  inline TypedPackedFunc(PackedFunc packed);  // NOLINT(*)
  /*!
   * \brief constructor from MXNetRetValue
   * \param value The MXNetRetValue
   */
  inline TypedPackedFunc(const MXNetRetValue& value);  // NOLINT(*)
  /*!
   * \brief constructor from MXNetArgValue
   * \param value The MXNetArgValue
   */
  inline TypedPackedFunc(const MXNetArgValue& value);  // NOLINT(*)
  /*!
   * \brief construct from a lambda function with the same signature.
   *
   * Example usage:
   * \code
   * auto typed_lambda = [](int x)->int { return x + 1; }
   * // construct from packed function
   * TypedPackedFunc<int(int)> ftyped(typed_lambda);
   * // call the typed version.
   * CHECK_EQ(ftyped(1), 2);
   * \endcode
   *
   * \param typed_lambda typed lambda function.
   * \tparam FLambda the type of the lambda function.
   */
  template <typename FLambda,
            typename = typename std::enable_if<
                std::is_convertible<FLambda,
                                    std::function<R(Args...)>>::value>::type>
  TypedPackedFunc(const FLambda& typed_lambda) {  // NOLINT(*)
    this->AssignTypedLambda(typed_lambda);
  }
  /*!
   * \brief copy assignment operator from typed lambda
   *
   * Example usage:
   * \code
   * // construct from packed function
   * TypedPackedFunc<int(int)> ftyped;
   * ftyped = [](int x) { return x + 1; }
   * // call the typed version.
   * CHECK_EQ(ftyped(1), 2);
   * \endcode
   *
   * \param typed_lambda typed lambda function.
   * \tparam FLambda the type of the lambda function.
   * \returns reference to self.
   */
  template <typename FLambda,
            typename = typename std::enable_if<
                std::is_convertible<FLambda,
                                    std::function<R(Args...)>>::value>::type>
  TSelf& operator=(FLambda typed_lambda) {  // NOLINT(*)
    this->AssignTypedLambda(typed_lambda);
    return *this;
  }
  /*!
   * \brief copy assignment operator from PackedFunc.
   * \param packed The packed function.
   * \returns reference to self.
   */
  TSelf& operator=(PackedFunc packed) {
    packed_ = packed;
    return *this;
  }
  /*!
   * \brief Invoke the operator.
   * \param args The arguments
   * \returns The return value.
   */
  inline R operator()(Args... args) const;
  /*!
   * \brief convert to PackedFunc
   * \return the internal PackedFunc
   */
  operator PackedFunc() const {
    return packed();
  }
  /*!
   * \return reference the internal PackedFunc
   */
  const PackedFunc& packed() const {
    return packed_;
  }
  /*! \return Whether the packed function is nullptr */
  bool operator==(std::nullptr_t null) const {
    return packed_ == nullptr;
  }
  /*! \return Whether the packed function is not nullptr */
  bool operator!=(std::nullptr_t null) const {
    return packed_ != nullptr;
  }

 private:
  friend class MXNetRetValue;
  /*! \brief The internal packed function */
  PackedFunc packed_;
  /*!
   * \brief Assign the packed field using a typed lambda function.
   *
   * \param flambda The lambda function.
   * \tparam FLambda The lambda function type.
   * \note We capture the lambda when possible for maximum efficiency.
   */
  template <typename FLambda>
  inline void AssignTypedLambda(FLambda flambda);
};

/*! \brief Arguments into TVM functions. */
class MXNetArgs {
 public:
  const MXNetValue* values;
  const int* type_codes;
  int num_args;
  /*!
   * \brief constructor
   * \param values The argument values
   * \param type_codes The argument type codes
   * \param num_args number of arguments.
   */
  MXNetArgs(const MXNetValue* values, const int* type_codes, int num_args)
      : values(values), type_codes(type_codes), num_args(num_args) {}
  /*! \return size of the arguments */
  inline int size() const;
  /*!
   * \brief Get i-th argument
   * \param i the index.
   * \return the ith argument.
   */
  inline MXNetArgValue operator[](int i) const;
};

/*!
 * \brief Convert type code to its name
 * \param type_code The type code .
 * \return The name of type code.
 */
inline const char* TypeCode2Str(int type_code);

/*!
 * \brief convert a string to TVM type.
 * \param s The string to be converted.
 * \return The corresponding tvm type.
 */
// inline TVMType String2TVMType(std::string s);

// macro to check type code.
#define MXNET_CHECK_TYPE_CODE(CODE, T) \
  CHECK_EQ(CODE, T) << " expected " << TypeCode2Str(T) << " but get " << TypeCode2Str(CODE)

/*!
 * \brief Type traits to mark if a class is tvm extension type.
 *
 * To enable extension type in C++ must be registered via marco.
 * TVM_REGISTER_EXT_TYPE(TypeName) after defining this with this traits.
 *
 * Extension class can be passed and returned via PackedFunc in all tvm runtime.
 * Internally extension class is stored as T*.
 *
 * \tparam T the typename
 */
template <typename T>
struct extension_type_info {
  static const int code = 0;
};

/*!
 * \brief Type traits for runtime type check during FFI conversion.
 * \tparam T the type to be checked.
 */
template <typename T>
struct ObjectTypeChecker {
  static bool Check(const Object* ptr) {
    using ContainerType = typename T::ContainerType;
    if (ptr == nullptr)
      return T::_type_is_nullable;
    return ptr->IsInstance<ContainerType>();
  }
  static std::string TypeName() {
    using ContainerType = typename T::ContainerType;
    return ContainerType::_type_key;
  }
};

/*!
 * \brief Internal base class to
 *  handle conversion to POD values.
 */
class MXNetPODValue_ {
 public:
  operator double() const {
    // Allow automatic conversion from int to float
    // This avoids errors when user pass in int from
    // the frontend while the API expects a float.
    if (type_code_ == kDLInt) {
      return static_cast<double>(value_.v_int64);
    }
    MXNET_CHECK_TYPE_CODE(type_code_, kDLFloat);
    return value_.v_float64;
  }
  operator int64_t() const {
    MXNET_CHECK_TYPE_CODE(type_code_, kDLInt);
    return value_.v_int64;
  }
  operator uint64_t() const {
    MXNET_CHECK_TYPE_CODE(type_code_, kDLUInt);
    return value_.v_uint64;
  }
  operator int() const {
    MXNET_CHECK_TYPE_CODE(type_code_, kDLInt);
    CHECK_LE(value_.v_int64, std::numeric_limits<int>::max());
    return static_cast<int>(value_.v_int64);
  }
  operator bool() const {
    MXNET_CHECK_TYPE_CODE(type_code_, kDLInt);
    return value_.v_int64 != 0;
  }
  operator void*() const {
    if (type_code_ == kNull)
      return nullptr;
    MXNET_CHECK_TYPE_CODE(type_code_, kHandle);
    return value_.v_handle;
  }
  operator ObjectRef() const {
    if (type_code_ == kNull) {
      return ObjectRef(ObjectPtr<Object>(nullptr));
    }
    MXNET_CHECK_TYPE_CODE(type_code_, kObjectHandle);
    return ObjectRef(ObjectPtr<Object>(static_cast<Object*>(value_.v_handle)));
  }
  template <typename TObjectRef,
            typename = typename std::enable_if<std::is_class<TObjectRef>::value>::type>
  inline bool IsObjectRef() const;
  template <typename TObjectRef>
  inline TObjectRef AsObjectRef() const;
  int type_code() const {
    return type_code_;
  }

  /*!
   * \brief return handle as specific pointer type.
   * \tparam T the data type.
   * \return The pointer type.
   */
  template <typename T>
  T* ptr() const {
    return static_cast<T*>(value_.v_handle);
  }

 protected:
  friend class MXNetArgsSetter;
  friend class MXNetRetValue;
  MXNetPODValue_() : type_code_(kNull) {}
  MXNetPODValue_(MXNetValue value, int type_code) : value_(value), type_code_(type_code) {}

  /*! \brief The value */
  MXNetValue value_;
  /*! \brief the type code */
  int type_code_;
};

/*!
 * \brief A single argument value to PackedFunc.
 *  Containing both type_code and MXNetValue
 *
 *  Provides utilities to do type cast into other types.
 */
class MXNetArgValue : public MXNetPODValue_ {
 public:
  /*! \brief default constructor */
  MXNetArgValue() {}
  /*!
   * \brief constructor
   * \param value of the function
   * \param type_code The type code.
   */
  MXNetArgValue(MXNetValue value, int type_code) : MXNetPODValue_(value, type_code) {}
  // reuse converter from parent
  using MXNetPODValue_::operator double;
  using MXNetPODValue_::operator int64_t;
  using MXNetPODValue_::operator uint64_t;
  using MXNetPODValue_::operator int;
  using MXNetPODValue_::operator bool;
  using MXNetPODValue_::operator void*;
  using MXNetPODValue_::operator ObjectRef;
  using MXNetPODValue_::AsObjectRef;
  using MXNetPODValue_::IsObjectRef;

  // conversion operator.
  operator std::string() const {
    if (type_code_ == kBytes) {
      MXNetByteArray* arr = static_cast<MXNetByteArray*>(value_.v_handle);
      return std::string(arr->data, arr->size);
    } else {
      MXNET_CHECK_TYPE_CODE(type_code_, kStr);
      return std::string(value_.v_str);
    }
  }
  operator DLDataType() const {
    if (type_code_ == kStr) {
      return String2DLDataType(operator std::string());
    }
    // None type
    if (type_code_ == kNull) {
      DLDataType t;
      t.code  = kHandle;
      t.bits  = 0;
      t.lanes = 0;
      return t;
    }
    MXNET_CHECK_TYPE_CODE(type_code_, kMXNetType);
    return value_.v_type;
  }
  operator MXNetDataType() const {
    return MXNetDataType(operator DLDataType());
  }
  operator ::mxnet::NDArray*() const {
    if (type_code_ == kNull) {
      return nullptr;
    }
    MXNET_CHECK_TYPE_CODE(type_code_, kNDArrayHandle);
    return reinterpret_cast<::mxnet::NDArray*>(value_.v_handle);
  }
  template <typename FType>
  operator TypedPackedFunc<FType>() const {
    return TypedPackedFunc<FType>(operator PackedFunc());
  }
  const MXNetValue& value() const {
    return value_;
  }
  template <typename T, typename = typename std::enable_if<std::is_class<T>::value>::type>
  inline operator T() const;
};

/*!
 * \brief Return Value container,
 *  Unlike MXNetArgValue, which only holds reference and do not delete
 *  the underlying container during destruction.
 *
 *  MXNetRetValue holds value and will manage the underlying containers
 *  when it stores a complicated data type.
 */
class MXNetRetValue : public MXNetPODValue_ {
 public:
  /*! \brief default constructor */
  MXNetRetValue() {}
  /*!
   * \brief move constructor from anoter return value.
   * \param other The other return value.
   */
  MXNetRetValue(MXNetRetValue&& other) : MXNetPODValue_(other.value_, other.type_code_) {
    other.value_.v_handle = nullptr;
    other.type_code_      = kNull;
  }
  /*! \brief destructor */
  ~MXNetRetValue() {
    this->Clear();
  }
  // reuse converter from parent
  using MXNetPODValue_::operator double;
  using MXNetPODValue_::operator int64_t;
  using MXNetPODValue_::operator uint64_t;
  using MXNetPODValue_::operator int;
  using MXNetPODValue_::operator bool;
  using MXNetPODValue_::operator void*;
  using MXNetPODValue_::operator ObjectRef;
  using MXNetPODValue_::AsObjectRef;
  using MXNetPODValue_::IsObjectRef;

  MXNetRetValue(const MXNetRetValue& other) : MXNetPODValue_() {
    this->Assign(other);
  }
  // conversion operators
  operator std::string() const {
    if (type_code_ == kBytes) {
      return *ptr<std::string>();
    }
    MXNET_CHECK_TYPE_CODE(type_code_, kStr);
    return *ptr<std::string>();
  }
  operator DLDataType() const {
    if (type_code_ == kStr) {
      return String2DLDataType(operator std::string());
    }
    MXNET_CHECK_TYPE_CODE(type_code_, kMXNetType);
    return value_.v_type;
  }
  operator MXNetDataType() const {
    return MXNetDataType(operator DLDataType());
  }
  template <typename FType>
  operator TypedPackedFunc<FType>() const {
    return TypedPackedFunc<FType>(operator PackedFunc());
  }
  // Assign operators
  MXNetRetValue& operator=(MXNetRetValue&& other) {
    this->Clear();
    value_           = other.value_;
    type_code_       = other.type_code_;
    other.type_code_ = kNull;
    return *this;
  }
  MXNetRetValue& operator=(double value) {
    this->SwitchToPOD(kDLFloat);
    value_.v_float64 = value;
    return *this;
  }
  MXNetRetValue& operator=(std::nullptr_t value) {
    this->SwitchToPOD(kNull);
    value_.v_handle = value;
    return *this;
  }
  MXNetRetValue& operator=(void* value) {
    this->SwitchToPOD(kHandle);
    value_.v_handle = value;
    return *this;
  }
  MXNetRetValue& operator=(int64_t value) {
    this->SwitchToPOD(kDLInt);
    value_.v_int64 = value;
    return *this;
  }
  MXNetRetValue& operator=(int value) {
    this->SwitchToPOD(kDLInt);
    value_.v_int64 = value;
    return *this;
  }
  MXNetRetValue& operator=(bool value) {
    this->SwitchToPOD(kDLInt);
    value_.v_int64 = value;
    return *this;
  }
  MXNetRetValue& operator=(std::string value) {
    this->SwitchToClass(kStr, value);
    return *this;
  }
  MXNetRetValue& operator=(DLDataType t) {
    this->SwitchToPOD(kMXNetType);
    value_.v_type = t;
    return *this;
  }
  MXNetRetValue& operator=(const MXNetDataType& other) {
    return operator=(other.operator DLDataType());
  }
  MXNetRetValue& operator=(MXNetByteArray value) {
    this->SwitchToClass(kBytes, std::string(value.data, value.size));
    return *this;
  }
  MXNetRetValue& operator=(ObjectRef other) {
    if (other.as<NDArrayHandleObj>()) {
      return operator=(Downcast<NDArrayHandle, ObjectRef>(other));
    }
    return operator=(std::move(other.data_));
  }
  template <typename T>
  MXNetRetValue& operator=(ObjectPtr<T> other) {
    SwitchToObject(kObjectHandle, std::move(other));
    return *this;
  }
  template <typename FType>
  MXNetRetValue& operator=(const TypedPackedFunc<FType>& f) {
    return operator=(f.packed());
  }
  MXNetRetValue& operator=(const MXNetRetValue& other) {  // NOLINT(*0
    this->Assign(other);
    return *this;
  }
  MXNetRetValue& operator=(const MXNetArgValue& other) {
    this->Assign(other);
    return *this;
  }
  MXNetRetValue& operator=(NDArray* value) {
    this->SwitchToPOD(kNDArrayHandle);
    value_.v_handle = reinterpret_cast<void*>(value);
    return *this;
  }
  MXNetRetValue& operator=(NDArrayHandle value) {
    this->SwitchToPOD(kNDArrayHandle);
    NDArray* arr    = new NDArray(value->value);
    value_.v_handle = reinterpret_cast<void*>(arr);
    return *this;
  }
  MXNetRetValue& operator=(const PythonArg& value) {
    this->SwitchToPOD(kPyArg);
    value_.v_int64 = value.offset();
    return *this;
  }
  template <typename T, typename = typename std::enable_if<extension_type_info<T>::code != 0>::type>
  MXNetRetValue& operator=(const T& other) {
    this->SwitchToClass<T>(extension_type_info<T>::code, other);
    return *this;
  }
  /*!
   * \brief Move the value back to front-end via C API.
   *  This marks the current container as null.
   *  The managed resources is moved to front-end and
   *  the front end should take charge in managing them.
   *
   * \param ret_value The return value.
   * \param ret_type_code The return type code.
   */
  void MoveToCHost(MXNetValue* ret_value, int* ret_type_code) {
    // cannot move str; need specially handle.
    CHECK(type_code_ != kStr && type_code_ != kBytes);
    *ret_value     = value_;
    *ret_type_code = type_code_;
    type_code_     = kNull;
  }
  /*! \return The value field, if the data is POD */
  const MXNetValue& value() const {
    CHECK(type_code_ != kObjectHandle && type_code_ != kStr)
        << "MXNetRetValue.value can only be used for POD data";
    return value_;
  }
  // ObjectRef related extenstions: in tvm/packed_func_ext.h
  template <typename T, typename = typename std::enable_if<std::is_class<T>::value>::type>
  inline operator T() const;

 private:
  template <typename T>
  void Assign(const T& other) {
    switch (other.type_code()) {
      case kStr: {
        SwitchToClass<std::string>(kStr, other);
        break;
      }
      case kBytes: {
        SwitchToClass<std::string>(kBytes, other);
        break;
      }
      case kObjectHandle: {
        *this = other.operator ObjectRef();
        break;
      }
      default: {
        if (other.type_code() < kExtBegin) {
          SwitchToPOD(other.type_code());
          value_ = other.value_;
        } else {
          LOG(FATAL) << "Does not support ext type";
        }
        break;
      }
    }
  }
  // get the internal container.
  void SwitchToPOD(int type_code) {
    if (type_code_ != type_code) {
      this->Clear();
      type_code_ = type_code;
    }
  }
  template <typename T>
  void SwitchToClass(int type_code, T v) {
    if (type_code_ != type_code) {
      this->Clear();
      type_code_      = type_code;
      value_.v_handle = new T(v);
    } else {
      *static_cast<T*>(value_.v_handle) = v;
    }
  }
  void SwitchToObject(int type_code, ObjectPtr<Object> other) {
    if (other.data_ != nullptr) {
      this->Clear();
      type_code_ = type_code;
      // move the handle out
      value_.v_handle = other.data_;
      other.data_     = nullptr;
    } else {
      SwitchToPOD(kNull);
    }
  }
  void Clear() {
    if (type_code_ == kNull)
      return;
    switch (type_code_) {
      case kStr:
        delete ptr<std::string>();
        break;
      case kObjectHandle: {
        static_cast<Object*>(value_.v_handle)->DecRef();
        break;
      }
    }
    if (type_code_ > kExtBegin) {
      LOG(FATAL) << "Does not support ext type";
    }
    type_code_ = kNull;
  }
};

inline DLDataType String2DLDataType(std::string s) {
  DLDataType t;
  // handle None type
  if (s.length() == 0) {
    t.bits  = 0;
    t.lanes = 0;
    t.code  = kHandle;
    return t;
  }
  t.bits           = 32;
  t.lanes          = 1;
  const char* scan = nullptr;
  if (s.substr(0, 3) == "int") {
    t.code = kDLInt;
    scan   = s.c_str() + 3;
  } else if (s.substr(0, 4) == "uint") {
    t.code = kDLUInt;
    scan   = s.c_str() + 4;
  } else if (s.substr(0, 5) == "float") {
    t.code = kDLFloat;
    scan   = s.c_str() + 5;
  } else if (s.substr(0, 6) == "handle") {
    t.code = kHandle;
    t.bits = 64;  // handle uses 64 bit by default.
    scan   = s.c_str() + 6;
  } else if (s == "bool") {
    t.code  = kDLUInt;
    t.bits  = 1;
    t.lanes = 1;
    return t;
  } else if (s.substr(0, 6) == "custom") {
    LOG(FATAL) << "custom MXNetDataType is not supported";
    // t.code = ParseCustomDatatype(s, &scan);
  } else {
    scan = s.c_str();
    LOG(FATAL) << "unknown type " << s;
  }
  char* xdelim;  // emulate sscanf("%ux%u", bits, lanes)
  uint8_t bits = static_cast<uint8_t>(strtoul(scan, &xdelim, 10));
  if (bits != 0)
    t.bits = bits;
  char* endpt = xdelim;
  if (*xdelim == 'x') {
    t.lanes = static_cast<uint16_t>(strtoul(xdelim + 1, &endpt, 10));
  }
  CHECK(endpt == s.c_str() + s.length()) << "unknown type " << s;
  return t;
}

// implementation details
inline const char* TypeCode2Str(int type_code) {
  switch (type_code) {
    case kDLInt:
      return "int";
    case kDLUInt:
      return "uint";
    case kDLFloat:
      return "float";
    case kStr:
      return "str";
    case kBytes:
      return "bytes";
    case kHandle:
      return "handle";
    case kNull:
      return "NULL";
    case kObjectHandle:
      return "ObjectCell";
    case kNDArrayHandle:
      return "NDArray";
    default:
      LOG(FATAL) << "unknown type_code=" << static_cast<int>(type_code);
      return "";
  }
}

inline int String2MXNetTypeWithBool(const std::string& s) {
  if (s == "float32") {
    return mshadow::kFloat32;
  } else if (s == "float64") {
    return mshadow::kFloat64;
  } else if (s == "float16") {
    return mshadow::kFloat16;
  } else if (s == "bfloat16") {
    return mshadow::kBfloat16;
  } else if (s == "uint8") {
    return mshadow::kUint8;
  } else if (s == "int8") {
    return mshadow::kInt8;
  } else if (s == "int32") {
    return mshadow::kInt32;
  } else if (s == "int64") {
    return mshadow::kInt64;
  } else if (s == "bool") {
    return mshadow::kBool;
  } else if (s == "int16") {
    return mshadow::kInt16;
  } else if (s == "uint16") {
    return mshadow::kUint16;
  } else if (s == "uint32") {
    return mshadow::kUint32;
  } else if (s == "uint64") {
    return mshadow::kUint64;
  } else {
    LOG(FATAL) << "unknown type " << s;
  }
  LOG(FATAL) << "should not reach here ";
  return 0;
}

inline int String2MXNetType(const std::string& s) {
  if (s == "float32") {
    return mshadow::kFloat32;
  } else if (s == "float64") {
    return mshadow::kFloat64;
  } else if (s == "float16") {
    return mshadow::kFloat16;
  } else if (s == "bfloat16") {
    return mshadow::kBfloat16;
  } else if (s == "uint8") {
    return mshadow::kUint8;
  } else if (s == "int8") {
    return mshadow::kInt8;
  } else if (s == "int32") {
    return mshadow::kInt32;
  } else if (s == "int64") {
    return mshadow::kInt64;
  } else if (s == "int16") {
    return mshadow::kInt16;
  } else if (s == "uint16") {
    return mshadow::kUint16;
  } else if (s == "uint32") {
    return mshadow::kUint32;
  } else if (s == "uint64") {
    return mshadow::kUint64;
  } else {
    LOG(FATAL) << "unknown type " << s;
  }
  LOG(FATAL) << "should not reach here ";
  return 0;
}

inline std::ostream& operator<<(std::ostream& os, DLDataType t) {  // NOLINT(*)
  if (t.bits == 1 && t.lanes == 1 && t.code == kDLUInt) {
    os << "bool";
    return os;
  }
  if (t.code < kCustomBegin) {
    os << TypeCode2Str(t.code);
  } else {
    LOG(FATAL) << "custom MXNetDataType is not supported";
    // os << "custom[" << GetCustomTypeName(t.code) << "]";
  }
  if (t.code == kHandle)
    return os;
  os << static_cast<int>(t.bits);
  if (t.lanes != 1) {
    os << 'x' << static_cast<int>(t.lanes);
  }
  return os;
}

inline std::ostream& operator<<(std::ostream& os, const MXNetDataType& dtype) {  // NOLINT(*)
  return os << dtype.operator DLDataType();
}

inline MXNetArgValue MXNetArgs::operator[](int i) const {
  CHECK_LT(i, num_args) << "not enough argument passed, " << num_args << " passed"
                        << " but request arg[" << i << "].";
  return MXNetArgValue(values[i], type_codes[i]);
}

inline int MXNetArgs::size() const {
  return num_args;
}

inline void PackedFunc::CallPacked(MXNetArgs args, MXNetRetValue* rv) const {
  body_(args, rv);
}

inline PackedFunc::FType PackedFunc::body() const {
  return body_;
}

// internal namespace
namespace detail {

template <bool stop, std::size_t I, typename F>
struct for_each_dispatcher {
  template <typename T, typename... Args>
  static void run(const F& f, T&& value, Args&&... args) {  // NOLINT(*)
    f(I, std::forward<T>(value));
    for_each_dispatcher<sizeof...(Args) == 0, (I + 1), F>::run(f, std::forward<Args>(args)...);
  }
};

template <std::size_t I, typename F>
struct for_each_dispatcher<true, I, F> {
  static void run(const F& f) {}  // NOLINT(*)
};

template <typename F, typename... Args>
inline void for_each(const F& f, Args&&... args) {  // NOLINT(*)
  for_each_dispatcher<sizeof...(Args) == 0, 0, F>::run(f, std::forward<Args>(args)...);
}
}  // namespace detail

/* \brief argument settter to PackedFunc */
class MXNetArgsSetter {
 public:
  MXNetArgsSetter(MXNetValue* values, int* type_codes) : values_(values), type_codes_(type_codes) {}
  // setters for POD types
  template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type>
  void operator()(size_t i, T value) const {
    values_[i].v_int64 = static_cast<int64_t>(value);
    type_codes_[i]     = kDLInt;
  }
  void operator()(size_t i, uint64_t value) const {
    values_[i].v_int64 = static_cast<int64_t>(value);
    CHECK_LE(value, static_cast<uint64_t>(std::numeric_limits<int64_t>::max()));
    type_codes_[i] = kDLInt;
  }
  void operator()(size_t i, double value) const {
    values_[i].v_float64 = value;
    type_codes_[i]       = kDLFloat;
  }
  void operator()(size_t i, std::nullptr_t value) const {
    values_[i].v_handle = value;
    type_codes_[i]      = kNull;
  }
  void operator()(size_t i, const MXNetArgValue& value) const {
    values_[i]     = value.value_;
    type_codes_[i] = value.type_code_;
  }
  void operator()(size_t i, void* value) const {
    values_[i].v_handle = value;
    type_codes_[i]      = kHandle;
  }
  void operator()(size_t i, const char* value) const {
    values_[i].v_str = value;
    type_codes_[i]   = kStr;
  }
  // setters for container type
  // They must be reference(instead of const ref)
  // to make sure they are alive in the tuple(instead of getting converted)
  void operator()(size_t i, const std::string& value) const {  // NOLINT(*)
    values_[i].v_str = value.c_str();
    type_codes_[i]   = kStr;
  }
  void operator()(size_t i, DLDataType value) const {
    values_[i].v_type = value;
    type_codes_[i]    = kMXNetType;
  }
  void operator()(size_t i, MXNetDataType dtype) const {
    operator()(i, dtype.operator DLDataType());
  }
  void operator()(size_t i, const MXNetByteArray& value) const {  // NOLINT(*)
    values_[i].v_handle = const_cast<MXNetByteArray*>(&value);
    type_codes_[i]      = kBytes;
  }
  template <typename FType>
  void operator()(size_t i, const TypedPackedFunc<FType>& value) const {  // NOLINT(*)
    operator()(i, value.packed());
  }
  void operator()(size_t i, const ObjectRef& value) const {  // NOLINT(*)
    if (value.defined()) {
      values_[i].v_handle = value.data_.data_;
      type_codes_[i]      = kObjectHandle;
    } else {
      type_codes_[i] = kNull;
    }
  }
  void operator()(size_t i, const MXNetRetValue& value) const {  // NOLINT(*)
    if (value.type_code() == kStr) {
      values_[i].v_str = value.ptr<std::string>()->c_str();
      type_codes_[i]   = kStr;
    } else {
      CHECK_NE(value.type_code(), kBytes) << "not handled.";
      values_[i]     = value.value_;
      type_codes_[i] = value.type_code();
    }
  }

 private:
  /*! \brief The values fields */
  MXNetValue* values_;
  /*! \brief The type code fields */
  int* type_codes_;
};

template <typename... Args>
inline MXNetRetValue PackedFunc::operator()(Args&&... args) const {
  const int kNumArgs   = sizeof...(Args);
  const int kArraySize = kNumArgs > 0 ? kNumArgs : 1;
  MXNetValue values[kArraySize];
  int type_codes[kArraySize];
  detail::for_each(MXNetArgsSetter(values, type_codes), std::forward<Args>(args)...);
  MXNetRetValue rv;
  body_(MXNetArgs(values, type_codes, kNumArgs), &rv);
  return rv;
}

namespace detail {
template <typename R, int nleft, int index, typename F>
struct unpack_call_dispatcher {
  template <typename... Args>
  static void run(const F& f,
                  const MXNetArgs& args_pack,
                  MXNetRetValue* rv,
                  Args&&... unpacked_args) {
    unpack_call_dispatcher<R, nleft - 1, index + 1, F>::run(
        f, args_pack, rv, std::forward<Args>(unpacked_args)..., args_pack[index]);
  }
};

template <typename R, int index, typename F>
struct unpack_call_dispatcher<R, 0, index, F> {
  template <typename... Args>
  static void run(const F& f,
                  const MXNetArgs& args_pack,
                  MXNetRetValue* rv,
                  Args&&... unpacked_args) {
    *rv = R(f(std::forward<Args>(unpacked_args)...));
  }
};

template <int index, typename F>
struct unpack_call_dispatcher<void, 0, index, F> {
  template <typename... Args>
  static void run(const F& f,
                  const MXNetArgs& args_pack,
                  MXNetRetValue* rv,
                  Args&&... unpacked_args) {
    f(std::forward<Args>(unpacked_args)...);
  }
};

template <typename R, int nargs, typename F>
inline void unpack_call(const F& f, const MXNetArgs& args, MXNetRetValue* rv) {
  unpack_call_dispatcher<R, nargs, 0, F>::run(f, args, rv);
}

template <typename R, typename... Args>
inline R call_packed(const PackedFunc& pf, Args&&... args) {
  return R(pf(std::forward<Args>(args)...));
}

template <typename R>
struct typed_packed_call_dispatcher {
  template <typename... Args>
  static inline R run(const PackedFunc& pf, Args&&... args) {
    return pf(std::forward<Args>(args)...);
  }
};

template <>
struct typed_packed_call_dispatcher<void> {
  template <typename... Args>
  static inline void run(const PackedFunc& pf, Args&&... args) {
    pf(std::forward<Args>(args)...);
  }
};
}  // namespace detail

template <typename R, typename... Args>
TypedPackedFunc<R(Args...)>::TypedPackedFunc(PackedFunc packed) : packed_(packed) {}

template <typename R, typename... Args>
TypedPackedFunc<R(Args...)>::TypedPackedFunc(const MXNetRetValue& value)
    : packed_(value.operator PackedFunc()) {}

template <typename R, typename... Args>
TypedPackedFunc<R(Args...)>::TypedPackedFunc(const MXNetArgValue& value)
    : packed_(value.operator PackedFunc()) {}

template <typename R, typename... Args>
template <typename FType>
inline void TypedPackedFunc<R(Args...)>::AssignTypedLambda(FType flambda) {
  packed_ = PackedFunc([flambda](const MXNetArgs& args, MXNetRetValue* rv) {
    detail::unpack_call<R, sizeof...(Args)>(flambda, args, rv);
  });
}

template <typename R, typename... Args>
inline R TypedPackedFunc<R(Args...)>::operator()(Args... args) const {
  return detail::typed_packed_call_dispatcher<R>::run(packed_, std::forward<Args>(args)...);
}

// extension and node type handling
namespace detail {
template <typename T, typename TSrc, bool is_ext, bool is_nd>
struct MXNetValueCast {
  static T Apply(const TSrc* self) {
    static_assert(!is_ext && !is_nd, "The default case accepts only non-extensions");
    return self->template AsObjectRef<T>();
  }
};

}  // namespace detail

/*!
 * \brief Type trait to specify special value conversion rules from
 *        MXNetArgValue and MXNetRetValue.
 *
 *  The trait can be specialized to add type specific conversion logic
 *  from the TVMArgvalue and TVMRetValue.
 *
 * \tparam TObjectRef the specific ObjectRefType.
 */
template <typename TObjectRef>
struct PackedFuncValueConverter {
  /*!
   * \brief Convert a TObjectRef from an argument value.
   * \param val The argument value.
   * \return the converted result.
   */
  static TObjectRef From(const MXNetArgValue& val) {
    return val.AsObjectRef<TObjectRef>();
  }
  /*!
   * \brief Convert a TObjectRef from a return value.
   * \param val The argument value.
   * \return the converted result.
   */
  static TObjectRef From(const MXNetRetValue& val) {
    return val.AsObjectRef<TObjectRef>();
  }
};

template <>
struct PackedFuncValueConverter<::mxnet::runtime::String> {
  static String From(const MXNetArgValue& val) {
    if (val.IsObjectRef<mxnet::runtime::String>()) {
      return val.AsObjectRef<mxnet::runtime::String>();
    } else {
      return mxnet::runtime::String(val.operator std::string());
    }
  }

  static String From(const MXNetRetValue& val) {
    if (val.IsObjectRef<mxnet::runtime::String>()) {
      return val.AsObjectRef<mxnet::runtime::String>();
    } else {
      return mxnet::runtime::String(val.operator std::string());
    }
  }
};

template <typename TObjectRef>
inline TObjectRef MXNetPODValue_::AsObjectRef() const {
  static_assert(std::is_base_of<ObjectRef, TObjectRef>::value,
                "Conversion only works for ObjectRef");
  using ContainerType = typename TObjectRef::ContainerType;

  if (type_code_ == kNull) {
    CHECK(TObjectRef::_type_is_nullable)
        << "Expect a not null value of " << ContainerType::_type_key;
    return TObjectRef(ObjectPtr<Object>(nullptr));
  }
  if (type_code_ == kObjectHandle) {
    // normal object type check.
    Object* ptr = static_cast<Object*>(value_.v_handle);
    CHECK(ObjectTypeChecker<TObjectRef>::Check(ptr))
        << "Expect " << ObjectTypeChecker<TObjectRef>::TypeName() << " but get "
        << ptr->GetTypeKey();
    return TObjectRef(GetObjectPtr<Object>(ptr));
  } else {
    MXNET_CHECK_TYPE_CODE(type_code_, kObjectHandle);
    return TObjectRef(ObjectPtr<Object>(nullptr));
  }
}

template <typename T, typename>
inline MXNetArgValue::operator T() const {
  return PackedFuncValueConverter<T>::From(*this);
}

template <typename TObjectRef, typename>
inline bool MXNetPODValue_::IsObjectRef() const {
  using ContainerType = typename TObjectRef::ContainerType;
  return type_code_ == kObjectHandle &&
         ObjectTypeChecker<TObjectRef>::Check(static_cast<Object*>(value_.v_handle));
}

inline bool String::CanConvertFrom(const MXNetArgValue& val) {
  return val.type_code() == kStr || val.IsObjectRef<mxnet::runtime::String>();
}

}  // namespace runtime
}  // namespace mxnet
#endif  // MXNET_RUNTIME_PACKED_FUNC_H_


text:
namespace BookingApp.Migrations
{
    using System.CodeDom.Compiler;
    using System.Data.Entity.Migrations;
    using System.Data.Entity.Migrations.Infrastructure;
    using System.Resources;

    [GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")]
    public sealed partial class UpdatedClasses : IMigrationMetadata
    {
        private readonly ResourceManager Resources = new ResourceManager(typeof(UpdatedClasses));

        string IMigrationMetadata.Id
        {
            get { return "201706060838400_UpdatedClasses"; }
        }

        string IMigrationMetadata.Source
        {
            get { return null; }
        }

        string IMigrationMetadata.Target
        {
            get { return Resources.GetString("Target"); }
        }
    }
}


text:
package com.eju.ess;

import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class HttpClientPool {
	private final static int MAX_PERROUTE = 500;
	private final static int MAX_TOTAL = 500;

	public static CloseableHttpClient getHttpClient() {
		PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
		cm.setMaxTotal(MAX_TOTAL);
		cm.setDefaultMaxPerRoute(MAX_PERROUTE);
		CloseableHttpClient httpClient = HttpClients
				.custom()
				.setConnectionManager(cm)
				.build();
		return httpClient;
	}
}


text:
'use strict';

const common = require('../common');

// The following tests validate base functionality for the fs.promises
// FileHandle.read method.

const fs = require('fs');
const { open } = fs.promises;
const path = require('path');
const tmpdir = require('../common/tmpdir');
const assert = require('assert');
const tmpDir = tmpdir.path;

tmpdir.refresh();
common.crashOnUnhandledRejection();

async function validateWrite() {
  const filePathForHandle = path.resolve(tmpDir, 'tmp-write.txt');
  const fileHandle = await open(filePathForHandle, 'w+');
  const buffer = Buffer.from('Hello world'.repeat(100), 'utf8');

  await fileHandle.write(buffer, 0, buffer.length);
  const readFileData = fs.readFileSync(filePathForHandle);
  assert.deepStrictEqual(buffer, readFileData);
}

async function validateEmptyWrite() {
  const filePathForHandle = path.resolve(tmpDir, 'tmp-empty-write.txt');
  const fileHandle = await open(filePathForHandle, 'w+');
  const buffer = Buffer.from(''); // empty buffer

  await fileHandle.write(buffer, 0, buffer.length);
  const readFileData = fs.readFileSync(filePathForHandle);
  assert.deepStrictEqual(buffer, readFileData);
}

async function validateNonUint8ArrayWrite() {
  const filePathForHandle = path.resolve(tmpDir, 'tmp-data-write.txt');
  const fileHandle = await open(filePathForHandle, 'w+');
  const buffer = Buffer.from('Hello world', 'utf8').toString('base64');

  await fileHandle.write(buffer, 0, buffer.length);
  const readFileData = fs.readFileSync(filePathForHandle);
  assert.deepStrictEqual(Buffer.from(buffer, 'utf8'), readFileData);
}

Promise.all([
  validateWrite(),
  validateEmptyWrite(),
  validateNonUint8ArrayWrite()
]).then(common.mustCall());