Exemplo n.º 1
0
void OsmAnd::RoutingConfiguration::loadDefault( RoutingConfiguration& outConfig )
{
    auto rawDefaultConfig = EmbeddedResources::decompressResource("routing.xml");
    QBuffer defaultConfig(&rawDefaultConfig);
    bool ok = false;
    ok = defaultConfig.open(QIODevice::ReadOnly | QIODevice::Text);
    assert(ok);
    ok = parseConfiguration(&defaultConfig, outConfig);
    assert(ok);
    defaultConfig.close();
}
Exemplo n.º 2
0
TEST(ParseConfiguration, ValidConfiguration) {
  llvm::ErrorOr<ClangTidyOptions> Options =
      parseConfiguration("Checks: \"-*,misc-*\"\n"
                         "HeaderFilterRegex: \".*\"\n"
                         "AnalyzeTemporaryDtors: true\n"
                         "User: some.user");
  EXPECT_TRUE(!!Options);
  EXPECT_EQ("-*,misc-*", *Options->Checks);
  EXPECT_EQ(".*", *Options->HeaderFilterRegex);
  EXPECT_TRUE(*Options->AnalyzeTemporaryDtors);
  EXPECT_EQ("some.user", *Options->User);
}
Exemplo n.º 3
0
PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext& context, const Dictionary& rtcConfiguration, ExceptionCode& ec)
{
    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
    if (ec)
        return nullptr;

    RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(context, configuration.release(), ec));
    peerConnection->suspendIfNeeded();
    if (ec)
        return nullptr;

    return peerConnection.release();
}
Exemplo n.º 4
0
void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, ExceptionCode& ec)
{
    if (m_signalingState == SignalingStateClosed) {
        ec = INVALID_STATE_ERR;
        return;
    }

    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
    if (ec)
        return;

    bool valid = m_peerHandler->updateIce(configuration);
    if (!valid)
        ec = SYNTAX_ERR;
}
Exemplo n.º 5
0
PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ScriptExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode& ec)
{
    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
    if (ec)
        return 0;

    RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaConstraints, ec);
    if (ec)
        return 0;

    RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(context, configuration.release(), constraints.release(), ec));
    peerConnection->suspendIfNeeded();
    if (ec)
        return 0;

    return peerConnection.release();
}
Exemplo n.º 6
0
void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
{
    if (throwExceptionIfSignalingStateClosed(m_signalingState, exceptionState))
        return;

    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, exceptionState);
    if (exceptionState.hadException())
        return;

    blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstraints, exceptionState);
    if (exceptionState.hadException())
        return;

    bool valid = m_peerHandler->updateICE(configuration.release(), constraints);
    if (!valid)
        exceptionState.throwDOMException(SyntaxError, "Could not update the ICE Agent with the given configuration.");
}
Exemplo n.º 7
0
PassRefPtr<RTCPeerConnection> RTCPeerConnection::create(ExecutionContext* context, const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState& exceptionState)
{
    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, exceptionState);
    if (exceptionState.hadException())
        return nullptr;

    blink::WebMediaConstraints constraints = MediaConstraintsImpl::create(mediaConstraints, exceptionState);
    if (exceptionState.hadException())
        return nullptr;

    RefPtr<RTCPeerConnection> peerConnection = adoptRef(new RTCPeerConnection(context, configuration.release(), constraints, exceptionState));
    peerConnection->suspendIfNeeded();
    if (exceptionState.hadException())
        return nullptr;

    return peerConnection.release();
}
Exemplo n.º 8
0
static std::unique_ptr<ClangTidyOptionsProvider> createOptionsProvider() {
  ClangTidyGlobalOptions GlobalOptions;
  if (std::error_code Err = parseLineFilter(LineFilter, GlobalOptions)) {
    llvm::errs() << "Invalid LineFilter: " << Err.message() << "\n\nUsage:\n";
    llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true);
    return nullptr;
  }

  ClangTidyOptions DefaultOptions;
  DefaultOptions.Checks = DefaultChecks;
  DefaultOptions.HeaderFilterRegex = HeaderFilter;
  DefaultOptions.SystemHeaders = SystemHeaders;
  DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
  DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
  // USERNAME is used on Windows.
  if (!DefaultOptions.User)
    DefaultOptions.User = llvm::sys::Process::GetEnv("USERNAME");

  ClangTidyOptions OverrideOptions;
  if (Checks.getNumOccurrences() > 0)
    OverrideOptions.Checks = Checks;
  if (HeaderFilter.getNumOccurrences() > 0)
    OverrideOptions.HeaderFilterRegex = HeaderFilter;
  if (SystemHeaders.getNumOccurrences() > 0)
    OverrideOptions.SystemHeaders = SystemHeaders;
  if (AnalyzeTemporaryDtors.getNumOccurrences() > 0)
    OverrideOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;

  if (!Config.empty()) {
    if (llvm::ErrorOr<ClangTidyOptions> ParsedConfig =
            parseConfiguration(Config)) {
      return llvm::make_unique<DefaultOptionsProvider>(
          GlobalOptions, ClangTidyOptions::getDefaults()
                             .mergeWith(DefaultOptions)
                             .mergeWith(*ParsedConfig)
                             .mergeWith(OverrideOptions));
    } else {
      llvm::errs() << "Error: invalid configuration specified.\n"
                   << ParsedConfig.getError().message() << "\n";
      return nullptr;
    }
  }
  return llvm::make_unique<FileOptionsProvider>(GlobalOptions, DefaultOptions,
                                                OverrideOptions);
}
Exemplo n.º 9
0
void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionCode& ec)
{
    if (m_readyState == ReadyStateClosing || m_readyState == ReadyStateClosed) {
        ec = INVALID_STATE_ERR;
        return;
    }

    RefPtr<RTCConfiguration> configuration = parseConfiguration(rtcConfiguration, ec);
    if (ec)
        return;

    RefPtr<MediaConstraints> constraints = MediaConstraintsImpl::create(mediaConstraints, ec);
    if (ec)
        return;

    bool valid = m_peerHandler->updateIce(configuration, constraints);
    if (!valid)
        ec = SYNTAX_ERR;
}
Exemplo n.º 10
0
/**
 * Initialises the library
 *
 */
void iotkit_init() {
    int store_path_length = 0;
    char *config_file_path = NULL;
    char *config_dir_path = NULL;

    if(isFileExists(CONFIGURATION_FILE_NAME)) {
        store_path_length = strlen(CURRENT_DIR) + strlen(CONFIGURATION_FILE_NAME) + 2;
        config_file_path = (char *)malloc(sizeof(char) * store_path_length);
        strcpy(config_file_path, CURRENT_DIR);
    } else {
        store_path_length = strlen(DEFAULT_CONFIG_DIR) + strlen(CONFIGURATION_FILE_NAME) + 2;
        config_file_path = (char *)malloc(sizeof(char) * store_path_length);
        strcpy(config_file_path, DEFAULT_CONFIG_DIR);
    }

    strcat(config_file_path, CONFIGURATION_FILE_NAME);

    parseConfiguration(config_file_path);
    parseAuthorizationToken();
    parseDeviceToken();
    parseComponentsList();

    if(!isInitialized) {
        CURLcode code = rest_init(configurations.isSecure);
        if(code) {
            fprintf(stderr, "Unable to initialize CURL %d\n", code);
        } else {
            isInitialized = true;
            #if DEBUG
                puts("Library initialized successfully");
            #endif
        }
    } else {
        #if DEBUG
            puts("Library is already initialized and doesn't need to be re-initialized");
        #endif
    }
}
Exemplo n.º 11
0
FormatStyle getStyle(StringRef StyleName, StringRef FileName) {
  FormatStyle Style;
  getPredefinedStyle(FallbackStyle, &Style);

  if (StyleName.startswith("{")) {
    // Parse YAML/JSON style from the command line.
    if (error_code ec = parseConfiguration(StyleName, &Style)) {
      llvm::errs() << "Error parsing -style: " << ec.message()
                   << ", using " << FallbackStyle << " style\n";
    }
    return Style;
  }

  if (!StyleName.equals_lower("file")) {
    if (!getPredefinedStyle(StyleName, &Style))
      llvm::errs() << "Invalid value for -style, using " << FallbackStyle
                   << " style\n";
    return Style;
  }

  if (FileName == "-")
    FileName = AssumeFilename;
  SmallString<128> Path(FileName);
  llvm::sys::fs::make_absolute(Path);
  for (StringRef Directory = Path;
       !Directory.empty();
       Directory = llvm::sys::path::parent_path(Directory)) {
    if (!llvm::sys::fs::is_directory(Directory))
      continue;
    SmallString<128> ConfigFile(Directory);

    llvm::sys::path::append(ConfigFile, ".clang-format");
    DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
    bool IsFile = false;
    // Ignore errors from is_regular_file: we only need to know if we can read
    // the file or not.
    llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);

    if (!IsFile) {
      // Try _clang-format too, since dotfiles are not commonly used on Windows.
      ConfigFile = Directory;
      llvm::sys::path::append(ConfigFile, "_clang-format");
      DEBUG(llvm::dbgs() << "Trying " << ConfigFile << "...\n");
      llvm::sys::fs::is_regular_file(Twine(ConfigFile), IsFile);
    }

    if (IsFile) {
      OwningPtr<MemoryBuffer> Text;
      if (error_code ec = MemoryBuffer::getFile(ConfigFile, Text)) {
        llvm::errs() << ec.message() << "\n";
        continue;
      }
      if (error_code ec = parseConfiguration(Text->getBuffer(), &Style)) {
        llvm::errs() << "Error reading " << ConfigFile << ": " << ec.message()
                     << "\n";
        continue;
      }
      DEBUG(llvm::dbgs() << "Using configuration file " << ConfigFile << "\n");
      return Style;
    }
  }
  llvm::errs() << "Can't find usable .clang-format, using " << FallbackStyle
               << " style\n";
  return Style;
}
Exemplo n.º 12
0
CMakeConfig BuildDirManager::configuration() const
{
    return parseConfiguration();
}
Exemplo n.º 13
0
AbstractRPM::AbstractRPM(std::shared_ptr<Wt::WServer> server, Wt::Json::Object conf) :
		server(server), shouldExit(false)
{
	parseConfiguration(conf);
}