cpp

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestCodeAplusb = `#include<iostream>
using namespace std;
int main() {
	int a,b;
	cin>>a>>b;
	cout<<a+b<<"\n";
}`
	TestCodeCompileError = `#include<lol>
lmao;
int main(a,b,c);
`
	TestCodeHelloWorld = `#include<iostream>
using namespace std;
int main() {
	cout<<"Hello world";
	return 0;
}`
	TestCodeTimeLimit = `#include<iostream>
using namespace std;
int main() {
	int n=0;
	while(1) n++; 
}`
	TestCodeRuntimeError = `` /* 130-byte string literal not displayed */

	TestCodeRuntimeErrorDiv0 = `#include<iostream>
using namespace std;
int main() {
	cerr<<(1/0);
}`
	TestCodeLongSleep = `#include<unistd.h>
int main() {
	sleep(20);
}
`
	TestCodeShortSleep = `#include<unistd.h>
int main() {
	usleep(100);
}
`
)

Variables

View Source
var DefaultCompileArgs = []string{"-O2", "-static", "-DONLINE_JUDGE"}
View Source
var Std11 = New("cpp11", "C++ 11", WithCompileArgs(append(DefaultCompileArgs, "-std=c++11")))
View Source
var Std14 = New("cpp14", "C++ 14", WithCompileArgs(append(DefaultCompileArgs, "-std=c++14")))
View Source
var Std17 = New("cpp17", "C++ 17", WithCompileArgs(append(DefaultCompileArgs, "-std=c++17")))

Functions

func AutoCompile

func AutoCompile(ctx context.Context, fs afero.Fs, s sandbox.Sandbox, workDir, src, dst string) error

func ExtractHeaderNames

func ExtractHeaderNames(fs afero.Fs, dir string, src []byte) []string

Types

type Cpp

type Cpp struct {
	// contains filtered or unexported fields
}

func New

func New(ID, name string, opts ...Option) *Cpp

func (Cpp) Compile

func (c Cpp) Compile(ctx context.Context, s sandbox.Sandbox, f sandbox.File, stderr io.Writer, extras []sandbox.File) (*sandbox.File, error)

func (Cpp) DefaultFilename added in v0.4.0

func (c Cpp) DefaultFilename() string

func (Cpp) DisplayName added in v0.4.0

func (c Cpp) DisplayName() string

func (Cpp) ID added in v0.4.0

func (c Cpp) ID() string

func (Cpp) Run

func (Cpp) Run(ctx context.Context, s sandbox.Sandbox, binary sandbox.File, stdin io.Reader, stdout io.Writer, tl time.Duration, ml memory.Amount) (*sandbox.Status, error)

func (Cpp) Test

func (c Cpp) Test(t *testing.T, s sandbox.Sandbox) error

type Option added in v0.4.0

type Option func(*Cpp)

func WithCompileArgs added in v0.4.0

func WithCompileArgs(args []string) Option

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL