当前位置: 首页>>代码示例>>C++>>正文


C++ gc::cString方法代码示例

本文整理汇总了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);
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:11,代码来源:IO.cpp

示例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>());
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:14,代码来源:Compiler.cpp

示例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;
  }
开发者ID:relrod,项目名称:magpie,代码行数:22,代码来源:Resolver.cpp

示例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());
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:24,代码来源:Environment_mac.cpp

示例5: add

 void SignatureBuilder::add(gc<String> text)
 {
   add(text->cString());
 }
开发者ID:DawidvC,项目名称:magpie,代码行数:4,代码来源:Compiler.cpp

示例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());
 }
开发者ID:DawidvC,项目名称:magpie,代码行数:5,代码来源:Path.cpp

示例7: fileExists

 bool fileExists(gc<String> path)
 {
   // If we can stat it, it exists.
   struct stat dummy;
   return stat(path->cString(), &dummy) == 0;
 }
开发者ID:joshuawarner32,项目名称:magpie,代码行数:6,代码来源:Path_posix.cpp

示例8: create

 gc<String> real(gc<String> path)
 {
   char absolute[PATH_MAX];
   realpath(path->cString(), absolute);
   return String::create(absolute);
 }
开发者ID:joshuawarner32,项目名称:magpie,代码行数:6,代码来源:Path_posix.cpp


注:本文中的gc::cString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。