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


C++ Nullable::get方法代码示例

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


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

示例1: get_idf_cpp

// [[Rcpp::export]]
List get_idf_cpp(List x,Nullable<CharacterVector> stop_) {

  IDFmap m;
  for(ListOf<CharacterVector>::iterator it = x.begin();it != x.end();it++){
    unsigned int dis = distance( x.begin(), it );
    auto tmp = as<CharacterVector>(*it);
    inner_find(tmp,m,dis);
  }
  RCPP_UNORDERED_MAP< string,unsigned int > res;
  
  
  unordered_set<string> st;
  
  if(!stop_.isNull()){
    CharacterVector stop_value = stop_.get();
    const char *const stop_path = stop_value[0];
    _loadStopWordDict(stop_path,st);
    for(auto its= m.begin();its!=m.end();its++){
      if(st.find((*its).first) ==st.end()) res[(*its).first] = (*its).second.second;
    }
    return wrap(res);
  }
  
  for(auto its= m.begin();its!=m.end();its++){
    res[(*its).first] = (*its).second.second;
  }
  return wrap(res);
}
开发者ID:luojiahuli,项目名称:jiebaR,代码行数:29,代码来源:get_idf.cpp

示例2: checkFileInfo

void TextData::checkFileInfo()
{
    if (fileNamePseudoFlag == false)
    {
        Nullable<TimeStamp> oldLastModifiedTime;
        bool fileExisted = false;
        
        if (fileInfo.exists())
        {
            fileExisted = true;
            oldLastModifiedTime = fileInfo.getLastModifiedTime();
        }
    
        this->fileInfo = File(this->fileName).getInfo();
        
        if (fileInfo.exists())
        {
            if (isReadOnlyFlag != !fileInfo.isWritable()) {
                isReadOnlyFlag = !fileInfo.isWritable();
                readOnlyListeners.invokeAllCallbacks(isReadOnlyFlag);
            }
            
            if (  (   fileExisted 
                   && fileInfo.getLastModifiedTime() != oldLastModifiedTime.get())
               || (!fileExisted))
            {
                modifiedOnDiskFlag = true;
            }
        }
    }
}
开发者ID:osch,项目名称:luced,代码行数:31,代码来源:TextData.cpp

示例3: Dictionary

TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter)
{
    Vector<Dictionary, 0> jsKeyframes;

    v8::Handle<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate);
    setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5);
    Dictionary timingInputDictionaryWithDuration = Dictionary(v8::Handle<v8::Value>::Cast(timingInputWithDuration), m_isolate);

    RefPtrWillBeRawPtr<Animation> animationWithDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryWithDuration, exceptionState);

    RefPtrWillBeRawPtr<AnimationNodeTiming> specifiedWithDuration = animationWithDuration->timing();
    Nullable<double> numberDuration;
    String stringDuration;
    specifiedWithDuration->getDuration("duration", numberDuration, stringDuration);
    EXPECT_FALSE(numberDuration.isNull());
    EXPECT_EQ(2.5, numberDuration.get());
    EXPECT_TRUE(stringDuration.isNull());


    v8::Handle<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate);
    Dictionary timingInputDictionaryNoDuration = Dictionary(v8::Handle<v8::Value>::Cast(timingInputNoDuration), m_isolate);

    RefPtrWillBeRawPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryNoDuration, exceptionState);

    RefPtrWillBeRawPtr<AnimationNodeTiming> specifiedNoDuration = animationNoDuration->timing();
    Nullable<double> numberDuration2;
    String stringDuration2;
    specifiedNoDuration->getDuration("duration", numberDuration2, stringDuration2);
    EXPECT_TRUE(numberDuration2.isNull());
    EXPECT_FALSE(stringDuration2.isNull());
    EXPECT_EQ("auto", stringDuration2);
}
开发者ID:dalecurtis,项目名称:mojo,代码行数:32,代码来源:AnimationTest.cpp

示例4: executeSql

void SQLTransaction::executeSql(ScriptState* scriptState, const String& sqlStatement, const Nullable<Vector<ScriptValue>>& arguments, SQLStatementCallback* callback, SQLStatementErrorCallback* callbackError, ExceptionState& exceptionState)
{
    Vector<SQLValue> sqlValues;
    if (!arguments.isNull())
        sqlValues = toImplArray<Vector<SQLValue>>(arguments.get(), scriptState->isolate(), exceptionState);
    executeSQL(sqlStatement, sqlValues, callback, callbackError, exceptionState);
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:7,代码来源:SQLTransaction.cpp

示例5: internLoadBuffer

// prepend fileName with "@" for external file, with "$" for builtin file
void LuaAccess::internLoadBuffer(const char*      scriptBegin,
                                 long             scriptLength,
                                 Nullable<String> fileName) const
{
    String      chunkName;
    const char* chunkNamePtr = NULL;
    if (fileName.isValid()) {
        chunkName << fileName.get();
        chunkNamePtr = chunkName.toCString();
    }

    int parsingRc = luaL_loadbuffer(L, scriptBegin, scriptLength, chunkNamePtr);

    if (parsingRc != 0) {
        if (parsingRc == LUA_ERRSYNTAX) {
            LuaVar errorObject(*this, lua_gettop(L));
            if (fileName.isValid()) {
                throw LuaException(ExceptionLuaInterface::createParsingFileError(errorObject, fileName.get()));
            } else {
                throw LuaException(ExceptionLuaInterface::createParsingScriptError(errorObject, scriptBegin, scriptLength));
            }
        }
        else if (parsingRc == LUA_ERRMEM) {
            throw LuaException(*this, "out of memory");
        }
        else {
            throw SystemException("unknown error while parsing lua script");
        }
    }
}
开发者ID:BackupTheBerlios,项目名称:luced,代码行数:31,代码来源:LuaAccess.cpp

示例6: tagger

 tagger(CharacterVector dict, CharacterVector model, CharacterVector user,Nullable<CharacterVector> stop) :
   dict_path(dict[0]), model_path(model[0]), user_path(user[0]), stopWords(unordered_set<string>()), taggerseg(dict_path, model_path, user_path)
 {
 	  	  if(!stop.isNull()){
 	    CharacterVector stop_value = stop.get();
 	 	  const char *const stop_path = stop_value[0];
 	 	  _loadStopWordDict(stop_path,stopWords);
 	 }
 }
开发者ID:hoyoung2015,项目名称:jiebaR,代码行数:9,代码来源:segtype.hpp

示例7: select

 static int select(int n, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const Nullable<TimePeriod>& timePeriod)
 {
     struct timeval  t;
     struct timeval* tPtr;
     
     if (timePeriod.isValid())
     {
         if (timePeriod.get() > Seconds(0)) {
             t = timePeriod.get().toTimeval();
         } else {
             t = TimePeriod(Seconds(0)).toTimeval();
         }
         tPtr = &t;
     } else {
         tPtr = NULL;
     }
     return ::select(n, readfds, writefds, exceptfds, tPtr);
 }
开发者ID:BackupTheBerlios,项目名称:luced,代码行数:18,代码来源:System.hpp

示例8: get_idf_cpp

// [[Rcpp::export]]
List get_idf_cpp(List x,Nullable<CharacterVector> stop_) {

  IDFmap m;
  for(ListOf<CharacterVector>::iterator it = x.begin();it != x.end();it++){
    unsigned int dis = distance( x.begin(), it );
    auto tmp = as<CharacterVector>(*it);
    inner_find(tmp,m,dis);
  }


  
  vector<string> sts;
  vector<double> stn;
  sts.reserve(m.size());
  stn.reserve(m.size());
  
  unordered_set<string> st;

  double xsize = x.size();
  
  if(!stop_.isNull()){
    CharacterVector stop_value = stop_.get();
    const char *const stop_path = stop_value[0];
    _loadStopWordDict(stop_path,st);
    for(auto its= m.begin();its!=m.end();its++){
      if(st.find((*its).first) ==st.end()){
        sts.push_back((*its).first);
        stn.push_back( log(xsize / (*its).second.second) );
      }
    }

  }else{
    for(auto its= m.begin();its!=m.end();its++){
      sts.push_back((*its).first);
      stn.push_back((*its).second.second);
    }
  }
  
  vector<string> row_names;
  row_names.reserve(sts.size());
  for (unsigned int i = 0; i < sts.size(); ++i) {
    row_names.emplace_back(int64tos(i));
  }
  
  List res = List::create(_["name"] = wrap(sts),_["count"] = wrap(stn));
  res.attr("row.names") = row_names;
  res.attr("names") = CharacterVector::create("name","count");
  res.attr("class") = "data.frame";
  return res;
}
开发者ID:Benknightdark,项目名称:jiebaR,代码行数:51,代码来源:get_idf.cpp

示例9: requestAll

ScriptPromise Permissions::requestAll(ScriptState* scriptState, const Vector<Dictionary>& rawPermissions)
{
    WebPermissionClient* client = getClient(scriptState->getExecutionContext());
    if (!client)
        return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "In its current state, the global scope can't request permissions."));

    ExceptionState exceptionState(ExceptionState::GetterContext,  "request", "Permissions", scriptState->context()->Global(), scriptState->isolate());
    OwnPtr<Vector<WebPermissionType>> internalPermissions = adoptPtr(new Vector<WebPermissionType>());
    OwnPtr<Vector<int>> callerIndexToInternalIndex = adoptPtr(new Vector<int>(rawPermissions.size()));
    for (size_t i = 0; i < rawPermissions.size(); ++i) {
        const Dictionary& rawPermission = rawPermissions[i];

        Nullable<WebPermissionType> type = parsePermission(scriptState, rawPermission, exceptionState);
        if (exceptionState.hadException())
            return exceptionState.reject(scriptState);

        // Only append permissions to the vector that is passed to the client if it is not already
        // in the vector (i.e. do not duplicate permisison types).
        int internalIndex;
        auto it = internalPermissions->find(type.get());
        if (it == kNotFound) {
            internalIndex = internalPermissions->size();
            internalPermissions->append(type.get());
        } else {
            internalIndex = it;
        }
        callerIndexToInternalIndex->operator[](i) = internalIndex;
    }

    ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
    ScriptPromise promise = resolver->promise();

    WebVector<WebPermissionType> internalWebPermissions = *internalPermissions;
    client->requestPermissions(internalWebPermissions, KURL(KURL(), scriptState->getExecutionContext()->getSecurityOrigin()->toString()),
        new PermissionsCallback(resolver, internalPermissions.release(), callerIndexToInternalIndex.release()));
    return promise;
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:37,代码来源:Permissions.cpp

