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


C++ UnicodeString::SubString方法代码示例

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


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

示例1: getName

UnicodeString getName(UnicodeString str) {
 UnicodeString name = str;

 if (name.Pos(":") > 0)
   name = name.SubString(1, name.Pos(":")-1);
 UnicodeString alphabet = L"QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm1234567890_";

 while (true) {
   if (name.Length() == 0)
     break;
   UnicodeString ch = name.SubString(name.Length(), 1);
   if (alphabet.Pos(ch) > 0 && name.Length() > 0)
     break;
   name = name.SubString(1, name.Length()-1);
 }

 UnicodeString temp_name;
 while (true) {
   if (name.Length() == 0)
     break;
   UnicodeString ch = name.SubString(name.Length(), 1);
   if (alphabet.Pos(ch) > 0 && name.Length() > 0)
     temp_name = ch + temp_name;
   else
     break;
   name = name.SubString(1, name.Length()-1);
 }

 return temp_name;
}
开发者ID:sea-kg,项目名称:seakgChrysocyonParser,代码行数:30,代码来源:main.cpp

示例2: MaskFileName

//---------------------------------------------------------------------------
UnicodeString MaskFileName(const UnicodeString & FileName, const UnicodeString & Mask)
{
  UnicodeString Result = FileName;
  if (IsEffectiveFileNameMask(Mask))
  {
    bool Masked;
    intptr_t P = Mask.LastDelimiter(L".");
    if (P > 0)
    {
      intptr_t P2 = Result.LastDelimiter(".");
      // only dot at beginning of file name is not considered as
      // name/ext separator
      UnicodeString FileExt = P2 > 1 ?
        Result.SubString(P2 + 1, Result.Length() - P2) : UnicodeString();
      FileExt = MaskFilePart(FileExt, Mask.SubString(P + 1, Mask.Length() - P), Masked);
      if (P2 > 1)
      {
        Result.SetLength(P2 - 1);
      }
      Result = MaskFilePart(Result, Mask.SubString(1, P - 1), Masked);
      if (!FileExt.IsEmpty())
      {
        Result += L"." + FileExt;
      }
    }
    else
    {
      Result = MaskFilePart(Result, Mask, Masked);
    }
  }
  return Result;
}
开发者ID:nineclock,项目名称:Far-NetBox,代码行数:33,代码来源:FileMasks.cpp

示例3: Add

void TOptions::Add(const UnicodeString & Value)
{
  if (!FNoMoreSwitches &&
      (Value.Length() == 2) &&
      (Value[1] == Value[2]) &&
      (FSwitchMarks.Pos(Value[1]) > 0))
  {
    FNoMoreSwitches = true;
  }
  else
  {
    bool Switch = false;
    intptr_t Index = 0; // shut up
    if (!FNoMoreSwitches &&
        (Value.Length() >= 2) &&
        (FSwitchMarks.Pos(Value[1]) > 0))
    {
      Index = 2;
      Switch = true;
      while (Switch && (Index <= Value.Length()))
      {
        if (Value.IsDelimiter(FSwitchValueDelimiters, Index))
        {
          break;
        }
        // this is to treat /home/martin as parameter, not as switch
        else if ((Value[Index] != L'?') && !IsLetter(Value[Index]))
        {
          Switch = false;
          break;
        }
        ++Index;
      }
    }

    if (Switch)
    {
      TOption Option;
      Option.Type = otSwitch;
      Option.Name = Value.SubString(2, Index - 2);
      Option.Value = Value.SubString(Index + 1, Value.Length());
      Option.Used = false;
      FOptions.push_back(Option);
    }
    else
    {
      TOption Option;
      Option.Type = otParam;
      Option.Value = Value;
      Option.Used = false;
      FOptions.push_back(Option);
      ++FParamCount;
    }
  }

  FOriginalOptions = FOptions;
}
开发者ID:kocicjelena,项目名称:Far-NetBox,代码行数:57,代码来源:Option.cpp

示例4: ChangeFileExtension

//
// Modifies the Filename's extension. The period is considered part
// of the extension.
//
// "/foo/bar/baz.txt", ".dat" --> "/foo/bar/baz.dat"
// "/foo/bar/baz.txt", "" --> "/foo/bar/baz"
// "/foo/bar/baz", ".txt" --> "/foo/bar/baz.txt"
//
UnicodeString ChangeFileExtension(const UnicodeString & Path, const UnicodeString & Ext, wchar_t Delimiter)
{
  UnicodeString FileName = ExtractFilename(Path, Delimiter);
  return ExtractDirectory(Path, Delimiter)
         + FileName.SubString(1, FileName.RPos(L'.'))
         + Ext;
}
开发者ID:CyberShadow,项目名称:Far-NetBox,代码行数:15,代码来源:Sysutils.cpp

