bool CCompiler::Compile(LPCTSTR pszFile) { m_strErrMsg.Format("Compile Failed......Unknown Error"); if(false == _Parse(pszFile)) return false; if(false == _Check()) return false; m_oClassMaker.SetInfo(m_nType, m_nCharsetNet, m_nCharsetHost); if(false == m_oClassMaker.Make(&m_oMainParser, &m_oVecChildParsers, m_strHPilePath,m_strCppFilePath)) { m_strErrMsg = m_oClassMaker.GetErrMsg(); return false; } m_strErrMsg.Format("Compile OK"); return true; //if(false == _SavePos()) // return false; //if(false == m_oClassMaker.Init()) // return false; //m_fpCpp = NULL; //m_fpH = NULL; // //if(false == _ProcFileHeader()) // return false; //if(false == _ProcDefines()) // return false; //if(false == _ProcTypes()) // return false; //if(false == _ProcMessages()) // return false; //if(false == m_oClassMaker.MakeEndPart()) // return false; //m_oClassMaker.SaveToHpp(m_fpH); //m_oClassMaker.SaveToCpp(m_fpCpp); // //fprintf(m_fpH, "#endif\n"); //m_strErrMsg.Format("Compile OK"); //_CloseFile(); // //return true; }
bool DirEntryTree::Check() { if (_InitReadOnly() != B_OK) { ERROR("DirEntryTree::Check(): Init failed!\n"); return false; } DirEntryBlock entryBlock(fRootEntryBlock, fRootEntryBlockSize); return _Check(0, fDirectory->BlockIndex(), NULL, 0, entryBlock); }
bool HashBucket<K,V,HashFunc>::Insert(const K &key,const V &value){ _Check(); Node* ret = Find(key); if(ret!=NULL){ //该key值已存在,返回false return false; } size_t index = _HashFunc(key); //计算下标 Node *newNode = new Node(std::make_pair(key,value)); //创建新节点 //头插 newNode->_next = _table[index]; _table[index] = newNode; ++_size; #ifdef __HASHBUCKET_DEBUG__ std::cout<<"["<<index<<"]"<<key<<":"<<value<<std::endl; #endif return true; }
void CIMError::setInstance(const CIMInstance& instance) { for (Uint32 i = 0; i < instance.getPropertyCount(); i++) { CIMConstProperty p = instance.getProperty(i); _Check("ErrorType", p, (Uint16*)0); _Check("OtherErrorType", p, (String*)0); _Check("OwningEntity", p, (String*)0); _Check("MessageID", p, (String*)0); _Check("Message", p, (String*)0); _Check("MessageArguments", p, (Array<String>*)0); _Check("PerceivedSeverity", p, (Uint16*)0); _Check("ProbableCause", p, (Uint16*)0); _Check("ProbableCauseDescription", p, (String*)0); _Check("RecommendedActions", p, (Array<String>*)0); _Check("ErrorSource", p, (String*)0); _Check("ErrorSourceFormat", p, (Uint16*)0); _Check("OtherErrorSourceFormat", p, (String*)0); _Check("CIMStatusCode", p, (Uint32*)0); _Check("CIMStatusCodeDescription", p, (String*)0); } // Verify that the instance contains all of the required properties. for (Uint32 i = 0; i < _numRequiredProperties; i++) { // Does inst have this property? Uint32 pos = instance.findProperty(_requiredProperties[i]); if (pos == PEG_NOT_FOUND) { char buffer[80]; sprintf(buffer, "required property does not exist: %s", _requiredProperties[i]); throw CIMException(CIM_ERR_NO_SUCH_PROPERTY, buffer); } // is required property non-null? CIMConstProperty p = instance.getProperty(pos); CIMValue v = p.getValue(); if (v.isNull()) { char buffer[80]; sprintf(buffer, "required property MUST NOT be Null: %s", _requiredProperties[i]); throw CIMException(CIM_ERR_FAILED, buffer); } } _inst = instance; }
bool DirEntryTree::_Check(int32 level, uint64 blockIndex, const char* key, size_t keyLength, DirEntryBlock& entryBlock) { // check block for validity if (!entryBlock.Check()) { ERROR("DirEntryTree::Check(): level %" B_PRIu32 ": block %" B_PRIu64 " not valid!\n", level, blockIndex); return false; } // The root block is allowed to be empty. For all other blocks that is an // error. uint32 entryCount = entryBlock.EntryCount(); if (entryCount == 0) { if (level == 0) return true; ERROR("DirEntryTree::Check(): level %" B_PRIu32 ": block %" B_PRIu64 " empty!\n", level, blockIndex); return false; } // Verify that the block's first entry matches the key with which the // parent block refers to it. if (level > 0) { size_t nameLength; const char* name = entryBlock.NameAt(0, nameLength); if (nameLength != keyLength || strncmp(name, key, keyLength) != 0) { ERROR("DirEntryTree::Check(): level %" B_PRIu32 ": block %" B_PRIu64 " key mismatch: is \"%.*s\", should be \"%.*s\"\n", level, blockIndex, (int)keyLength, key, (int)nameLength, name); return false; } } if (level == _Depth()) return true; // not the final level -- recurse for (uint32 i = 0; i < entryCount; i++) { size_t nameLength; const char* name = entryBlock.NameAt(i, nameLength); uint64 childBlockIndex = entryBlock.BlockIndexAt(i); Block childBlock; if (!childBlock.GetReadable(fDirectory->GetVolume(), childBlockIndex)) { ERROR("DirEntryTree::Check(): level %" B_PRIu32 ": block %" B_PRIu64 " failed to get child block %" B_PRIu64 " (entry %" B_PRIu32 ")\n", level, blockIndex, childBlockIndex, i); } DirEntryBlock childEntryBlock( (checksumfs_dir_entry_block*)childBlock.Data(), B_PAGE_SIZE); if (!_Check(level + 1, childBlockIndex, name, nameLength, childEntryBlock)) { return false; } } return true; }