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


C++ ArrayValue类代码示例

本文整理汇总了C++中ArrayValue的典型用法代码示例。如果您正苦于以下问题:C++ ArrayValue类的具体用法?C++ ArrayValue怎么用?C++ ArrayValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ArrayValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parseAdvancedConstraints

static void parseAdvancedConstraints(const Dictionary& mediaTrackConstraints, Vector<MediaTrackConstraintSetMap>& advancedConstraints)
{
    ArrayValue sequenceOfMediaTrackConstraintSets;
    if (!mediaTrackConstraints.get("advanced", sequenceOfMediaTrackConstraintSets) || sequenceOfMediaTrackConstraintSets.isUndefinedOrNull()) {
        LOG(Media, "parseAdvancedConstraints() - value of advanced key is not a list.");
        return;
    }

    size_t numberOfConstraintSets;
    if (!sequenceOfMediaTrackConstraintSets.length(numberOfConstraintSets)) {
        LOG(Media, "parseAdvancedConstraints() - ignoring empty advanced sequence of MediaTrackConstraintSets.");
        return;
    }

    for (size_t i = 0; i < numberOfConstraintSets; ++i) {
        Dictionary mediaTrackConstraintSet;
        if (!sequenceOfMediaTrackConstraintSets.get(i, mediaTrackConstraintSet) || mediaTrackConstraintSet.isUndefinedOrNull()) {
            LOG(Media, "parseAdvancedConstraints() - ignoring constraint set with index '%zu' in advanced list.", i);
            continue;
        }

        MediaTrackConstraintSetMap map;

        Vector<String> localKeys;
        mediaTrackConstraintSet.getOwnPropertyNames(localKeys);
        for (auto& localKey : localKeys)
            parseMediaTrackConstraintSetForKey(mediaTrackConstraintSet, localKey, map, ConstraintSetType::Advanced);

        if (!map.isEmpty())
            advancedConstraints.append(WTFMove(map));
    }
}
开发者ID:ollie314,项目名称:webkit,代码行数:32,代码来源:JSMediaDevicesCustom.cpp

示例2: ASCIILiteral

bool MediaConstraintsImpl::initialize(const Dictionary& constraints)
{
    if (constraints.isUndefinedOrNull())
        return true;

    Vector<String> names;
    constraints.getOwnPropertyNames(names);

    String mandatory = ASCIILiteral("mandatory");
    String optional = ASCIILiteral("optional");

    for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) {
        if (*it != mandatory && *it != optional)
            return false;
    }

    if (names.contains(mandatory)) {
        Dictionary mandatoryConstraints;
        bool ok = constraints.get(mandatory, mandatoryConstraints);
        if (!ok || mandatoryConstraints.isUndefinedOrNull())
            return false;

        ok = mandatoryConstraints.getOwnPropertiesAsStringHashMap(m_mandatoryConstraints);
        if (!ok)
            return false;
    }

    if (names.contains(optional)) {
        ArrayValue optionalConstraints;
        bool ok = constraints.get(optional, optionalConstraints);
        if (!ok || optionalConstraints.isUndefinedOrNull())
            return false;

        size_t numberOfConstraints;
        ok = optionalConstraints.length(numberOfConstraints);
        if (!ok)
            return false;

        for (size_t i = 0; i < numberOfConstraints; ++i) {
            Dictionary constraint;
            ok = optionalConstraints.get(i, constraint);
            if (!ok || constraint.isUndefinedOrNull())
                return false;
            Vector<String> localNames;
            constraint.getOwnPropertyNames(localNames);
            if (localNames.size() != 1)
                return false;
            String key = localNames[0];
            String value;
            ok = constraint.get(key, value);
            if (!ok)
                return false;
            m_optionalConstraints.append(MediaConstraint(key, value));
        }
    }

    return true;
}
开发者ID:Channely,项目名称:know-your-chrome,代码行数:58,代码来源:MediaConstraintsImpl.cpp

示例3: initialize