示例5: PrintDoc

void PrintDoc(seakgOutput *pOutput, UnicodeString filename, UnicodeString name, UnicodeString uuid, UnicodeString code) {
  filename = filename.SubString(rootPath.Length()+1, filename.Length() - rootPath.Length());
  UnicodeString id = "";
//  UnicodeString id = "";

  code = encoding_html(code);
  name = encoding_html(name);

  TGUID g;
  OleCheck(CoCreateGuid(&g));
  //Sysutils::GUIDToString(g);
  //id = Sysutils::GUIDToString(g);
  //id = id.SubString(2,37) + "[" + IntToStr(g_nInc++) + "]";

  id = IntToStr(g_nInc++);
  while (id.Length() < 6)
    id = "0" + id;

  id = prefixforid + id;

  pOutput->addline("\t<doc>");
  pOutput->addline("\t\t<field name=\"id\">" + id + "</field>");
  pOutput->addline("\t\t<field name=\"project\">" + projectName + "</field>");
  pOutput->addline("\t\t<field name=\"name\">" + name + "</field>");
  pOutput->addline("\t\t<field name=\"uuid\">" + uuid.UpperCase() + "</field>");
  pOutput->addline("\t\t<field name=\"source_filepath\">" + filename + "</field>");
  pOutput->addline("\t\t<field name=\"full_source_code\">\n" + code + "\n\t\t</field>");
  pOutput->addline("\t</doc>");
};
开发者ID:sea-kg,项目名称:seakgChrysocyonParser,代码行数:29,代码来源:main.cpp

示例6: FileSearch

UnicodeString FileSearch(const UnicodeString & FileName, const UnicodeString & DirectoryList)
{
  UnicodeString Temp;
  UnicodeString Result;
  Temp = DirectoryList;
  UnicodeString PathSeparators = L"/\\";
  do
  {
    intptr_t I = ::Pos(Temp, PathSeparators);
    while ((Temp.Length() > 0) && (I == 0))
    {
      Temp.Delete(1, 1);
      I = ::Pos(Temp, PathSeparators);
    }
    I = ::Pos(Temp, PathSeparators);
    if (I > 0)
    {
      Result = Temp.SubString(1, I - 1);
      Temp.Delete(1, I);
    }
    else
    {
      Result = Temp;
      Temp = L"";
    }
    Result = ::IncludeTrailingBackslash(Result);
    Result = Result + FileName;
    if (!::FileExists(Result))
    {
      Result = L"";
    }
  }
  while (!(Temp.Length() == 0) || (Result.Length() != 0));
  return Result;
}
开发者ID:CyberShadow,项目名称:Far-NetBox,代码行数:35,代码来源:Sysutils.cpp

示例7: SetByString

void __fastcall TResolution::SetByString(UnicodeString ResString)
{
	int pos = Pos(L"x", ResString);
	if (pos == 0) throw EResolutionError(L"Divider not found");
	try {
		this->Width = this->Convert(ResString.SubString(1, pos-1));
	}
	catch (EResolutionError& e) {
		throw EResolutionError(UnicodeString(L"Cannot read width. ") + e.Message);
	}
	try {
		this->Height = this->Convert(ResString.SubString(pos+1, ResString.Length()-pos));
	}
	catch (EResolutionError& e) {
		throw EResolutionError(UnicodeString(L"Cannot read height. ") + e.Message);
	}
}
开发者ID:DesktopUpload,项目名称:DesktopUploader,代码行数:17,代码来源:SrvInfo.cpp

示例8: ScanAndPrint

void ScanAndPrint(seakgOutput *pOutput, UnicodeString fullname) {
  TStringList *list = new TStringList();  
  list->LoadFromFile(fullname);
  int nCount = list->Count;
  for (int i = 0; i < nCount; i++)
  {
    UnicodeString str = list->Strings[i];
	  if (str.Pos(L"class") > 0 && str.Pos("__declspec") > 0) {
      UnicodeString code = str + "\r\n";
      str = str.Trim();

      UnicodeString uuid = "none";
      if (str.Pos("\"") > 0)
        uuid = str.SubString(str.Pos("\"") + 1, 36);

      UnicodeString interfacename = str.SubString(str.Pos("I"), str.Length() - str.Pos("I") + 1);
      UnicodeString interfacename2 = getName(str);
      bool bStop = false;
      int nIncr = 0;
      while (bStop == false && i < nCount) {
        i++;
        str = list->Strings[i];
        if (str.Pos("{") > 0) {
          nIncr++;
        };

        if (str.Pos("}") > 0) {
          nIncr--;
          if(nIncr == 0) bStop = true;
        };

        code += str + "\n";
      };

	  PrintDoc(pOutput, fullname, interfacename2, uuid, code);
//      std::wcout << str.c_str();
    };
  };



  /*std::wcout << "createuuidprojectname: " <<  << "\r\n";
  std::wcout << "projectname: " << projectName.c_str() << "\r\n";
  std::wcout << "fullname: " << fullname.c_str() << "\r\n";*/
};
开发者ID:sea-kg,项目名称:seakgChrysocyonParser,代码行数:45,代码来源:main.cpp

