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


C++ DString类代码示例

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


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

示例1: extractDirectory

TOOLSPACE_BEGIN

// 存在函数声明和定义两部分时,默认参数只可以在函数声明中设定一次
DString FileTools::extractDirectory(const DString & in_strPath, char in_cDelimiter)
{
    return in_strPath.substr(0, in_strPath.find_last_of(in_cDelimiter) + 1);
}
开发者ID:dragonkid,项目名称:XLib,代码行数:7,代码来源:FileTools.cpp

示例2: OnChangeMaterial

void ObjFileEditDialog::OnChangeMaterial(wxCommandEvent &e)
{
	if(NULL == m_pEntityListMaterialComboBox
	|| NULL == m_pMaterialListMaterialComboBox)
	return;

	DString entmatname			  = m_pEntityListMaterialComboBox->GetStringSelection().c_str();

	DString matmatname			  = m_pMaterialListMaterialComboBox->GetStringSelection().c_str();

	if(entmatname.empty() && matmatname.empty())
		return;

	DString matname;
	if(entmatname.empty())
	{
		matname = matmatname;
	}
	else
	{
		matname = entmatname;
	}

	Fairy::CGod* pModel = GetDataManipulatr()->FindModel(GetDataManipulatr()->m_CurModelName);

	if(NULL == pModel)
		return;

	std::vector<Ogre::String> matvec = Ogre::StringUtil::split(matname,".");


	pModel->ChangeMat(matvec[0],matvec[0]);
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:33,代码来源:ObjFileEditDlg.cpp

示例3: sem_create

  BaseGDL* sem_create(EnvT *e)
  {
    SizeT nParam = e->NParam(1); // 1 is the minimal number of parameter required

    DString name;
    e->AssureStringScalarPar(0, name); // IDL accepts null-string name

    int destroyIx = e->KeywordIx("DESTROY_SEMAPHORE");
    bool destroyKWPresent = e->KeywordPresent(destroyIx);
    DLong destroy = 0;
    if (destroyKWPresent) 
    {
      destroy = (*e->GetKWAs<DLongGDL>(0))[0];
    }

    bool owner = true;
#if defined(_WIN32) && !defined(__CYGWIN__)
    // TODO: Needs error handling with name length > 256
    const char* cname = name.c_str();
    WCHAR tname[256] = {0,};

    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cname, strlen(cname), tname, 256);
    HANDLE sem = CreateSemaphoreW(NULL,1,1,tname);
    if (sem == NULL) {
	owner = false;
	return new DIntGDL(0);
    }
#else
    sem_t *sem = sem_open(name.c_str(), O_CREAT | O_EXCL, 0666, 1);
    if (sem == SEM_FAILED)
    {  // semaphore exists. make another one, locked (value=0)
      owner = false;
      if (errno == EEXIST)
      {
        sem = sem_open(name.c_str(), O_CREAT ,0666, 0);
      }
      if (sem == SEM_FAILED)
      {
        return new DIntGDL(0);
      }
    }
#endif

    // Behavior for different values of DESTROY_SEMAPHORE:
    // DESTROY_SEMAPHORE | owner    | other (== !owner)
    // ------------------+----------+-----------
    // not set           | delete   | ignore
    // != 0              | delete   | delete
    // 0                 | ignore   | ignore
    sem_data_t data;
    data.sem = sem;

    sem_set_owner(data, owner);
    sem_set_deletable(data, (!destroyKWPresent && owner) || (destroy != 0));
    sem_set_locked(data, false);

    sem_add(name, data);

    return new DIntGDL(1);
  }
开发者ID:ezhangle,项目名称:GNU-Data-Language-0.9.6,代码行数:60,代码来源:semshm.cpp

示例4: grib_get_size_fun

  BaseGDL* grib_get_size_fun(EnvT* e)
  {
#ifndef USE_GRIB
    e->Throw("GDL was compiled without support for GRIB");
    return NULL;
#else
    {
      SizeT nParam = e->NParam(2);
    }

    DLong gribid;
    e->AssureScalarPar<DLongGDL>(0, gribid);

    if (GribHandleList.find(gribid) == GribHandleList.end()) e->Throw("unrecognized message id: " + i2s(gribid));

    DString key;
    e->AssureScalarPar<DStringGDL>(1, key);

    size_t size;
    int err = GRIB_SUCCESS;
    if (GRIB_SUCCESS != (err = grib_get_size(GribHandleList[gribid], key.c_str(), &size)))
      e->Throw("failed to get size of: " + key + "\n%   GRIB API message: " + grib_get_error_message(err)); 

    return new DLongGDL(size);
#endif
  }
