本文整理汇总了C++中gc::cString方法的典型用法代码示例。如果您正苦于以下问题:C++ gc::cString方法的具体用法?C++ gc::cString怎么用?C++ gc::cString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gc
的用法示例。
在下文中一共展示了gc::cString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open
void FileObject::open(gc<Fiber> fiber, gc<String> path)
{
FSTask* task = new FSTask(fiber);
// TODO(bob): Make this configurable.
int flags = O_RDONLY;
// TODO(bob): Make this configurable when creating a file.
int mode = 0;
uv_fs_open(task->loop(), task->request(), path->cString(), flags, mode,
openFileCallback);
}
示例2: declareVariable
void Compiler::declareVariable(gc<SourcePos> pos, gc<String> name,
Module* module)
{
// Make sure there isn't already a top-level variable with that name.
int existing = module->findVariable(name);
if (existing != -1)
{
reporter_.error(pos,
"There is already a variable '%s' defined in this module.",
name->cString());
}
module->addVariable(name, gc<Object>());
}
示例3: ResolvedName
gc<ResolvedName> Resolver::makeLocal(gc<SourcePos> pos, gc<String> name)
{
// Make sure there isn't already a local variable with this name in the
// current scope.
for (int i = scope_->startSlot(); i < locals_.count(); i++)
{
if (locals_[i].name() == name)
{
compiler_.reporter().error(pos,
"There is already a variable '%s' defined in this scope.",
name->cString());
}
}
gc<ResolvedName> resolved = new ResolvedName(locals_.count());
locals_.add(Local(name, resolved));
if (locals_.count() > maxLocals_) {
maxLocals_ = locals_.count();
}
return resolved;
}
示例4: stream
// Reads a file from the given path into a String.
gc<String> readFile(gc<String> path)
{
// TODO(bob): Use platform-native API for this?
using namespace std;
ifstream stream(path->cString());
if (stream.fail()) return gc<String>();
// From: http://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring.
string str;
// Allocate a std::string big enough for the file.
stream.seekg(0, ios::end);
str.reserve(stream.tellg());
stream.seekg(0, ios::beg);
// Read it in.
str.assign((istreambuf_iterator<char>(stream)),
istreambuf_iterator<char>());
return String::create(str.c_str());
}
示例5: add
void SignatureBuilder::add(gc<String> text)
{
add(text->cString());
}
示例6: format
gc<String> join(gc<String> a, gc<String> b)
{
// TODO(bob): Handle lots of edge cases better here.
return String::format("%s%c%s", a->cString(), separator(), b->cString());
}
示例7: fileExists
bool fileExists(gc<String> path)
{
// If we can stat it, it exists.
struct stat dummy;
return stat(path->cString(), &dummy) == 0;
}
示例8: create
gc<String> real(gc<String> path)
{
char absolute[PATH_MAX];
realpath(path->cString(), absolute);
return String::create(absolute);
}