本文整理匯總了Golang中github.com/lanior/upc/formats.ProblemArchiveReader.ReadFile方法的典型用法代碼示例。如果您正苦於以下問題:Golang ProblemArchiveReader.ReadFile方法的具體用法?Golang ProblemArchiveReader.ReadFile怎麽用?Golang ProblemArchiveReader.ReadFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lanior/upc/formats.ProblemArchiveReader
的用法示例。
在下文中一共展示了ProblemArchiveReader.ReadFile方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ImportArchive
func (self Format) ImportArchive(archive *formats.ProblemArchiveReader) (problems []*model.Problem, err error) {
defer SuppressPanic(&err)
data, err := archive.ReadFile("domjudge-problem.ini")
PanicIf(err, "Cannot read problem settings: %s", err)
settings := ParseSettings(data)
p := &model.Problem{
Title: settings["name"],
TimeLimit: float32(settings.GetInt("timelimit")),
MemoryLimit: 128,
Solutions: make(map[string]*model.Solution),
}
PanicIf(archive.LoadTests(p, "(.*).in$", "(.*).out$"))
PanicIf(archive.LoadSolutions(p, "sol_(.*)"))
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)
}
}