void RTCConfiguration::initialize(const Dictionary& configuration, ExceptionCode& ec)
{
    ArrayValue iceServers;
    bool ok = configuration.get("iceServers", iceServers);
    if (!ok || iceServers.isUndefinedOrNull()) {
        ec = TYPE_MISMATCH_ERR;
        return;
    }

    size_t numberOfServers;
    ok = iceServers.length(numberOfServers);
    if (!ok || !numberOfServers) {
        ec = !ok ? TYPE_MISMATCH_ERR : INVALID_ACCESS_ERR;
        return;
    }

    for (size_t i = 0; i < numberOfServers; ++i) {
        Dictionary iceServerDict;
        ok = iceServers.get(i, iceServerDict);
        if (!ok) {
            ec = TYPE_MISMATCH_ERR;
            return;
        }

        RefPtr<RTCIceServer> iceServer = parseIceServer(iceServerDict, ec);
        if (!iceServer)
            return;

        m_iceServers.append(WTFMove(iceServer));
    }

    String iceTransportPolicy;
    if (configuration.get("iceTransportPolicy", iceTransportPolicy)) {
        if (iceTransportPolicy == "relay")
            m_iceTransportPolicy = IceTransportPolicy::Relay;
        else if (iceTransportPolicy == "all")
            m_iceTransportPolicy = IceTransportPolicy::All;
        else {
            ec = TypeError;
            return;
        }
    }

    String bundlePolicy;
    if (configuration.get("bundlePolicy", bundlePolicy)) {
        if (bundlePolicy == "balanced")
            m_bundlePolicy = BundlePolicy::Balanced;
        else if (bundlePolicy == "max-compat")
            m_bundlePolicy = BundlePolicy::MaxCompat;
        else if (bundlePolicy == "max-bundle")
            m_bundlePolicy = BundlePolicy::MaxBundle;
        else
            ec = TypeError;
    }
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:55,代码来源:RTCConfiguration.cpp

示例4: parse

// Old style parser. Deprecated.
static bool parse(const Dictionary& constraintsDictionary, WebVector<WebMediaConstraint>& optional, WebVector<WebMediaConstraint>& mandatory)
{
    if (constraintsDictionary.isUndefinedOrNull())
        return true;

    Vector<String> names;
    bool ok = constraintsDictionary.getPropertyNames(names);
    if (!ok)
        return false;

    String mandatoryName("mandatory");
    String optionalName("optional");

    for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) {
        if (*it != mandatoryName && *it != optionalName)
            return false;
    }

    if (names.contains(mandatoryName)) {
        Dictionary mandatoryConstraintsDictionary;
        bool ok = constraintsDictionary.get(mandatoryName, mandatoryConstraintsDictionary);
        if (!ok || mandatoryConstraintsDictionary.isUndefinedOrNull())
            return false;
        ok = parseMandatoryConstraintsDictionary(mandatoryConstraintsDictionary, mandatory);
        if (!ok)
            return false;
    }

    Vector<WebMediaConstraint> optionalConstraintsVector;
    if (names.contains(optionalName)) {
        ArrayValue optionalConstraints;
        bool ok = DictionaryHelper::get(constraintsDictionary, optionalName, optionalConstraints);
        if (!ok || optionalConstraints.isUndefinedOrNull())
            return false;

        size_t numberOfConstraints;
        ok = optionalConstraints.length(numberOfConstraints);
        if (!ok)
            return false;

        for (size_t i = 0; i < numberOfConstraints; ++i) {
            Dictionary constraint;
            ok = optionalConstraints.get(i, constraint);
            if (!ok || constraint.isUndefinedOrNull())
                return false;
            ok = parseOptionalConstraintsVectorElement(constraint, optionalConstraintsVector);
            if (!ok)
                return false;
        }
        optional.assign(optionalConstraintsVector);
    }

    return true;
}
开发者ID:joone,项目名称:chromium-crosswalk,代码行数:55,代码来源:MediaConstraintsImpl.cpp

示例5: initializeStringConstraintWithList

static void initializeStringConstraintWithList(StringConstraint& constraint, void (StringConstraint::*appendValue)(const String&), const ArrayValue& list)
{
    size_t size;
    if (!list.length(size))
        return;

    for (size_t i = 0; i < size; ++i) {
        String value;
        if (list.get(i, value))
            (constraint.*appendValue)(value);
    }
}
开发者ID:ollie314,项目名称:webkit,代码行数:12,代码来源:JSMediaDevicesCustom.cpp

