当前位置: 首页>>代码示例>>Golang>>正文


Golang formats.ProblemArchiveReader类代码示例

本文整理汇总了Golang中github.com/lanior/upc/formats.ProblemArchiveReader的典型用法代码示例。如果您正苦于以下问题:Golang ProblemArchiveReader类的具体用法?Golang ProblemArchiveReader怎么用?Golang ProblemArchiveReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ProblemArchiveReader类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ImportArchive

func (self Format) ImportArchive(archive *formats.ProblemArchiveReader) (problems []*model.Problem, err error) {
	defer SuppressPanic(&err)

	p := &model.Problem{
		Solutions: make(map[string]*model.Solution),
	}
	PanicIf(archive.LoadTests(p, "in/(.*).in$", "out/(.*).out$"))
	PanicIf(archive.LoadSolutions(p, "prog/(.*)"))
	return []*model.Problem{p}, nil
}
开发者ID:lanior,项目名称:upc,代码行数:10,代码来源:import.go

示例2: importStatement

func importStatement(archive *formats.ProblemArchiveReader, problem *model.Problem, statement *Statement) {
	data, err := archive.ReadFile(statement.Path)
	PanicIf(err, "Cannot read statement %s: %s", statement.Path, err)

	getTeX := func(src []byte) model.FormattedText {
		return model.RawText(src)
	}

	if match := statementRe.FindSubmatch(data); match != nil {
		problem.Statement = getTeX(match[1])
		problem.InputFormat = getTeX(match[2])
		problem.OutputFormat = getTeX(match[3])
	}

	matches := exampleRe.FindAllSubmatch(data, -1)
	problem.Samples = make([]model.Sample, len(matches))
	for i, match := range matches {
		problem.Samples[i].Input = string(match[1])
		problem.Samples[i].Output = string(match[2])
	}
}
开发者ID:lanior,项目名称:upc,代码行数:21,代码来源:import.go

示例3: addGenerator

func addGenerator(archive *formats.ProblemArchiveReader, problem *model.Problem, generator *Generator) {
	gen := problem.Generators[generator.Name]
	if gen == nil {
		gen = new(model.Generator)
		problem.Generators[generator.Name] = gen
	}
	gen.Name = generator.Name
	if generator.OutputFile != "" {
		gen.OutputFile = generator.OutputFile
	}

	if generator.LanguageCode != 0 || generator.Source != "" {
		lang := getLanguage(generator.LanguageCode, generator.Source)
		PanicIf(lang == nil, "Unknown generator language")
		gen.Language = lang.Name
	}

	if generator.Source != "" {
		data, err := archive.ReadFile(generator.Source)
		PanicIf(err)
		gen.SourceCode = string(data)
	}
}
开发者ID:lanior,项目名称:upc,代码行数:23,代码来源:import.go


注:本文中的github.com/lanior/upc/formats.ProblemArchiveReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。