本文整理汇总了C++中FileType类的典型用法代码示例。如果您正苦于以下问题:C++ FileType类的具体用法?C++ FileType怎么用?C++ FileType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool FileType::operator==(const FileType &pFileType) const
{
// Return whether the current item is equal to the given one
return !mMimeType.compare(pFileType.mimeType())
&& !mFileExtension.compare(pFileType.fileExtension());
}
示例2: pf
void ConsoleTools::profile(int loopCount){
clock_t msecs;
// parsers factory
ParserFactory pf(catalogPath);
// Source file text lines store.
TextLinesStore textLinesStore;
textLinesStore.loadFile(inputFileName, inputEncoding, true);
// Base editor to make primary parse
BaseEditor baseEditor(&pf, &textLinesStore);
// HRD RegionMapper linking
baseEditor.setRegionMapper(&DString("console"), hrdName);
FileType *type = selectType(pf.getHRCParser(), &textLinesStore);
type->getBaseScheme();
baseEditor.setFileType(type);
msecs = clock();
while(loopCount--){
baseEditor.modifyLineEvent(0);
baseEditor.lineCountEvent(textLinesStore.getLineCount());
baseEditor.validate(-1, false);
}
msecs = clock() - msecs;
printf("%ld\n", (msecs*1000)/CLOCKS_PER_SEC );
}
示例3: AddFile
bool FileGroup::AddFile(const FileType &NewFile)
// Never will there be duplicate files within a FileGroup...
// It is just not gonna be allowed by definition.
{
if (NewFile.IsValid())
{
if (!binary_search(myFiles.begin(), myFiles.end(), NewFile))
{
myFiles.insert(lower_bound(myFiles.begin(), myFiles.end(), NewFile),
NewFile);
}
else
{
// If the filenames are the same, then check to see which one is bigger (filesize-wise)
// and keep that one.
FileIter FileIter = lower_bound(myFiles.begin(), myFiles.end(), NewFile);
if (NewFile.GiveFileSize() > FileIter->GiveFileSize())
{
// The NewFile's filesize is larger than the one I already have. Replace it!
*FileIter = NewFile;
}
}
return(true);
}
else
{
return(false);
}
}
示例4: StreamWriter
void ConsoleTools::listTypes(bool load, bool useNames){
Writer *writer = null;
try{
writer = new StreamWriter(stdout, outputEncodingIndex, bomOutput);
ParserFactory pf(catalogPath);
HRCParser *hrcParser = pf.getHRCParser();
fprintf(stderr, "\nloading file types...\n");
for(int idx = 0;; idx++){
FileType *type = hrcParser->enumerateFileTypes(idx);
if (type == null) break;
if (useNames){
writer->write(StringBuffer(type->getName())+"\n");
}else{
if (type->getGroup() != null){
writer->write(StringBuffer(type->getGroup()) + ": ");
}
writer->write(type->getDescription());
writer->write(DString("\n"));
}
if (load) type->getBaseScheme();
}
delete writer;
}catch(Exception &e){
delete writer;
fprintf(stderr, "%s\n", e.getMessage()->getChars());
}
}
示例5: DString
FileType *ColorerFilter::selectType(HRCParser *hrcParser, String *fline)
{
FileType *type = null;
if (typeDescription != null) {
type = hrcParser->getFileType(typeDescription);
if (type == null) {
for(int idx = 0;; idx++)
{
type = hrcParser->enumerateFileTypes(idx);
if (type == null) {
break;
}
if (type->getDescription() != null &&
type->getDescription()->length() >= typeDescription->length() &&
DString(type->getDescription(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) {
break;
}
if (type->getName()->length() >= typeDescription->length() &&
DString(type->getName(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) {
break;
}
type = null;
}
}
}
if (typeDescription == null || type == null) {
type = hrcParser->chooseFileType(inputFileName, fline, 0);
}
return type;
}
示例6: DString
FileType *ConsoleTools::selectType(HRCParser *hrcParser, LineSource *lineSource){
FileType *type = null;
if (typeDescription != null){
type = hrcParser->getFileType(typeDescription);
if (type == null){
for(int idx = 0;; idx++){
type = hrcParser->enumerateFileTypes(idx);
if (type == null) break;
if (type->getDescription() != null &&
type->getDescription()->length() >= typeDescription->length() &&
DString(type->getDescription(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription))
break;
if (type->getName()->length() >= typeDescription->length() &&
DString(type->getName(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription))
break;
type = null;
}
}
}
if (typeDescription == null || type == null){
StringBuffer textStart;
int totalLength = 0;
for(int i = 0; i < 4; i++){
String *iLine = lineSource->getLine(i);
if (iLine == null) break;
textStart.append(iLine);
textStart.append(DString("\n"));
totalLength += iLine->length();
if (totalLength > 500) break;
}
type = hrcParser->chooseFileType(inputFileName, &textStart, 0);
}
return type;
}
示例7: dsd
FileType *BaseEditor::chooseFileType(const String *fileName)
{
if (lineSource == null)
{
currentFileType = hrcParser->chooseFileType(fileName, null);
}
else
{
int chooseStr=CHOOSE_STR, chooseLen=CHOOSE_LEN;
DString dsd("default");
FileType *def = hrcParser->getFileType(&dsd);
if(def)
{
chooseStr = def->getParamValueInt(DString("firstlines"), chooseStr);
chooseLen = def->getParamValueInt(DString("firstlinebytes"), chooseLen);
}
currentFileType = chooseFileTypeCh(fileName, chooseStr, chooseLen);
}
setFileType(currentFileType);
return currentFileType;
}
示例8: loadInitialMaps_
void loadInitialMaps_(vector<MapType>& maps, StringList& ins,
FileType& input_file)
{
// custom progress logger for this task:
ProgressLogger progresslogger;
progresslogger.setLogType(TOPPMapAlignerBase::log_type_);
progresslogger.startProgress(0, ins.size(), "loading input files");
for (Size i = 0; i < ins.size(); ++i)
{
progresslogger.setProgress(i);
input_file.load(ins[i], maps[i]);
}
progresslogger.endProgress();
}
示例9: switch
bool FileInfo::IsImageFile(FileType fileType)
{
switch(fileType.ToInt())
{
case FileType::jpeg.IntValue:
case FileType::png.IntValue:
case FileType::pvr.IntValue:
case FileType::gif.IntValue:
return true;
default:
return false;
}
}
示例10: storeTransformedMaps_
void storeTransformedMaps_(vector<MapType>& maps, StringList& outs,
FileType& output_file)
{
// custom progress logger for this task:
ProgressLogger progresslogger;
progresslogger.setLogType(log_type_);
progresslogger.startProgress(0, outs.size(), "writing output files");
for (Size i = 0; i < outs.size(); ++i)
{
progresslogger.setProgress(i);
// annotate output with data processing info:
addDataProcessing_(maps[i],
getProcessingInfo_(DataProcessing::ALIGNMENT));
output_file.store(outs[i], maps[i]);
}
progresslogger.endProgress();
}
示例11: sizeof
template<class FileType> void ZMO::init(FileType& file) {
char buf[0x10] = { 0x00 };
file.readStringWithGivenLength(8, buf);
if (_stricmp("ZMO0002", buf))
return;
this->animationInfo.framesPerSecond = static_cast<word_t>(file.read<dword_t>());
this->animationInfo.framesInTotal = static_cast<word_t>(file.read<dword_t>())+1;
this->animationInfo.defaultTime = static_cast<word_t>(static_cast<float>(this->animationInfo.framesInTotal) / static_cast<float>(this->animationInfo.framesPerSecond) * 1000);
//last 4 bytes are the ZMO-version type (e.g. 3ZMO)
//The previous 10 bytes: an offset or anything of the sorts seems to be hiddin in there.
file.setPosition(file.getTotalSize() - 14 - sizeof(word_t)*this->animationInfo.framesInTotal);
#ifdef __ROSE_ZMO_OUTPUT__
std::cout << "[" << this->filePath.c_str() << "] Total time: " << this->animationInfo.defaultTime << "\n";
#endif
word_t *newContent = new word_t[this->animationInfo.framesInTotal];
for (unsigned int i = 0; i < this->animationInfo.framesInTotal; i++) {
word_t currentType = file.read<word_t>();
newContent[i] = currentType;
if (i > 0 && (currentType >= 21 && currentType <= 29)) { //Dunno what this means, but it seems to be a valid indicator?
/* current frame - 3, because the server may need up to 100ms to perform the actual action.
(3 * (1000ms / 30FPS) = 100ms -> the offset we need.
*/
float percentage = static_cast<float>(i-3) / static_cast<float>(this->animationInfo.framesInTotal);
ZMO::TimingInfo::Frame newFrame;
dword_t storedPosition = file.getPosition();
file.setPosition(storedPosition - sizeof(word_t)*3);
newFrame.motionType = file.read<word_t>();
file.setPosition(storedPosition);
newFrame.timeToReach = static_cast<word_t>(percentage * this->animationInfo.defaultTime);
this->timingInfo.attacksAtFrames.insert(std::pair<word_t, ZMO::TimingInfo::Frame>(i - 3, newFrame));
#ifdef __ROSE_ZMO_OUTPUT__
auto it = this->timingInfo.attacksAtFrames.at(i - 3);
std::cout << "Found attackPattern at " << percentage * 100.0f << "%\t| " << it.timeToReach << "ms\n";
#endif
}
}
this->content.init(newContent, this->animationInfo.framesInTotal);
delete[] newContent;
newContent = nullptr;
this->animationInfo.framesInTotal--;
#ifdef __ROSE_ZMO_OUTPUT__
std::cout << "\n";
#endif
}
示例12: MIKTEX_ASSERT_STRING
void
SessionImpl::RegisterFileType (/*[in]*/ FileType fileType,
/*[in]*/ const char * lpszFileType,
/*[in]*/ const char * lpszApplication,
/*[in]*/ const char * lpszFileNameExtensions,
/*[in]*/ const char * lpszAlternateExtensions,
/*[in]*/ const char * lpszDefaultSearchPath,
/*[in]*/ const char * lpszEnvVarNames)
{
MIKTEX_ASSERT_STRING (lpszFileType);
MIKTEX_ASSERT_STRING_OR_NIL (lpszApplication);
InternalFileTypeInfo fti;
fti.fileType = fileType;
fti.fileTypeString = lpszFileType;
if (lpszApplication != 0)
{
fti.applicationName = lpszApplication;
}
string section = "ft.";
section += lpszFileType;
fti.fileNameExtensions =
GetConfigValue(section.c_str(),
"extensions",
lpszFileNameExtensions );
fti.alternateExtensions = GetConfigValue(section.c_str(),
"alternate_extensions",
lpszAlternateExtensions == 0 ? "" : lpszAlternateExtensions);
fti.searchPath =
GetConfigValue(section.c_str(),
"path",
lpszDefaultSearchPath);
fti.envVarNames =
GetConfigValue(section.c_str(),
"env",
lpszEnvVarNames);
fileTypes.resize (FileType::E_N_D);
fileTypes[fileType.Get()] = fti;
}
示例13: addType
void NewFileChooser::setFileTypes(QPtrList<FileType> filetypes) {
for(FileType * filetype = filetypes.first();
filetype;
filetype=filetypes.next()) {
if (filetype->enabled()) {
if (filetype->subtypes().count()==0)
addType(filetype);
QPtrList<FileType> subtypes = filetype->subtypes();
for(FileType * subtype = subtypes.first();
subtype;
subtype=subtypes.next()) {
if (subtype->enabled())
addType(subtype);
}
}
}
}
示例14: reloadTypeSettings
void FarEditor::reloadTypeSettings()
{
FileType *ftype = baseEditor->getFileType();
HRCParser *hrcParser = parserFactory->getHRCParser();
FileType *def = hrcParser->getFileType(&DString("default"));
if (def == null){
throw Exception(DString("No 'default' file type found"));
}
int backparse = 2000;
UnicodeTools::getNumber(def->getParamValue(DString("backparse")), &backparse);
UnicodeTools::getNumber(def->getParamValue(DString("maxlinelength")), &maxLineLength);
UnicodeTools::getNumber(def->getParamValue(DString("default-fore")), &newfore);
UnicodeTools::getNumber(def->getParamValue(DString("default-back")), &newback);
const String *value;
value = def->getParamValue(DString("fullback"));
if (value != null && value->equals("no")) fullBackground = false;
value = def->getParamValue(DString("show-cross"));
if (value != null && value->equals("none")){
showHorizontalCross = false;
showVerticalCross = false;
};
if (value != null && value->equals("vertical")){
showHorizontalCross = false;
showVerticalCross = true;
};
if (value != null && value->equals("horizontal")){
showHorizontalCross = true;
showVerticalCross = false;
};
if (value != null && value->equals("both")){
showHorizontalCross = true;
showVerticalCross = true;
};
value = def->getParamValue(DString("cross-zorder"));
if (value != null && value->equals("top")) crossZOrder = 1;
// installs custom file properties
UnicodeTools::getNumber(ftype->getParamValue(DString("backparse")), &backparse);
UnicodeTools::getNumber(ftype->getParamValue(DString("maxlinelength")), &maxLineLength);
UnicodeTools::getNumber(ftype->getParamValue(DString("default-fore")), &newfore);
UnicodeTools::getNumber(ftype->getParamValue(DString("default-back")), &newback);
value = ftype->getParamValue(DString("fullback"));
if (value != null && value->equals("no")) fullBackground = false;
value = ftype->getParamValue(DString("show-cross"));
if (value != null && value->equals("none")){
showHorizontalCross = false;
showVerticalCross = false;
};
if (value != null && value->equals("vertical")){
showHorizontalCross = false;
showVerticalCross = true;
};
if (value != null && value->equals("horizontal")){
showHorizontalCross = true;
showVerticalCross = false;
};
if (value != null && value->equals("both")){
showHorizontalCross = true;
showVerticalCross = true;
};
value = ftype->getParamValue(DString("cross-zorder"));
if (value != null && value->equals("top")) crossZOrder = 1;
baseEditor->setBackParse(backparse);
}
示例15: switch
bool
SessionImpl::TryCreateFile (/*[in]*/ const char * lpszFileName,
/*[in]*/ FileType fileType)
{
CommandLineBuilder commandLine;
PathName makeUtility;
char szBasename[BufferSizes::MaxPath];
PathName::Split (lpszFileName, 0, 0, szBasename, BufferSizes::MaxPath, 0, 0);
switch (fileType.Get())
{
case FileType::BASE:
case FileType::FMT:
if (! FindFile(MIKTEX_INITEXMF_EXE, FileType::EXE, makeUtility))
{
FATAL_MIKTEX_ERROR ("SessionImpl::TryCreateFile",
T_("The MiKTeX configuration utility could not be found."),
0);
}
commandLine.AppendOption ("--dump-by-name=", szBasename);
if (fileType == FileType::FMT)
{
commandLine.AppendOption ("--engine=", GetEngine());
}
break;
case FileType::TFM:
if (! FindFile(MIKTEX_MAKETFM_EXE, FileType::EXE, makeUtility))
{
FATAL_MIKTEX_ERROR ("SessionImpl::TryCreateFile",
T_("The MakeTFM utility could not be found."),
0);
}
commandLine.AppendOption ("-v");
commandLine.AppendArgument (szBasename);
break;
default:
return (false);
}
const size_t BUF_SIZE = 50000;
char * szBuf = reinterpret_cast<char*>(malloc(BUF_SIZE));
if (szBuf == 0)
{
OUT_OF_MEMORY ("malloc");
}
AutoMemoryPointer xxx (szBuf);
size_t size = BUF_SIZE;
int exitCode;
if (! Process::Run(makeUtility,
commandLine.Get(),
szBuf,
&size,
&exitCode))
{
return (false);
}
if (exitCode != 0)
{
TraceError (T_("Make failed; output follows"));
TraceError ("%.*s", static_cast<int>(size), szBuf);
return (false);
}
return (true);
}