示例6: result

ustring DataValue::serializeArray(void *value) {
	ustring result("[");
	ArrayValue *arr = (ArrayValue*)value;
	for(ArrayValue::iterator i = arr->begin(); i != arr->end(); i++) {
		if(i != arr->begin())
			result += ",";
		result += "'" + i->name + "'=" + serialize(arr->type, i->data);
	}
	result += "]";

	return result;
}
开发者ID:hiasmstudio,项目名称:hiasm5,代码行数:12,代码来源:ElementProperty.cpp

示例7: if

ExceptionOr<void> RTCConfiguration::initialize(const Dictionary& configuration)
{
    ArrayValue iceServers;
    bool ok = configuration.get("iceServers", iceServers);
    if (!ok || iceServers.isUndefinedOrNull())
        return Exception { TYPE_MISMATCH_ERR };

    size_t numberOfServers;
    ok = iceServers.length(numberOfServers);
    if (!ok)
        return Exception { TYPE_MISMATCH_ERR };
    if (!numberOfServers)
        return Exception { INVALID_ACCESS_ERR };

    for (size_t i = 0; i < numberOfServers; ++i) {
        Dictionary iceServerDict;
        ok = iceServers.get(i, iceServerDict);
        if (!ok)
            return Exception { TYPE_MISMATCH_ERR };

        auto server = parseIceServer(iceServerDict);
        if (server.hasException())
            return server.releaseException();

        m_iceServers.append(server.releaseReturnValue());
    }

    String iceTransportPolicy;
    if (configuration.get("iceTransportPolicy", iceTransportPolicy)) {
        if (iceTransportPolicy == "relay")
            m_iceTransportPolicy = IceTransportPolicy::Relay;
        else if (iceTransportPolicy == "all")
            m_iceTransportPolicy = IceTransportPolicy::All;
        else
            return Exception { TypeError };
    }

    String bundlePolicy;
    if (configuration.get("bundlePolicy", bundlePolicy)) {
        if (bundlePolicy == "balanced")
            m_bundlePolicy = BundlePolicy::Balanced;
        else if (bundlePolicy == "max-compat")
            m_bundlePolicy = BundlePolicy::MaxCompat;
        else if (bundlePolicy == "max-bundle")
            m_bundlePolicy = BundlePolicy::MaxBundle;
        else
            return Exception { TypeError };
    }

    return { };
}
开发者ID:ollie314,项目名称:webkit,代码行数:51,代码来源:RTCConfiguration.cpp

示例8: url

PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Dictionary& configuration, ExceptionCode& ec)
{
    if (configuration.isUndefinedOrNull())
        return nullptr;

    ArrayValue iceServers;
    bool ok = configuration.get("iceServers", iceServers);
    if (!ok || iceServers.isUndefinedOrNull()) {
        ec = TYPE_MISMATCH_ERR;
        return nullptr;
    }

    size_t numberOfServers;
    ok = iceServers.length(numberOfServers);
    if (!ok) {
        ec = TYPE_MISMATCH_ERR;
        return nullptr;
    }

    RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create();

    for (size_t i = 0; i < numberOfServers; ++i) {
        Dictionary iceServer;
        ok = iceServers.get(i, iceServer);
        if (!ok) {
            ec = TYPE_MISMATCH_ERR;
            return nullptr;
        }

        String urlString, credential, username;
        ok = iceServer.get("url", urlString);
        if (!ok) {
            ec = TYPE_MISMATCH_ERR;
            return nullptr;
        }
        URL url(URL(), urlString);
        if (!url.isValid() || !(url.protocolIs("turn") || url.protocolIs("stun"))) {
            ec = TYPE_MISMATCH_ERR;
            return nullptr;
        }

        iceServer.get("credential", credential);
        iceServer.get("username", username);

        rtcConfiguration->appendServer(RTCIceServer::create(url, credential, username));
    }

    return rtcConfiguration.release();
}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例9: parseArray

