Ejemplo n.º 1
0
Symbol readSymbol(Reader &Data, llvm::ArrayRef<llvm::StringRef> Strings) {
  Symbol Sym;
  Sym.ID = Data.consumeID();
  Sym.SymInfo.Kind = static_cast<index::SymbolKind>(Data.consume8());
  Sym.SymInfo.Lang = static_cast<index::SymbolLanguage>(Data.consume8());
  Sym.Name = Data.consumeString(Strings);
  Sym.Scope = Data.consumeString(Strings);
  Sym.TemplateSpecializationArgs = Data.consumeString(Strings);
  Sym.Definition = readLocation(Data, Strings);
  Sym.CanonicalDeclaration = readLocation(Data, Strings);
  Sym.References = Data.consumeVar();
  Sym.Flags = static_cast<Symbol::SymbolFlag>(Data.consumeVar());
  Sym.Origin = static_cast<SymbolOrigin>(Data.consumeVar());
  Sym.Signature = Data.consumeString(Strings);
  Sym.CompletionSnippetSuffix = Data.consumeString(Strings);
  Sym.Documentation = Data.consumeString(Strings);
  Sym.ReturnType = Data.consumeString(Strings);
  Sym.Type = Data.consumeString(Strings);
  Sym.IncludeHeaders.resize(Data.consumeVar());
  for (auto &I : Sym.IncludeHeaders) {
    I.IncludeHeader = Data.consumeString(Strings);
    I.References = Data.consumeVar();
  }
  return Sym;
}
int M2XStreamClient::readLocation(const char* feedId,
                                  location_read_callback callback,
                                  void* context) {
  if (_client->connect(_host, _port)) {
#ifdef DEBUG
    printf("Connected to M2X server!\n");
#endif
    _client->print("GET /v1/feeds/");
    print_encoded_string(_client, feedId);
    _client->println("/location HTTP/1.0");

    writeHttpHeader(-1);
  } else {
#ifdef DEBUG
    printf("ERROR: Cannot connect to M2X server!\n");
#endif
    return E_NOCONNECTION;
  }
  int status = readStatusCode(false);
  if (status == 200) {
    readLocation(callback, context);
  }

  close();
  return status;
}
Ejemplo n.º 3
0
 FrameInfo* getFrameInfo() {
     if (id.type == PythonFrameId::COMPILED) {
         CompiledFunction* cf = getCF();
         assert(cf->location_map->frameInfoFound());
         const auto& frame_info_loc = cf->location_map->frame_info_location;
         return *reinterpret_cast<FrameInfo**>(readLocation(frame_info_loc));
     } else if (id.type == PythonFrameId::INTERPRETED) {
         return getFrameInfoForInterpretedFrame((void*)id.bp);
     }
     abort();
 }
Ejemplo n.º 4
0
std::pair<SymbolID, std::vector<Ref>>
readRefs(Reader &Data, llvm::ArrayRef<llvm::StringRef> Strings) {
  std::pair<SymbolID, std::vector<Ref>> Result;
  Result.first = Data.consumeID();
  Result.second.resize(Data.consumeVar());
  for (auto &Ref : Result.second) {
    Ref.Kind = static_cast<RefKind>(Data.consume8());
    Ref.Location = readLocation(Data, Strings);
  }
  return Result;
}
bool WeatherDataModel::loadEpw(QString filename)
{
    int lineNumber=0;
    QFile fp(filename);
    if(!fp.open(QFile::ReadOnly))
    {
        LOG(error) << "WeatherDataModel: Failed to open file '" << filename.toStdString() << "'";
        return false;
    }
    LOG(info) << "WeatherDataModel: Opening file '" << filename.toStdString() << "'";
    QTextStream stream(&fp);
    QString line = stream.readLine();
    lineNumber++;
    if(!readLocation(line)) {
        return false;
    }
    //std::cout << line.toStdString() << std::endl;
    line = stream.readLine();
    lineNumber++;
    //std::cout << line.toStdString() << std::endl;
    line = stream.readLine();
    lineNumber++;
    //std::cout << line.toStdString() << std::endl;
    line = stream.readLine();
    lineNumber++;
    //std::cout << line.toStdString() << std::endl;
    line = stream.readLine();
    lineNumber++;
    //std::cout << line.toStdString() << std::endl;
    line = stream.readLine();
    lineNumber++;
    //std::cout << line.toStdString() << std::endl;
    line = stream.readLine();
    lineNumber++;
    //std::cout << line.toStdString() << std::endl;
    line = stream.readLine();
    lineNumber++;
    if(!readDataPeriods(line)) {
        LOG(error) << "WeatherDataModel: Failed to read data periods";
        return false;
    }
    LOG(info) << "Read " << m_dataPeriods.size() << " data period(s)";
    for(int i=0;i<m_dataPeriods.size();i++) {
        LOG(info) << "Period " << i+1 <<" : (" << m_dataPeriods[i].name() << ","
                  << m_dataPeriods[i].dayOfWeek() << "," << m_dataPeriods[i].startMonth()
                  << "/" <<  m_dataPeriods[i].startDay() << "," << m_dataPeriods[i].endMonth()
                  << "/" <<  m_dataPeriods[i].endDay() << ")";
    }
    //std::cout << line.toStdString() << std::endl;
    line = stream.readLine();

    beginResetModel();
    m_data.clear();
    int currentMinute = 0;
    while(!line.isNull()){
        lineNumber++;
        boost::optional<WeatherDataPoint> point = WeatherDataPoint::fromEpwString(line.toStdString());
        if(!point) {
            LOG(error) << "Failed to read input line " << lineNumber;
            endResetModel();
            return false;
        }
        if(m_recordsPerHour > 1) {
            point->setMinute(currentMinute);
            currentMinute += m_minutesBetweenRecords;
            if(currentMinute == 60) {
                currentMinute = 0;
            }
        }
        m_data << point.get();
        line = stream.readLine();
    }
    endResetModel();
    // Need to do checks or something
    //QModelIndex topLeft = index(0, 0);
    //QModelIndex bottomRight = index(rowCount() - 1, columnCount() - 1);
    //emit dataChanged(topLeft, bottomRight);

    return true;
}