本文整理汇总了C++中One类的典型用法代码示例。如果您正苦于以下问题:C++ One类的具体用法?C++ One怎么用?C++ One使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了One类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Exclamation
void MapEditor::OnLevelMapCalc(Level& level, int number)
{
if (level.GetMapBG().IsEmpty())
{
Exclamation(NFormat(t_("Please, select the image for level: %s"), level.GetName()));
return;
}
String fp = AppendFileName( AppendFileName( GetFileDirectory(GetExeFilePath()), "Maps"),
level.GetMapBG());
if (!FileExists(fp))
{
Exclamation(NFormat(t_("Image file not exist: %s"), fp));
return;
}
String name = level.GetName();
double zx = level.GetZoomDX();
Size pz = level.GetPageSize();
Size sz = level.GetCellSize();
FileIn in(fp);
One<StreamRaster> r = StreamRaster::OpenAny(in);
if (!r)
{
Exclamation(NFormat(t_("Error while loading image file: %s"), fp));
return;
}
Image img = r->GetImage();
Calculate(sz.cx, sz.cy, pz.cx, pz.cy, zx,
NFormat("%s-%d", _map.GetName(), number + 1), img);
}
示例2: GetPackageIndex
void Ide::Preprocess(bool asmout) {
if(editfile.IsEmpty())
return;
int pi = GetPackageIndex();
if(pi < 0) return;
SwitchHeader();
String pfn = ConfigFile(GetFileTitle(editfile) + ".i.tmp");
DeleteFile(pfn);
const Workspace& wspc = IdeWorkspace();
if(pi >= wspc.GetCount())
return;
One<Host> host = CreateHost(true);
One<Builder> b = CreateBuilder(~host);
Vector<String> linkfile;
String linkopt;
b->config = PackageConfig(wspc, pi, GetMethodVars(method), mainconfigparam, *host, *b);
console.Clear();
PutConsole((asmout ? "Compiling " : "Preprocessing ") + editfile);
b->Preprocess(wspc[pi], editfile, pfn, asmout);
HideBottom();
if(FileExists(pfn)) {
EditFile(pfn);
if(!editor.IsReadOnly())
ToggleReadOnly();
}
}
示例3: BeginNative
void Draw::DrawDataOp(int x, int y, int cx, int cy, const String& data, const char *id)
{
bool tonative = !IsNative();
if(tonative) {
BeginNative();
Native(x, y);
Native(cx, cy);
}
One<DataDrawer> dd = DataDrawer::Create(id);
if(dd) {
dd->Open(data, cx, cy);
if((cx > 2048 || cy > 2048) && (GetInfo() & DATABANDS)) {
int yy = 0;
while(yy < cy) {
int ccy = min(cy - yy, 32);
ImageBuffer ib(cx, ccy);
dd->Render(ib);
DrawImageBandRLE(*this, x, y + yy, ib, 16);
yy += ccy;
}
}
else {
ImageBuffer m(cx, cy);
dd->Render(m);
DrawImage(x, y, m);
}
}
if(tonative)
EndNative();
}
示例4: run_main
int run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("Intrusive_Auto_Ptr_Test"));
One *theone (new One(0));
{
ACE_TEST_ASSERT (theone->has_refs (0));
ACE_TEST_ASSERT (!One::was_released ());
ACE_Intrusive_Auto_Ptr<One> ip2(theone);
{
ACE_TEST_ASSERT (theone->has_refs (1));
ACE_TEST_ASSERT (!One::was_released ());
ACE_Intrusive_Auto_Ptr<One> ip2(theone);
ACE_TEST_ASSERT (theone->has_refs (2));
ACE_TEST_ASSERT (!One::was_released ());
}
ACE_TEST_ASSERT (theone->has_refs (1));
ACE_TEST_ASSERT (!One::was_released ());
}
ACE_TEST_ASSERT (One::was_released());
ACE_END_TEST;
return 0;
}
示例5: PdbCreate
One<Debugger> PdbCreate(One<Host> host, const String& exefile, const String& cmdline)
{
One<Debugger> dbg;
if(!dbg.Create<Pdb>().Create(host, exefile, cmdline))
dbg.Clear();
return dbg;
}
示例6: ss
Size RichRawImage::GetPixelSize(const Value& data) const
{
String s = data;
StringStream ss(s);
One<StreamRaster> r = StreamRaster::OpenAny(ss);
if(r)
return r->GetSize();
return Size(0, 0);
}
示例7: CreateHost
One<Host> Ide::CreateHostRunDir()
{
One<Host> h = CreateHost(false);
if(IsNull(rundir))
h->ChDir(GetFileFolder(target));
else
h->ChDir(rundir);
return h;
}
示例8: GetMethodVars
void Ide::BuildAndDebug(bool runto)
{
VectorMap<String, String> bm = GetMethodVars(method);
String builder = bm.Get("BUILDER", "");
if(!Build())
return;
if(!FileExists(target))
return;
if(designer)
EditAsText();
One<Host> host = CreateHostRunDir();
host->ChDir(Nvl(rundir, GetFileFolder(target)));
HideBottom();
editor.Disable();
#ifdef COMPILER_MSC
if(builder == "GCC")
if(gdbSelector)
debugger = Gdb_MI2Create(host, target, runarg);
else
debugger = GdbCreate(host, target, runarg);
else
debugger = PdbCreate(host, target, runarg);
#else
if(gdbSelector)
debugger = Gdb_MI2Create(host, target, runarg);
else
debugger = GdbCreate(host, target, runarg);
#endif
if(!debugger) return;
debuglock = 0;
const Workspace& wspc = IdeWorkspace();
for(int i = 0; i < wspc.GetCount(); i++) {
const Package& pk = wspc.GetPackage(i);
String n = wspc[i];
for(int i = 0; i < pk.file.GetCount(); i++) {
String file = SourcePath(n, pk.file[i]);
LineInfo& ln = Filedata(file).lineinfo;
for(int i = 0; i < ln.GetCount(); i++) {
LineInfoRecord& lr = ln[i];
if(!lr.breakpoint.IsEmpty())
if(!debugger->SetBreakpoint(file, lr.lineno, lr.breakpoint)) {
lr.breakpoint = "\xe";
if(PathIsEqual(file, editfile))
editor.SetBreakpoint(lr.lineno, "\xe");
}
}
}
}
SetBar();
editor.Enable();
if(runto) {
if(!debugger->RunTo())
IdeEndDebug();
}
else
debugger->Run();
}
示例9: AcceptRaw
bool Socket::Data::Accept(Socket& socket, dword *ipaddr, bool nodelay, int timeout_msec)
{
SOCKET connection = AcceptRaw(ipaddr, timeout_msec);
if(connection == INVALID_SOCKET)
return false;
One<Socket::Data> data = new Data;
data->Attach(connection, nodelay, is_blocking);
socket.Attach(data);
return true;
}
示例10: OptimizeConst
void Compiler::OptimizeConst(One<Exe>& exe)
{
One<Exe> oxe;
Vector<Value> stack;
ExeContext x(stack);
oxe.Create<ExeConst>().value = exe->Eval(x);
LLOG("OPTIMIZED constant: " << exe->Eval(stack, out));
exe = pick(oxe);
optimized = true;
}
示例11: PutConsole
void MakeBuild::CleanPackage(const Workspace& wspc, int package)
{
PutConsole(NFormat("Cleaning %s", wspc[package]));
One<Host> host = CreateHost(false);
One<Builder> builder = CreateBuilder(~host);
if(!builder)
return;
host->DeleteFolderDeep(OutDir(PackageConfig(wspc, package, GetMethodVars(method), mainconfigparam,
*host, *builder), wspc[package], GetMethodVars(method)));
}
示例12: Create
bool Pdb::Create(One<Host> local, const String& exefile, const String& cmdline)
{
STARTUPINFO si;
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = 0;
String cl;
if(exefile.Find(' ') >= 0)
cl << '\"' << exefile << '\"';
else
cl << exefile;
if(!IsNull(cmdline))
cl << ' ' << cmdline;
Buffer<char> cmd(cl.GetLength() + 1);
memcpy(cmd, cl, cl.GetLength() + 1);
PROCESS_INFORMATION pi;
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
Buffer<char> env(local->GetEnvironment().GetCount() + 1);
memcpy(env, ~local->GetEnvironment(), local->GetEnvironment().GetCount() + 1);
bool h = CreateProcess(exefile, cmd, NULL, NULL, TRUE,
NORMAL_PRIORITY_CLASS|CREATE_NEW_CONSOLE|DEBUG_ONLY_THIS_PROCESS|DEBUG_PROCESS,
~env, NULL, &si, &pi);
if(!h) {
Exclamation("Error creating process&[* " + DeQtf(exefile) + "]&" +
"Windows error: " + DeQtf(GetLastErrorMessage()));
return false;
}
hProcess = pi.hProcess;
CloseHandle(pi.hThread);
IdeSetBottom(*this);
IdeSetRight(disas);
LoadFromGlobal(*this, CONFIGNAME);
if(!SymInitialize(hProcess, 0, FALSE)) {
Error();
return false;
}
SymSetOptions(SYMOPT_LOAD_LINES|SYMOPT_UNDNAME|SYMOPT_NO_UNQUALIFIED_LOADS);
lock = 0;
stop = false;
refreshmodules = true;
terminated = false;
running = true;
RunToException();
// Sync();
return true;
}
示例13: CreateHostRunDir
void Ide::BuildAndDebug0(const String& srcfile)
{
if(Build()) {
One<Host> h = CreateHostRunDir();
h->ChDir(GetFileFolder(target));
VectorMap<String, String> bm = GetMethodVars(method);
String dbg = bm.Get("DEBUGGER", Null);
if(IsNull(dbg)) {
if(bm.Get("BUILDER", Null) == "MSC71") {
String sln = ForceExt(target, ".sln");
if(GetFileLength(sln) > 0)
h->Launch("devenv \"" + h->GetHostPath(sln) + "\" "
// + "\"" + h->GetHostPath(srcfile) + "\"" //TRC, 2011/09/26: wrong devenv argument
);
else
h->Launch("devenv \"" + h->GetHostPath(target)
//+ "\" \"" + h->GetHostPath(srcfile) //TRC, 2011/09/26: wrong devenv argument
+ "\" /debugexe "
);
return;
}
dbg = "gdb";
}
else
h->Launch('\"' + dbg + "\" \""
// + h->GetHostPath(srcfile) + ' '
+ h->GetHostPath(target) + "\"", true);
}
}
示例14: Render
String Render(const One<Exe>& exe, Renderer *r, Vector<Value>& var)
{
LTIMING("Render0");
ExeContext x(var, r);
Value v = exe->Eval(x);
x.out.Cat(AsString(v));
return x.out;
}
示例15: Bitmap
void ImageMT::LoadImage()
{
FileSel dlg;
dlg.Type("Image files","*.bmp *.png *.tif *.jpg");
dlg.Type("Image: JPEG","*.jpg");
dlg.Type("Image: Portable Nework Graphics","*.png");
dlg.Type("Image: Tagged Image Format","*.tif");
dlg.Type("Image: Windows Bitmap (24bit)","*.bmp");
dlg.ActiveDir(GetCurrentDirectory());
if(!dlg.ExecuteOpen("Open Image"))return;
SetCurrentDirectory(dlg.GetActiveDir());
String path = ~dlg;
FileIn in(path);
if(in.IsError())
{
String s = Format("Error opening image file %s",path);
PromptOK(s);
return;
}
One<StreamRaster> r = StreamRaster::OpenAny(in);
if(!r)
{
String s = Format("Error opening streamraster file %s",path);
PromptOK(s);
return;
}
Layer* pLayer = new Layer;
Size sz = GetSize();
pLayer->m_img = r->GetImage();
pLayer->m_rc.left = 0;
pLayer->m_rc.right = 1;
pLayer->m_rc.top = 0;
pLayer->m_rc.bottom = 1;
m_pLayers.Add(pLayer);
}