示例10: revoke

ScriptPromise Permissions::revoke(ScriptState* scriptState, const Dictionary& rawPermission)
{
    WebPermissionClient* client = getClient(scriptState->getExecutionContext());
    if (!client)
        return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "In its current state, the global scope can't revoke permissions."));

    ExceptionState exceptionState(ExceptionState::GetterContext,  "revoke", "Permissions", scriptState->context()->Global(), scriptState->isolate());
    Nullable<WebPermissionType> type = parsePermission(scriptState, rawPermission, exceptionState);
    if (exceptionState.hadException())
        return exceptionState.reject(scriptState);

    ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
    ScriptPromise promise = resolver->promise();

    client->revokePermission(type.get(), KURL(KURL(), scriptState->getExecutionContext()->getSecurityOrigin()->toString()), new PermissionCallback(resolver, type.get()));
    return promise;
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:17,代码来源:Permissions.cpp

示例11: query

ScriptPromise Permissions::query(ScriptState* scriptState, const Dictionary& rawPermission)
{
    WebPermissionClient* client = getClient(scriptState->getExecutionContext());
    if (!client)
        return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "In its current state, the global scope can't query permissions."));

    ExceptionState exceptionState(ExceptionState::GetterContext,  "query", "Permissions", scriptState->context()->Global(), scriptState->isolate());
    Nullable<WebPermissionType> type = parsePermission(scriptState, rawPermission, exceptionState);
    if (exceptionState.hadException())
        return exceptionState.reject(scriptState);

    ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
    ScriptPromise promise = resolver->promise();

    // If the current origin is a file scheme, it will unlikely return a
    // meaningful value because most APIs are broken on file scheme and no
    // permission prompt will be shown even if the returned permission will most
    // likely be "prompt".
    client->queryPermission(type.get(), KURL(KURL(), scriptState->getExecutionContext()->getSecurityOrigin()->toString()), new PermissionCallback(resolver, type.get()));
    return promise;
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:21,代码来源:Permissions.cpp

示例12: reloadFile

void TextData::reloadFile()
{
    File file(this->fileName);

    long oldLength = getLength();
    long oldNumberLines = this->numberLines;

    ObjectArray<LineAndColumn> oldMarkPositions;

    for (long i = 0; i < marks.getLength(); ++i) {
        if (marks[i].inUseCounter > 0) {
            oldMarkPositions.append(LineAndColumn(marks[i].line,
                                                  getWCharColumn(marks[i])));
        } else {
            oldMarkPositions.append(LineAndColumn(0, 0));
        }
    }
    
    Nullable<FileException> fileException;
    try {
        file.loadInto(&buffer);
    } catch (FileException& ex) {
        fileException = ex;
    }

    EncodingConverter c(fileContentEncoding, "UTF-8");
    
    if (c.isConvertingBetweenDifferentCodesets())
    {
        c.convertInPlace(&buffer);
    }

    long len = buffer.getLength();
    byte* ptr = buffer.getTotalAmount();

    this->numberLines = 1;
    for (long i = 0; i < len; ++i) {
        if (ptr[i] == '\n') {
            ++this->numberLines;
        }
    }
    this->beginChangedPos = 0;
    this->changedAmount = len - oldLength;
    this->oldEndChangedPos = oldLength;
    
    updateMarks(0, oldLength, len - oldLength,           // long beginChangedPos, long oldEndChangedPos, long changedAmount,
                0, this->numberLines - oldNumberLines);  // long beginLineNumber, long changedLineNumberAmount)

    for (long i = 0; i < marks.getLength(); ++i) {
        if (marks[i].inUseCounter > 0) {
            moveMarkToLineAndWCharColumn(MarkHandle(i), oldMarkPositions[i].line,
                                                        oldMarkPositions[i].wcharColumn);
        }
    }
    setModifiedFlag(false);

    this->fileInfo = file.getInfo();
    this->modifiedOnDiskFlag = false;
    this->ignoreModifiedOnDiskFlag = false;

    if (!fileException.isValid()) {
        if (isReadOnlyFlag != !fileInfo.isWritable()) {
            isReadOnlyFlag = !fileInfo.isWritable();
            readOnlyListeners.invokeAllCallbacks(isReadOnlyFlag);
        }
        clearHistory();
    }
    if (fileException.isValid()) {
        throw fileException.get();
    }
}
开发者ID:osch,项目名称:luced,代码行数:71,代码来源:TextData.cpp