示例9: OpenWinSCPKey

static long OpenWinSCPKey(HKEY Key, const char * SubKey, HKEY * Result, bool CanCreate)
{
  long R;
  assert(GetConfiguration() != nullptr);

  assert(Key == HKEY_CURRENT_USER);
  USEDPARAM(Key);

  UnicodeString RegKey = SubKey;
  UnicodeString OriginalPuttyRegistryStorageKey(_T(PUTTY_REG_POS));
  intptr_t PuttyKeyLen = OriginalPuttyRegistryStorageKey.Length();
  assert(RegKey.SubString(1, PuttyKeyLen) == OriginalPuttyRegistryStorageKey);
  RegKey = RegKey.SubString(PuttyKeyLen + 1, RegKey.Length() - PuttyKeyLen);
  if (!RegKey.IsEmpty())
  {
    assert(RegKey[1] == L'\\');
    RegKey.Delete(1, 1);
  }

  if (RegKey.IsEmpty())
  {
    *Result = static_cast<HKEY>(nullptr);
    R = ERROR_SUCCESS;
  }
  else
  {
    // we expect this to be called only from verify_host_key() or store_host_key()
    assert(RegKey == L"SshHostKeys");

    std::unique_ptr<THierarchicalStorage> Storage(GetConfiguration()->CreateConfigStorage());
    Storage->SetAccessMode((CanCreate ? smReadWrite : smRead));
    if (Storage->OpenSubKey(RegKey, CanCreate))
    {
      *Result = reinterpret_cast<HKEY>(Storage.release());
      R = ERROR_SUCCESS;
    }
    else
    {
      R = ERROR_CANTOPEN;
    }
  }

  return R;
}
开发者ID:valery-barysok,项目名称:Far-NetBox,代码行数:44,代码来源:PuttyIntf.cpp

示例10: OpenWinSCPKey

//---------------------------------------------------------------------------
static long OpenWinSCPKey(HKEY Key, const char * SubKey, HKEY * Result, bool CanCreate)
{
  long R;
  assert(Configuration != NULL);

  assert(Key == HKEY_CURRENT_USER);
  USEDPARAM(Key);

  UnicodeString RegKey = SubKey;
  int PuttyKeyLen = OriginalPuttyRegistryStorageKey.Length();
  assert(RegKey.SubString(1, PuttyKeyLen) == OriginalPuttyRegistryStorageKey);
  RegKey = RegKey.SubString(PuttyKeyLen + 1, RegKey.Length() - PuttyKeyLen);
  if (!RegKey.IsEmpty())
  {
    assert(RegKey[1] == L'\\');
    RegKey.Delete(1, 1);
  }

  if (RegKey.IsEmpty())
  {
    *Result = static_cast<HKEY>(NULL);
    R = ERROR_SUCCESS;
  }
  else
  {
    // we expect this to be called only from verify_host_key() or store_host_key()
    assert(RegKey == L"SshHostKeys");

    THierarchicalStorage * Storage = Configuration->CreateConfigStorage();
    Storage->AccessMode = (CanCreate ? smReadWrite : smRead);
    if (Storage->OpenSubKey(RegKey, CanCreate))
    {
      *Result = reinterpret_cast<HKEY>(Storage);
      R = ERROR_SUCCESS;
    }
    else
    {
      delete Storage;
      R = ERROR_CANTOPEN;
    }
  }

  return R;
}
开发者ID:elazzi,项目名称:winscp,代码行数:45,代码来源:PuttyIntf.cpp

示例11: ExtractFileExtension