开发者ID:cenit,项目名称:GDL,代码行数:26,代码来源:grib.cpp

示例5: GetDataManipulatr

void ObjFileEditDialog::OnChangeLocator(wxCommandEvent &e)
{
	if(NULL == m_pLocatorNameComboBox
	|| NULL == GetDataManipulatr())

	 return;

	Fairy::CGod* pModel = GetDataManipulatr()->FindModel(GetDataManipulatr()->m_CurModelName);

	if(NULL == pModel)
		return;

	DString locatorname			  = m_pLocatorNameComboBox->GetStringSelection().c_str();

	if(locatorname.empty())
		locatorname			      = m_pLocatorNameComboBox->GetValue().c_str();

	if(locatorname.empty())
		return;

	std::vector<Ogre::String> locatorvec = Ogre::StringUtil::split(locatorname,"\\");

	if(locatorvec.size() < 2)
		return;

	const DString bone			  = locatorvec[0];

	const DString locator		  = locatorvec[1];

	pModel->UpdateLocatorPosAndOriData(locator);
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:31,代码来源:ObjFileEditDlg.cpp

示例6: parseAddress

	sockaddr_in DSocket::parseAddress( const DString& addr, uint16 port )
	{
		sockaddr_in ret;
		std::memset(&ret, 0, sizeof(ret));

		if (addr.empty())
		{
			ret.sin_addr.s_addr = htonl(INADDR_ANY);
		}
		else
		{
			ret.sin_addr.s_addr = inet_addr(addr.c_str());
		}

		if (INADDR_NONE == ret.sin_addr.s_addr)
		{
			hostent* pHostEnt = gethostbyname(addr.c_str());
			if (pHostEnt != NULL)
			{
				std::memcpy(&ret.sin_addr.s_addr,
					pHostEnt->h_addr_list[0], pHostEnt->h_length);
			}
			else
			{
				DUEL_EXCEPT_BRIEF(DException::ET_InvalidParameters,
					"Invalid address: " + addr,
					"Duel::DSocket::parseAddress");	
			}
		}

		ret.sin_family = AF_INET;
		ret.sin_port = htons(port);

		return ret;
	}
开发者ID:jiazhipeng03,项目名称:Duel-Engine,代码行数:35,代码来源:DuelSocket.cpp

示例7: sendPacket

int DServerSock::sendPacket ( int hSock, const DString & packet, bool checkSock )
{
	ssize_t numberChar;
	fd_set stFdSet;
	struct timeval stTime;
	DString buffer;
	long int timeout;

	if ( checkSock )
	{
		// check if socket is opened
		timeout = m_timeout;
		setTimeout ( 10 );
		m_status = readMessage ( hSock, buffer );
		setTimeout ( timeout );
	}

	if ( m_hSocket < 0 || m_status == NO_SOCKET )
	{
		m_status = NO_SOCKET;
		m_lastError = "No opened socket found";
		return m_status;
	}
	FD_ZERO ( &stFdSet );
	FD_SET ( hSock, &stFdSet );
	stTime.tv_sec = m_timeout;
	stTime.tv_usec = 0;

	if (m_debug)
	{
		printMessage(packet);
	}
	// Check if data can be sent without any blocking
	if ( ( select ( hSock+1, NULL, &stFdSet, NULL, &stTime ) != -1 ) &&
			  ( FD_ISSET ( hSock, &stFdSet ) ) )
	{
		numberChar = send ( hSock, packet.c_str(), packet.length(), 0 );
		if ( numberChar == static_cast<ssize_t> ( packet.length() ) )
		{
			m_lastError = "";
			m_status = SUCCESS;
		}
		else
		{
			m_lastError = "No data sent, ";
			m_lastError =  + strerror ( errno );
			m_status = NO_SEND;
		}
	}
	else
	{
		m_lastError = "No data sent, ";
		m_lastError =  + strerror ( errno );
		m_status = NO_SEND;
	}
	return m_status;
}
开发者ID:didier13150,项目名称:dlibs,代码行数:57,代码来源:dsocket.cpp

示例8: sem_create

  BaseGDL* sem_create(EnvT *e)
  {
    SizeT nParam = e->NParam(1); // 1 is the minimal number of parameter required

    DString name;
    e->AssureStringScalarPar(0, name); // IDL accepts null-string name

    int destroyIx = e->KeywordIx("DESTROY_SEMAPHORE");
    bool destroyKWPresent = e->KeywordPresent(destroyIx);
    DLong destroy = 0;
    if (destroyKWPresent) 
    {
      destroy = (*e->GetKWAs<DLongGDL>(0))[0];
    }

    bool owner = true;
#ifdef _MSC_VER
    HANDLE sem = CreateSemaphore(NULL,1,1,name.c_str());
    if (sem == NULL) {
	owner = false;
	return new DIntGDL(0);
    }
#else
    sem_t *sem = sem_open(name.c_str(), O_CREAT | O_EXCL, 0666, 1);
    if (sem == SEM_FAILED)
    {
      owner = false;
      if (errno == EEXIST)
      {
        sem = sem_open(name.c_str(), 0);
      }
      if (sem == SEM_FAILED)
      {
        return new DIntGDL(0);
      }
    }
#endif

    // Behavior for different values of DESTROY_SEMAPHORE:
    // DESTROY_SEMAPHORE | owner    | other (== !owner)
    // ------------------+----------+-----------
    // not set           | delete   | ignore
    // != 0              | delete   | delete
    // 0                 | ignore   | ignore
    sem_data_t data;
    data.sem = sem;

    sem_set_owner(data, owner);
    sem_set_deletable(data, (!destroyKWPresent && owner) || (destroy != 0));
    sem_set_locked(data, false);

    sem_add(name, data);

    return new DIntGDL(1);
  }
开发者ID:vedraiyani,项目名称:GDL,代码行数:55,代码来源:semshm.cpp

示例9:

DString cadence::operator+(DString m, const DString &str) {
	int s = m.size();
	int s2 = str.size();

	for (int i=0; i<s2; i++) {
		m.m_obj[s+i].set(str.m_obj.get(i), true);
	}

	m.m_obj[Size].set(s+s2);

	return m;
}
开发者ID:knicos,项目名称:Cadence,代码行数:12,代码来源:dstring.cpp

示例10: printMessage

void DSock::printMessage(DString message)
{
	DString buffer;
	std::ofstream file;
	
	if (m_debug)
	{
		buffer = message.replaceEscapeSequence();
	}
	if ( ( m_debug & DEBUG_STDOUT ) == DEBUG_STDOUT )
	{
		std::cout << buffer << std::endl;
	}
	if ( ( m_debug & DEBUG_FILE ) == DEBUG_FILE )
	{
		if (!m_debugfile.isEmpty())
		{
			file.open(m_debugfile.c_str(), std::ios::out |  std::ios::app);
			if (file)
			{
				file << buffer << std::endl;
				file.close();
			}
		}
	}
}
开发者ID:didier13150,项目名称:dlibs,代码行数:26,代码来源:dsocket.cpp

示例11: strCopy

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// PBook::StripOpcode:
//    Strips the specified opcode from every position in the book.
//    Only the first occurrence of an opcode is removed for any position,
//    but opcodes are not supposed to occur more than once anyway.
//    Returns the number of positions where an opcode was removed.
uint
PBook::StripOpcode (const char * opcode)
{
    char * searchCode = new char [strLength(opcode) + 2];
    strCopy (searchCode, opcode);
    strAppend (searchCode, " ");
    DString dstr;
    uint countFound = 0;

    for (uint i=0; i < NodeListCount; i++) {
        bookNodeT * node = NodeList[i];
        if (node == NULL) { continue; }
        const char * s = node->data.comment;
        int startIndex = -1;
        int index = 0;
        // Look for a line with a matching opcode:
        while (*s != 0) {
            while (*s == '\n'  ||  *s == ' ') { s++; index++; }
            if (strIsPrefix (searchCode, s)) {
                startIndex = index;
                countFound++;
                break;
            }
            while (*s != 0  &&  *s != '\n') { s++; index++; }
        }
        if (startIndex > -1) {
            s = node->data.comment;
            index = 0;
            // Add all characters before the line to be stripped:
            dstr.Clear();
            while (index < startIndex) {
                dstr.AddChar (s[index]);
                index++;
            }
            // Now find the end of this line:
            s = &(s[startIndex + 1]);
            while (*s != 0  &&  *s != '\n') { s++; }
            if (*s == '\n') { s++; }
            while (*s != 0) { dstr.AddChar (*s);  s++; }

            delete[] node->data.comment;
            node->data.comment = strDuplicate (dstr.Data());
        }
    }
    delete[] searchCode;
    return countFound;
}
开发者ID:ageneau,项目名称:scid,代码行数:53,代码来源:pbook.cpp

示例12: ncdf_groupdef

  BaseGDL* ncdf_groupdef(EnvT* e)
  {
    size_t nParam=e->NParam(2);

    DLong grpid;
    e->AssureLongScalarPar( 0, grpid);

    DString s;
    e->AssureScalarPar<DStringGDL>(1, s);

    int status;
    int new_grpid;

    status=nc_def_grp(grpid, s.c_str(), &new_grpid);
    ncdf_handle_error(e, status,"NCDF_GROUPDEF");

    return new DLongGDL(new_grpid);
  }
开发者ID:cenit,项目名称:GDL,代码行数:18,代码来源:ncdf4_group.cpp

示例13: clear

void Search::readStrGraph(Patterns &patterns,StrGraph &desc) {
    clear();
    map<StrGraph::Node*,Node*> recollect;
    for(StrGraph::node_iter ni = desc.nodes().begin(); ni!=desc.nodes().end(); ++ni) {
        Node *n = create_node(gd<Name>(*ni));
        recollect[*ni] = n;
        SearchStage &stage = gd<SearchStage>(n);
        DString limit = gd<StrAttrs>(*ni).look("limit","50");
        stage.limit = atoi(limit.c_str());
        DString action = gd<StrAttrs>(*ni).look("action","union");
        if(action=="union")
            stage.type = UnionInquiry;
        else if(action=="intersection")
            stage.type = IntersectionInquiry;
        else if(action=="pattern") {
            stage.type = PatternInquiry;
            DString pattern = gd<StrAttrs>(*ni).look("pattern","");
            Patterns::iterator pi = patterns.find(pattern);
            if(pi==patterns.end())
                throw UndefinedPattern(pattern);
            stage.pattern = &pi->second;
        }
        else if(action=="path") {
            stage.type = PathInquiry;
            DString ways = gd<StrAttrs>(*ni)["ways"];
            if(ways=="in")
                stage.goIn = true, stage.goOut = false;
            else if(ways=="both")
                stage.goIn = stage.goOut = true;
            else  // ways=="out" default
                stage.goIn = false, stage.goOut = true;
            stage.firstOnly = gd<StrAttrs>(*ni)["firstonly"]=="true";
            stage.shortest = gd<StrAttrs>(*ni)["shortest"]=="true";
            stage.weightattr = gd<StrAttrs>(*ni).look("weightattr","weight");
        }
        else
            throw UnknownAction(action);
    }
    for(StrGraph::graphedge_iter ei = desc.edges().begin(); ei!=desc.edges().end(); ++ei) {
        Edge *e = create_edge(recollect[(*ei)->tail],recollect[(*ei)->head]).first;
        DString input = gd<StrAttrs>(*ei).look("input","");
        gd<Name>(e) = input;
    }
}
开发者ID:gordonwoodhull,项目名称:dynagraph,代码行数:44,代码来源:Search.cpp

示例14: ncdf_ncidinq

  BaseGDL* ncdf_ncidinq(EnvT* e)
  {
 
    // it is mandatory to have 2 parameters !
    size_t nParam=e->NParam(2);

    // in fact, we can use the "grpid" to check the file format it-self.
    DLong grpid;
    e->AssureLongScalarPar( 0, grpid);

    DString s;
    e->AssureScalarPar<DStringGDL>(1, s);

    // before going further we have to chech the file format, must be NetCDF-4

    int status;
    int fileformat;
    status=nc_inq_format(grpid, &fileformat);
    ncdf_handle_error(e, status,"NCDF_NCIDINQ");

    if (fileformat == NC_FORMAT_CLASSIC) 
      Warning("NCDF_NCIDINQ: NetCDF 3 Classic format found. not OK");
    if (fileformat == NC_FORMAT_64BIT)
      Warning("NCDF_NCIDINQ: NetCDF 3 64-BIT format found. not OK");
    
    if ((fileformat == NC_FORMAT_64BIT) || (fileformat == NC_FORMAT_CLASSIC)) {
      return new DLongGDL(-1);
    }

    int sub_grpid;
    status=nc_inq_ncid(grpid, s.c_str(), &sub_grpid);

    if (status != 0) {
      if (status == -125) {
	Warning("NCDF_NCIDINQ: No group found. (NC_ERROR=-125)");      
	return new DLongGDL(-1);
      } else {
	ncdf_handle_error(e, status,"NCDF_NCIDINQ");
      }
    }
    return new DLongGDL(sub_grpid);

  }
开发者ID:cenit,项目名称:GDL,代码行数:43,代码来源:ncdf4_group.cpp

示例15: AddStartDir

void CFindOptions::AddStartDir( const DString &startDir )
{
	DString _lowercase = startDir.ToLower();

	for(auto _it : mStartDirVec)
	{
		if(_lowercase.compare(_it.ToLower()) == 0) return;
	}

	mStartDirVec.push_back( startDir );
}
开发者ID:DarkKnight178,项目名称:Finder,代码行数:11,代码来源:CFindOptions.cpp


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