當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。