void DataValue::parseArray(const ustring &text, void *value) {
	ArrayValue *arr = (ArrayValue*)value;
	int i = 1;	// skip [
	while (text[i] != ']') {
		i++;	// skip '
		int p = text.find('\'', i);
		void *v = arr->add(ustring(text, i, p - i));
		i = p + 2;	// skip =
		p = text.find(',', i);
		if(p == -1)
			p = text.length() - 1;
		parse(ustring(text, i, p - i), arr->type, v);
		i = p;
		if(text[i] == ',') i++;
	}
}
开发者ID:hiasmstudio,项目名称:hiasm5,代码行数:16,代码来源:ElementProperty.cpp

示例10: makeItems

 void makeItems(ArrayValue const &ids, bool recommended)
 {
     for (Value const *value : ids.elements())
     {
         contents->items() << new Item(value->asText(), recommended, packageId);
     }
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例11:

CBORValue::CBORValue(const ArrayValue& inArray)
    : m_type(Type::Array)
    , m_arrayValue()
{
    m_arrayValue.reserveCapacity(inArray.size());
    for (const auto& val : inArray)
        m_arrayValue.append(val.clone());
}
开发者ID:wolfviking0,项目名称:webcl-webkit,代码行数:8,代码来源:CBORValue.cpp

示例12: if

Value *DictionaryValue::next()
{
    if (!_validIteration)
    {
        _iteration = _elements.begin();
        _validIteration = true;
    }
    else if (_iteration == _elements.end())
    {
        return 0;
    }
    ArrayValue *pair = new ArrayValue;
    pair->add(_iteration->first.value->duplicate());
    pair->add(_iteration->second->duplicate());
    ++_iteration;
    return pair;
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例13: processIceServer

PassRefPtr<RTCConfiguration> RTCPeerConnection::parseConfiguration(const Dictionary& configuration, ExceptionCode& ec)
{
    if (configuration.isUndefinedOrNull())
        return nullptr;

    ArrayValue iceServers;
    bool ok = configuration.get("iceServers", iceServers);
    if (!ok || iceServers.isUndefinedOrNull()) {
        ec = TYPE_MISMATCH_ERR;
        return nullptr;
    }

    size_t numberOfServers;
    ok = iceServers.length(numberOfServers);
    if (!ok || !numberOfServers) {
        ec = !ok ? TYPE_MISMATCH_ERR : INVALID_ACCESS_ERR;
        return nullptr;
    }

    String iceTransports;
    String requestIdentity;
    configuration.get("iceTransports", iceTransports);
    configuration.get("requestIdentity", requestIdentity);

    RefPtr<RTCConfiguration> rtcConfiguration = RTCConfiguration::create();

    rtcConfiguration->setIceTransports(iceTransports);
    rtcConfiguration->setRequestIdentity(requestIdentity);

    for (size_t i = 0; i < numberOfServers; ++i) {
        Dictionary iceServer;
        ok = iceServers.get(i, iceServer);
        if (!ok) {
            ec = TYPE_MISMATCH_ERR;
            return nullptr;
        }

        ec = processIceServer(iceServer, rtcConfiguration.get());
        if (ec)
            return nullptr;
    }

    return rtcConfiguration.release();
}
开发者ID:boska,项目名称:webkit,代码行数:44,代码来源:RTCPeerConnection.cpp

示例14: parse

static bool parse(const Dictionary& constraintsDictionary, blink::WebVector<blink::WebMediaConstraint>& optional, blink::WebVector<blink::WebMediaConstraint>& mandatory)
{
    if (constraintsDictionary.isUndefinedOrNull())
        return true;

    Vector<String> names;
    constraintsDictionary.getOwnPropertyNames(names);

    String mandatoryName("mandatory");
    String optionalName("optional");

    for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) {
        if (*it != mandatoryName && *it != optionalName)
            return false;
    }

    Vector<blink::WebMediaConstraint> mandatoryConstraintsVector;
    if (names.contains(mandatoryName)) {
        Dictionary mandatoryConstraintsDictionary;
        bool ok = constraintsDictionary.get(mandatoryName, mandatoryConstraintsDictionary);
        if (!ok || mandatoryConstraintsDictionary.isUndefinedOrNull())
            return false;

        HashMap<String, String> mandatoryConstraintsHashMap;
        ok = mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap(mandatoryConstraintsHashMap);
        if (!ok)
            return false;

        HashMap<String, String>::const_iterator iter = mandatoryConstraintsHashMap.begin();
        for (; iter != mandatoryConstraintsHashMap.end(); ++iter)
            mandatoryConstraintsVector.append(blink::WebMediaConstraint(iter->key, iter->value));
    }

    Vector<blink::WebMediaConstraint> optionalConstraintsVector;
    if (names.contains(optionalName)) {
        ArrayValue optionalConstraints;
        bool ok = constraintsDictionary.get(optionalName, optionalConstraints);
        if (!ok || optionalConstraints.isUndefinedOrNull())
            return false;

        size_t numberOfConstraints;
        ok = optionalConstraints.length(numberOfConstraints);
        if (!ok)
            return false;

        for (size_t i = 0; i < numberOfConstraints; ++i) {
            Dictionary constraint;
            ok = optionalConstraints.get(i, constraint);
            if (!ok || constraint.isUndefinedOrNull())
                return false;
            Vector<String> localNames;
            constraint.getOwnPropertyNames(localNames);
            if (localNames.size() != 1)
                return false;
            String key = localNames[0];
            String value;
            ok = constraint.get(key, value);
            if (!ok)
                return false;
            optionalConstraintsVector.append(blink::WebMediaConstraint(key, value));
        }
    }

    optional.assign(optionalConstraintsVector);
    mandatory.assign(mandatoryConstraintsVector);
    return true;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:67,代码来源:MediaConstraintsImpl.cpp

示例15: createStringConstraint

static Optional<StringConstraint> createStringConstraint(const Dictionary& mediaTrackConstraintSet, const String& name, MediaConstraintType type, ConstraintSetType constraintSetType)
{
    auto constraint = StringConstraint(name, type);

    // Dictionary constraint value.
    Dictionary dictionaryValue;
    if (mediaTrackConstraintSet.get(name, dictionaryValue) && !dictionaryValue.isUndefinedOrNull()) {
        ArrayValue exactArrayValue;
        if (dictionaryValue.get("exact", exactArrayValue) && !exactArrayValue.isUndefinedOrNull())
            initializeStringConstraintWithList(constraint, &StringConstraint::appendExact, exactArrayValue);
        else {
            String exactStringValue;
            if (dictionaryValue.get("exact", exactStringValue))
                constraint.setExact(exactStringValue);
        }

        ArrayValue idealArrayValue;
        if (dictionaryValue.get("ideal", idealArrayValue) && !idealArrayValue.isUndefinedOrNull())
            initializeStringConstraintWithList(constraint, &StringConstraint::appendIdeal, idealArrayValue);
        else {
            String idealStringValue;
            if (!dictionaryValue.get("ideal", idealStringValue))
                constraint.setIdeal(idealStringValue);
        }

        if (constraint.isEmpty()) {
            LOG(Media, "createStringConstraint() - ignoring string constraint '%s' with dictionary value since it has no valid or supported key/value pairs.", name.utf8().data());
            return Nullopt;
        }
        
        return WTFMove(constraint);
    }

    // Array constraint value.
    ArrayValue arrayValue;
    if (mediaTrackConstraintSet.get(name, arrayValue) && !arrayValue.isUndefinedOrNull()) {
        initializeStringConstraintWithList(constraint, &StringConstraint::appendIdeal, arrayValue);

        if (constraint.isEmpty()) {
            LOG(Media, "createStringConstraint() - ignoring string constraint '%s' with array value since it is empty.", name.utf8().data());
            return Nullopt;
        }

        return WTFMove(constraint);
    }

    // Scalar constraint value.
    String value;
    if (mediaTrackConstraintSet.get(name, value)) {
        if (constraintSetType == ConstraintSetType::Mandatory)
            constraint.setIdeal(value);
        else
            constraint.setExact(value);
        
        return WTFMove(constraint);
    }

    // Invalid constraint value.
    LOG(Media, "createStringConstraint() - ignoring string constraint '%s' since it has neither a dictionary nor sequence nor scalar value.", name.utf8().data());
    return Nullopt;
}
开发者ID:ollie314,项目名称:webkit,代码行数:61,代码来源:JSMediaDevicesCustom.cpp


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