示例13: openFiles

void FileOpener::openFiles()
{
    if (isWaitingForMessageBox) {
        isWaitingForMessageBox = false;
        ASSERT(lastTopWin.isValid());
        if (lastTopWin.isValid()) {
            lastTopWin->requestCloseWindow(TopWin::CLOSED_SILENTLY);
            lastTopWin = NULL;
        }
    }

    ASSERT(!isWaitingForMessageBox)

    while (fileParameterList.isValid() && fileParameterList->getLength() > 0)
    {
        int    numberOfWindows  = fileParameterList->get(0).numberOfWindows;
        String fileName         = fileParameterList->get(0).fileName;
        String encoding         = fileParameterList->get(0).encoding;
        String resolvedFileName = File(fileName).getAbsoluteNameWithResolvedLinks();

        if (numberOfWindows <= 0)
        {
            numberOfWindows = 1;
        }

        RawPtr<TopWinList> topWins = TopWinList::getInstance();

        if (lastTopWin.isInvalid())
        {

            numberOfRaisedWindows = 0;

            for (int w = 0; w < topWins->getNumberOfTopWins() && numberOfRaisedWindows < numberOfWindows; ++w)
            {
                EditorTopWin* topWin = dynamic_cast<EditorTopWin*>(topWins->getTopWin(w));
                if (topWin != NULL && File(topWin->getFileName()).getAbsoluteNameWithResolvedLinks() == resolvedFileName) {
                    topWin->raise();
                    numberOfRaisedWindows += 1;
                    lastTopWin = topWin;
                }
            }

            if (lastTopWin.isInvalid() && numberOfRaisedWindows < numberOfWindows)
            {
                TextData::Ptr     textData     = TextData::create();
                LanguageMode::Ptr languageMode;
                HilitedText::Ptr  hilitedText;
                
                Nullable<String> errorMessage;

                try
                {
                    ByteBuffer buffer; 
                    File(fileName).loadInto(&buffer);
                    
                    Nullable<GlobalConfig::LanguageModeAndEncoding> result;
                    try
                    {
                        result = GlobalConfig::getInstance()
                                 ->getLanguageModeAndEncodingForFileNameAndContent
                                 (
                                   fileName, 
                                   &buffer
                                 );
                        languageMode = result.get().languageMode;
                        hilitedText  = HilitedText::create(textData, languageMode);
                    }
                    catch (ConfigException& ex) {
                        languageMode = GlobalConfig::getInstance()->getDefaultLanguageMode();
                        hilitedText  = HilitedText::create(textData, languageMode);
                        errorMessage = ex.getMessage();
                    }
                    
                    if (encoding.getLength() == 0 && result.isValid() && result.get().encoding.getLength() > 0) {
                        encoding = result.get().encoding;
                    }

                    textData->takeOverFileBuffer(fileName, encoding, &buffer);
                }
                catch (LuaException& ex)
                {
                    throw;
                }
                catch (BaseException& ex)
                {
                    try
                    {
                        if (!languageMode.isValid()) {
                            languageMode = GlobalConfig::getInstance()->getLanguageModeForFileName(fileName);
                        }
                        if (!hilitedText.isValid()) {
                            hilitedText  = HilitedText::create(textData, languageMode);
                        }
                    } catch (BaseException& ex2) {
                        languageMode = GlobalConfig::getInstance()->getDefaultLanguageMode();
                        hilitedText  = HilitedText::create(textData, languageMode);
                    }

                    isWaitingForMessageBox = true;
                    
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:luced,代码行数:101,代码来源:FileOpener.cpp


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