//
// Returns the file's extension, if any. The period is considered part
// of the extension.
//
// "/foo/bar/baz.txt" --> ".txt"
// "/foo/bar/baz" --> ""
UnicodeString ExtractFileExtension(const UnicodeString & Path, wchar_t Delimiter)
{
  UnicodeString FileName = ExtractFilename(Path, Delimiter);
  intptr_t N = FileName.RPos(L'.');
  if (N > 0)
  {
    return FileName.SubString(N);
  }
  return UnicodeString();
}
开发者ID:CyberShadow,项目名称:Far-NetBox,代码行数:16,代码来源:Sysutils.cpp

示例12: TrimVersion

//---------------------------------------------------------------------------
UnicodeString TConfiguration::TrimVersion(const UnicodeString & Version) const
{
  UnicodeString Result = Version;
  while ((Result.Pos(L".") != Result.LastDelimiter(L".")) &&
    (Result.SubString(Result.Length() - 1, 2) == L".0"))
  {
    Result.SetLength(Result.Length() - 2);
  }
  return Result;
}
开发者ID:CyberShadow,项目名称:Far-NetBox,代码行数:11,代码来源:Configuration.cpp

示例13: ESrvResponseError

//---------------------------------------------------------------------------
// TSrvResponse
//---------------------------------------------------------------------------
__fastcall TSrvResponse::TSrvResponse(UnicodeString ResponseText)
	: TStringList()
{
	if (ResponseText.IsEmpty()) throw ESrvResponseError(L"Server response is empty.");

	this->Text = ResponseText;
	try {
		this->StatusCode = StrToInt(this->Strings[0]);
	}
	catch (EConvertError& e) {
		throw ESrvResponseError(L"Cannot read status code. "+e.Message);
	}

	this->Delete(0); //Remove status code line

	for (int i = this->Count-1; i >= 0; i--) {
		UnicodeString line = this->Strings[i].Trim();
		int split = line.Pos(L":");
		if (split) {
			this->Strings[i] = line.SubString(1, split-1).Trim() \
			+ L":" \
			+ line.SubString(split+1, line.Length()-split).Trim();
		}
		else {
			this->Delete(i);
		}
	}

	this->NameValueSeparator = ':';

	if (this->StatusCode != 0) {
		if (this->StatusCode < 0) throw ESrvResponseError(L"Negative status code not allowed.");

		this->ErrorMessage = this->ReadString(TSrvResponseValID("ErrorMessage"), L"", true);
		if (this->ErrorMessage.IsEmpty()) this->ErrorMessage = L"Error #"
			+ IntToStr(this->StatusCode)
			+ L" (No error message provided).";
	}
	else { //Find URLs
		this->AvatarURL = this->Values[L"AvatarURL"];
		this->WatermarkURL = this->Values[L"WatermarkURL"];
    }
}
开发者ID:DesktopUpload,项目名称:DesktopUploader,代码行数:46,代码来源:SrvInfo.cpp

示例14: tabelaOpusa

UnicodeString tabelaOpusa(UnicodeString Tabela)
{
    if (Tabela.Pos("clienti_") == 0)
        return "clienti_"+Tabela;
    else
    {
        int pos = Tabela.Pos("_");
        return Tabela.SubString(pos+1, Tabela.Length()-pos);
    }
}
开发者ID:elfumelfu,项目名称:sandbox,代码行数:10,代码来源:tools.cpp

示例15: PatternReplacement

//---------------------------------------------------------------------------
bool TInteractiveCustomCommand::PatternReplacement(const UnicodeString & Pattern,
  UnicodeString & Replacement, bool & Delimit)
{
  bool Result;
  if ((Pattern.Length() >= 3) && (Pattern[2] == L'?'))
  {
    UnicodeString PromptStr;
    intptr_t Pos = Pattern.SubString(3, Pattern.Length() - 2).Pos(L"?");
    if (Pos > 0)
    {
      Replacement = Pattern.SubString(3 + Pos, Pattern.Length() - 3 - Pos);
      if ((Pos > 1) && (Pattern[3 + Pos - 2] == L'\\'))
      {
        Delimit = false;
        Pos--;
      }
      PromptStr = Pattern.SubString(3, Pos - 1);
    }
    else
    {
      PromptStr = Pattern.SubString(3, Pattern.Length() - 3);
    }

    Prompt(PromptStr, Replacement);

    Result = true;
  }
  else if ((Pattern.Length() >= 3) && (Pattern[2] == L'`'))
  {
    UnicodeString Command = Pattern.SubString(3, Pattern.Length() - 3);
    Command = FChildCustomCommand->Complete(Command, true);
    Execute(Command, Replacement);
    Delimit = false;
    Result = true;
  }
  else
  {
    Result = false;
  }

  return Result;
}
开发者ID:nineclock,项目名称:Far-NetBox,代码行数:43,代码来源:FileMasks.cpp


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