本文整理汇总了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
}
示例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])
}
}
示例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)
}
}