//************************************************************************* // Method: SetPaneIsVisible // Description: sets whether or not a pane is visible // // Parameters: // pane - the pane to set the visibility of // isVisible - true to make the pane visible, false otherwise // // Return Value: None //************************************************************************* void DockablePaneManager::SetPaneIsVisible(DockablePane *pane, bool isVisible) { if (!pane) return; ArrayList *list; IEnumerator *enumerator; // check the pane list for the pane list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(pane->Group)); if (list && (list->Count > 0)) { enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *currContent = dynamic_cast<Content *>(enumerator->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (currPane && (currPane->Name->Equals(pane->Name))) { if (isVisible) dockManager->ShowContent(currContent); else dockManager->HideContent(currContent); } } } }
//************************************************************************* // Method: GetIsPaneVisible // Description: gets whether or not a pane is visible // // Parameters: // pane - the pane to set the visibility of // // Return Value: true if the pane is visible, false otherwise //************************************************************************* bool DockablePaneManager::GetIsPaneVisible(DockablePane *pane) { if (!pane) return false; ArrayList *list; IEnumerator *enumerator; // check the pane list for the pane list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(pane->Group)); if (list && (list->Count > 0)) { enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *currContent = dynamic_cast<Content *>(enumerator->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (currPane && (currPane->Name->Equals(pane->Name))) { return currContent->Visible; } } } return false; }
void Dart::Update(int delta) { float distance = sqrt(pow(movementOffset.x, 2) + pow(movementOffset.y, 2)); position->SetPosition(Point(position->x + movementOffset.x / distance * delta * DART_SPEED, position->y + movementOffset.y / distance * delta * DART_SPEED)); ArrayList* zombies = WorldManager::Instance()->GetImagesByNameN(ZOMBIE); IEnumerator* pEnum = zombies->GetEnumeratorN(); Zombie* zombie = null; bool found = false; while (pEnum->MoveNext() == E_SUCCESS && !found) { zombie = (Zombie*)pEnum->GetCurrent(); Point offset = Point(position->x + ressource->GetWidth()/2 - zombie->position->x - zombie->ressource->GetWidth()/2, position->y + ressource->GetHeight()/2 - zombie->position->y - zombie->ressource->GetHeight()/2); float distance = sqrt(pow(offset.x, 2) + pow(offset.y, 2)); if(distance < 50) { Image* bitmapDecoder = new Image(); bitmapDecoder->Construct(); WorldManager::Instance()->AddImage(new KImage(bitmapDecoder->DecodeN(L"/Home/Res/zombie_dead.png", BITMAP_PIXEL_FORMAT_ARGB8888), new Point(*(zombie->position)), ZOMBIE_DEAD)); WorldManager::Instance()->DeleteImage(zombie); WorldManager::Instance()->DeleteImage(this); delete bitmapDecoder; found = true; } } delete pEnum; delete zombies; }
// This internal function adds each file that matches file specification, then does this for each subdirectory if requested void ZipFile::AddFilesToZip(String* FileSpec, String* CurrDirectory, int RootPathLength, Boolean RecurseSubdirectories, PathInclusion AddPathMethod, char* Password) { IEnumerator* filesEnum = Directory::GetFiles(CurrDirectory, FileSpec)->GetEnumerator(); String* fullFileName; String* adjustedFileName; while (filesEnum->MoveNext()) { fullFileName = filesEnum->Current->ToString(); adjustedFileName = GetAdjustedFileName(fullFileName, RootPathLength, AddPathMethod); if (files->Find(adjustedFileName, false)) throw new CompressionException(String::Concat(S"Failed to add file \"", fullFileName, "\" to zip, compressed file with this same name already exists in zip file. Try using \"Update\" instead.")); AddFileToZip(this, NULL, fullFileName, adjustedFileName, Password, S"Add Zip File"); } if (RecurseSubdirectories) { IEnumerator* dirsEnum = Directory::GetDirectories(CurrDirectory, "*")->GetEnumerator(); while (dirsEnum->MoveNext()) AddFilesToZip(FileSpec, dirsEnum->Current->ToString(), RootPathLength, RecurseSubdirectories, AddPathMethod, Password); } }
//************************************************************************* // Method: GetPane // Description: gets a dockable pane based on group and name // // Parameters: // group - the group name of the pane // name - the name of the pane // // Return Value: the pane if found, NULL otherwise //************************************************************************* DockablePane *DockablePaneManager::GetPane(String *group, String *name) { if (!group || !name) return NULL; ArrayList *list; IEnumerator *enumerator; // check the pane list list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(group)); if (list && (list->Count > 0)) { enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *currContent = dynamic_cast<Content *>(enumerator->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (currPane && (currPane->Name->Equals(name))) return currPane; } } // not found, return null return NULL; }
//************************************************************************* // Method: RefreshLayout // Description: refreshes the layout of the pane groups based on positions // // Parameters: // None // // Return Value: None //************************************************************************* void DockablePaneManager::RefreshLayout() { lastVerticalLeftContentAdded = NULL; lastVerticalRightContentAdded = NULL; lastHorizontalTopContentAdded = NULL; lastHorizontalBottomContentAdded = NULL; ArrayList *groupNames = new ArrayList(); IEnumerator *enumerator = groupToContentListTable->Keys->GetEnumerator(); while (enumerator->MoveNext()) { String *group = dynamic_cast<String *>(enumerator->Current); if (!group) continue; groupNames->Add(group); } enumerator = groupNames->GetEnumerator(); while (enumerator->MoveNext()) { String *group = dynamic_cast<String *>(enumerator->Current); if (!group) continue; RefreshLayoutOfGroup(group); } }
result User::updateFromDictionary(HashMap *dictionary) { result success = E_FAILURE; if (dictionary && !dictionary->ContainsKey(kHTTPParamNameError)) { Double *idValue = static_cast<Double *>(dictionary->GetValue(kHTTPParamNameUserID)); if (idValue) { _id = idValue->ToInt(); success = E_SUCCESS; } String *usernameValue = static_cast<String *>(dictionary->GetValue(kHTTPParamNameUsername)); if (usernameValue) { _username = *usernameValue; success = E_SUCCESS; } String *emailValue = static_cast<String *>(dictionary->GetValue(kHTTPParamNameEmail)); if (emailValue) { _email = *emailValue; success = E_SUCCESS; } String *avatarUrlValue = static_cast<String *>(dictionary->GetValue(kHTTPParamNameAvatarUrl)); if (avatarUrlValue) { _avatarUrl = *avatarUrlValue; success = E_SUCCESS; } HashMap *dateDictionary = static_cast<HashMap *>(dictionary->GetValue(kHTTPParamNameDateCreated)); if (dateDictionary) { _dateCreated = new Date(); result dateSuccess = _dateCreated->updateFromDictionary(dateDictionary); if (IsFailed(dateSuccess)) { delete _dateCreated; _dateCreated = NULL; } else { success = E_SUCCESS; } } if (!IsFailed(success)) { if (_listeners) { IEnumerator *iter = _listeners->GetEnumeratorN(); while (iter->MoveNext() == E_SUCCESS) { UserListener *listener = static_cast<UserListener *>(iter->GetCurrent()); listener->onUserUpdate(this); } delete iter; } } } return success; }
//************************************************************************* // Method: get_VisibleColumns // Description: get method of the VisibleColumns property // // Parameters: // None // // Return Value: the visible column headers to get //************************************************************************* ArrayList *ScheduledTestPane::get_VisibleColumns() { ArrayList *returnValue = new ArrayList(); IEnumerator *enumerator = listView->Columns->GetEnumerator(); while (enumerator->MoveNext()) returnValue->Add(enumerator->Current); return returnValue; }
//************************************************************************* // Method: RefreshLayoutOfGroup // Description: refreshes the layout of the panes in a group based on positions // // Parameters: // group - the group to refresh // // Return Value: None //************************************************************************* void DockablePaneManager::RefreshLayoutOfGroup(String *group) { ArrayList *list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(group)); if (!list || list->Count == 0) return; WindowContent *windowContent; // put them in the correct order in a new list ArrayList *orderedList = new ArrayList(); IEnumerator *enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *content = dynamic_cast<Content *>(enumerator->Current); if (!content) continue; DockablePane *pane = dynamic_cast<DockablePane *>(content->Control); if (!pane) continue; windowContent = content->ParentWindowContent; int insertPos = GetInsertPositionForContentList(orderedList, pane); orderedList->Insert(insertPos, content); } // remove all the panes enumerator = orderedList->GetEnumerator(); while (enumerator->MoveNext()) { Content *content = dynamic_cast<Content *>(enumerator->Current); if (!content) continue; if (dockManager->Contents && dockManager->Contents->Contains(content)) dockManager->Contents->Remove(content); list->Remove(content); } groupToContentListTable->Remove(group); // put them back in the right order enumerator = orderedList->GetEnumerator(); while (enumerator->MoveNext()) { Content *content = dynamic_cast<Content *>(enumerator->Current); if (!content) continue; DockablePane *pane = dynamic_cast<DockablePane *>(content->Control); if (!pane) continue; AddPane(pane); } }
void CCppConfigGenerator::TypeCollect( XmlSchema* schema, TypeCollectContext& ctx) { IEnumerator<XmlSchemaElement>* pEnumEle = schema->EnumGlobalElement(); if(pEnumEle) { while(pEnumEle->MoveNext()) { TypeCollect(pEnumEle->Current(), types); } } }
void CTypeCollector::Collect( CXmlSchema* schema, Xsd2CppContext& ctx) { IEnumerator<XmlSchemaElement>* pEnumEle = schema->EnumGlobalElement(); if(pEnumEle) { while(pEnumEle->MoveNext()) { Collect(schema->GetElement(pEnumEle->Current().Name), ctx); } } }
//************************************************************************* // Method: set_Function // Description: Set method for the Function property // // Parameters: // value - the name of the function to set // // Return Value: None //************************************************************************* void TestOutParamSelectionPage::set_Function(String *value) { this->function = value; if (!function) return; InterceptedFunctionDB *db; if (function->IndexOf('.') != -1) db = InterceptedFunctionDB::GetInstance(DOT_NET_FUNC_DB_FILE_NAME); else db = InterceptedFunctionDB::GetInstance(FUNCTION_DB_FILE_NAME); if (!db) return; InterceptedFunction *f = db->GetFunctionByName(function); if (!f) { //may have been stripped of A/W so add it back on. f = db->GetFunctionByName(String::Concat(function, "A")); if (!f) return; } paramListView->Items->Clear(); IEnumerator *enumerator = f->Parameters->GetEnumerator(); while (enumerator->MoveNext()) { InterceptedFunctionParameter *param = dynamic_cast<InterceptedFunctionParameter *>(enumerator->Current); if (!param) continue; // make sure this is an out or in out parameter if ((param->Access) && ( (param->Access->ToUpper()->IndexOf("OUT") != -1) || (param->Access->ToUpper()->IndexOf("NONE") != -1)) ) { ListViewItem *newItem = new ListViewItem(); newItem->Text = param->ID.ToString(); newItem->SubItems->Add(param->Name); newItem->SubItems->Add(OUT_PARAM_NO_CHANGE_STRING); paramListView->Items->Add(newItem); } } if (paramListView->Items->Count > 0) paramListView->Items->get_Item(0)->Selected = true; }
v8::Handle<v8::Value> Contacts::isExistCategory(const v8::Arguments& args) { AppLogTag("Contacts", "Entered Contacts::isExistCategory (args: length:%d)", args.Length()); if (args.Length() < 1 || Util::isArgumentNull(args[0])) { AppLog("Bad parameters"); return v8::ThrowException(v8::String::New("Bad parameters")); } String name = null; v8::HandleScope scope; if(args[0]->IsString()) { name = UNWRAP_STRING(args[0]).c_str(); AppLogTag("Contacts","check Category:%ls", name.GetPointer()); } if(name == null) { AppLogTag("Contacts","category name is null"); return scope.Close(v8::Boolean::New(false)); } AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance(); Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID); IList* pCategoryList = pAddressbook->GetAllCategoriesN(); result r = GetLastResult(); if (IsFailed(r)) { AppLog("Failed to get addressbook: %s", GetErrorMessage(r)); return scope.Close(v8::Boolean::New(false)); } if (pCategoryList != null && pCategoryList->GetCount() > 0) { IEnumerator* pCategoryEnum = pCategoryList->GetEnumeratorN(); Category* pCategory = null; while (pCategoryEnum->MoveNext() == E_SUCCESS) { pCategory = static_cast<Category*>(pCategoryEnum->GetCurrent()); if (pCategory->GetName().Equals(name)) { AppLog("It is existed category"); return scope.Close(v8::Boolean::New(true)); } } } AppLog("Non-exist category"); return scope.Close(v8::Boolean::New(false)); }
// Removes specified files from zip void ZipFile::Remove(String* FileSpec, Boolean RecurseSubdirectories) { ZipFile* tempZipFile; OpenFileForUnzip(); // Just wrapping in a try/catch/finally to make sure temp zip file gets removed try { Regex* filePattern = GetFilePatternRegularExpression(FileSpec, caseSensitive); IEnumerator* filesEnum = files->GetEnumerator(); CompressedFile* file; // Create temporary zip file to hold remove results tempZipFile = CreateTempZipFile(); // Loop through compressed file collection while (filesEnum->MoveNext()) { file = static_cast<CompressedFile*>(filesEnum->Current); // We copy all files into destination zip file except those user requested to be removed... if (!filePattern->IsMatch(GetSearchFileName(FileSpec, file->get_FileName(), RecurseSubdirectories))) CopyFileInZip(file, this, tempZipFile, S"Remove Zip File"); } // Now make the temp file the new zip file Close(); tempZipFile->Close(); File::Delete(fileName); File::Move(tempZipFile->fileName, fileName); } catch (CompressionException* ex) { // We just rethrow any errors back to user throw ex; } catch (Exception* ex) { throw ex; } __finally { // If everything went well, temp zip will no longer exist, but just in case we tidy up and delete the temp file... DeleteTempZipFile(tempZipFile); } // We'll reload the file list after remove if requested... if (autoRefresh) Refresh(); }
tstring StringSplice(IEnumerator<tstring>& source, tstring connecter) { tstring result; if(source.MoveNext()) { result = source.Current(); while(source.MoveNext()) { result += connecter; result += source.Current(); } } return result; }
//************************************************************************* // Method: set_Parameters // Description: set method of the Parameters property // // Parameters: // value - the parameters to set // // Return Value: None //************************************************************************* void TestOutParamSelectionPage::set_Parameters(ArrayList *value) { paramListView->Items->Clear(); IEnumerator *enumerator = value->GetEnumerator(); while (enumerator->MoveNext()) { InterceptedFunctionParameter *param = dynamic_cast<InterceptedFunctionParameter *>(enumerator->Current); if (!param) continue; ListViewItem *item = new ListViewItem(param->ID.ToString()); item->SubItems->Add(param->Name); item->SubItems->Add(param->ChangeValue); paramListView->Items->Add(item); } }
v8::Handle<v8::Value> Contacts::removeCategory(const v8::Arguments& args) { AppLog("Entered Contacts::removeCategory (args length:%d)", args.Length()); if (args.Length() < 2 || Util::isArgumentNull(args[0]) || Util::isArgumentNull(args[1])) { AppLog("Bad parameters"); return v8::ThrowException(v8::String::New("Bad parameters")); } v8::HandleScope scope; String category = UNWRAP_STRING(args[0]).c_str(); String force = UNWRAP_STRING(args[1]).c_str(); AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance(); Addressbook* pAddressbook = pAddressbookManager->GetAddressbookN(DEFAULT_ADDRESSBOOK_ID); IList* pCategoryList = pAddressbook->GetAllCategoriesN(); result r = GetLastResult(); if (IsFailed(r)) { AppLog("Failed to get addressbook: %s", GetErrorMessage(r)); return scope.Close(v8::Boolean::New(false)); } if (pCategoryList != null && pCategoryList->GetCount() > 0) { IEnumerator* pCategoryEnum = pCategoryList->GetEnumeratorN(); Category* pCategory = null; while (pCategoryEnum->MoveNext() == E_SUCCESS) { pCategory = static_cast<Category*>(pCategoryEnum->GetCurrent()); if (pCategory->GetName().Equals(category)) { r = pAddressbook->RemoveCategory(*pCategory); if (IsFailed(r)) { AppLog("Fail to remove category: %s", GetErrorMessage(r)); return scope.Close(v8::Boolean::New(false)); } else { AppLog("Succeed to remove category"); break; } } } } return scope.Close(v8::Boolean::New(true)); }
void User::logout() { _id = 0; _fullname = L""; _username = L""; _email = L""; _avatarUrl = L""; _dateCreated = NULL; if (_listeners) { IEnumerator *iter = _listeners->GetEnumeratorN(); while (iter->MoveNext() == E_SUCCESS) { UserListener *listener = static_cast<UserListener *>(iter->GetCurrent()); listener->onUserUpdate(this); } delete iter; } }
//************************************************************************* // Method: get_Parameters // Description: get method of the Parameters property // // Parameters: // None // // Return Value: an array holding interceptedfunctionparameter objects // representing the values in the list view //************************************************************************* ArrayList *TestOutParamSelectionPage::get_Parameters() { ArrayList *returnValue = new ArrayList(); InterceptedFunctionDB *db; if (function->IndexOf('.') != -1) db = InterceptedFunctionDB::GetInstance(DOT_NET_FUNC_DB_FILE_NAME); else db = InterceptedFunctionDB::GetInstance(FUNCTION_DB_FILE_NAME); InterceptedFunction *f = db->GetFunctionByName(function); if (!f) { //may have been stripped of A/W so add it back on. f = db->GetFunctionByName(String::Concat(function, "A")); if (!f) return returnValue; } IEnumerator *enumerator = paramListView->Items->GetEnumerator(); while (enumerator->MoveNext()) { ListViewItem *item = dynamic_cast<ListViewItem *>(enumerator->Current); if (!item) continue; InterceptedFunctionParameter *param = new InterceptedFunctionParameter(); if (!param) continue; param->ID = Int32::Parse(item->Text); param->Name = item->SubItems->get_Item(1)->Text; param->ChangeValue = item->SubItems->get_Item(2)->Text; InterceptedFunctionParameter *dbParam = dynamic_cast<InterceptedFunctionParameter *>(f->Parameters->get_Item(param->ID)); if (dbParam) param->CompareAsType = dbParam->CompareAsType; returnValue->Add(param); } return returnValue; }
Osp::Base::Object* SkyBuilder::Run() { SkyIterator* skyIterator = SkyFactory::getStars(); ArrayList* args = new ArrayList(); args -> Add(*(new Integer(0))); args -> Add(*(new Integer(skyIterator -> GetSize()))); Osp::App::Application::GetInstance() -> SendUserEvent(BUILD_PROGRESS_RANGE_SET, args); AppLog("Setting progress range from 0 to %d", skyIterator -> GetSize()); int counter = 0; bool isVisible = false; Osp::Base::Collection::ArrayList* list; ConstellationComparer* comparer = new ConstellationComparer(); list = new Osp::Base::Collection::ArrayList(); while (skyIterator -> hasNext()) { SkyObject* skyObject = skyIterator -> getNext(); isVisible = skyObject -> Draw(); String constName = skyObject->getConstellation(); constName.Trim(); if (isVisible && (!list -> Contains(constName)) && constName.GetLength()>0) { String* str = new String(constName); list -> Add(*str); } counter++; if (counter%500 == 0) { args = new ArrayList(); args -> Add(*(new Integer(counter))); Osp::App::Application::GetInstance() -> SendUserEvent(BUILD_PROGRESS_SET, args); } } args = new ArrayList(); args -> Add(*(new Integer(skyIterator -> GetSize()))); IEnumerator* e = list->GetEnumeratorN(); while (e->MoveNext()==E_SUCCESS) { AppLog("List have %S", ((String*)e->GetCurrent())->GetPointer()); } list -> Sort(*comparer); SkyCanvas::SetConstellations(list); delete comparer; Osp::App::Application::GetInstance() -> SendUserEvent(BUILD_PROGRESS_DONE, args); return null; }
void CTypeCollector::Collect( XmlSchemaSubitemGroup* group, Xsd2CppContext& ctx) { if(group->Category() != EnumSubitemCategory::sequence) { throw std::exception("when as a schema for config, only sequence support!"); } IEnumerator<XmlSchemaSubitem*>* pEnumItem = group->Subitems.Enum(); if(pEnumItem) { while(pEnumItem->MoveNext()) { if(pEnumItem->Current()->Category() == EnumSubitemCategory::element) { Collect(static_cast<XmlSchemaElement*>(pEnumItem->Current()), ctx); } else if(pEnumItem->Current()->Category() == EnumSubitemCategory::sequence) { Collect(static_cast<XmlSchemaSubitemGroup*>(pEnumItem->Current()), ctx); } else { throw std::exception("when as a schema for config, only sequence and element support!"); } } } }
//************************************************************************* // Method: get_ModifiersString // Description: get method for the ModifiersString property // Returns a combined string of modifiers, both typeModifiers // and calling convention modifiers // // Parameters: // None // // Return Value: a string representing the modifiers of the function //************************************************************************* String *InterceptedFunction::get_ModifiersString() { String *returnValue = ""; int i = 0; IEnumerator *enumerator = this->Modifiers->GetEnumerator(); while (enumerator->MoveNext()) { String *modifier = dynamic_cast<String *>(enumerator->Current); if (!modifier) continue; if (i == 0) returnValue = modifier; else returnValue = String::Concat(returnValue, ", ", modifier); i++; } return returnValue; }
void ProjectGiraffeTab4::updateViews() { AppLog("updating views"); // Remove all views if they exist if (_contentViews) _contentViews->RemoveAll(true); delete _contentViews; if (_contextViews) _contextViews->RemoveAll(true); delete _contextViews; if (_items && _items->GetCount()) { _contentViews = new ArrayList(SingleObjectDeleter); _contentViews->Construct(); _contextViews = new ArrayList(SingleObjectDeleter); _contextViews->Construct(); IEnumerator *iter = _items->GetEnumeratorN(); int width = GetSize().width; while (iter->MoveNext() == E_SUCCESS) { Graffiti *graffiti = static_cast<Graffiti *>(iter->GetCurrent()); if (graffiti) { // Create content view GraffitiCellContentView *contentView = new GraffitiCellContentView(); contentView->Construct(Rectangle(0, 0, width, GetDefaultItemHeight())); contentView->setGraffiti(graffiti); contentView->sizeToFit(); _contentViews->Add((Panel *)contentView); // Create social context view GraffitiCellSocialContextView *socialContextView = new GraffitiCellSocialContextView(); socialContextView->Construct(contentView->GetBounds()); socialContextView->setGraffiti(graffiti); _contextViews->Add((Panel *)socialContextView); } } } else { _contentViews = NULL; _contextViews = NULL; } }
bool CCppConfigGenerator::GenerateCppCodeFromSchema( CXmlSchema* schema, const tstring& path, const tstring name) { if(!schema || schema->ElementCount() <= 0) { return false; } TypeCollectContext ctx(schema); ctx.ProjectName = name; TypeCollect(schema, ctx); GenerateEnumFile(ctx); IEnumerator<XmlSchemaElement>* pEnumEle = schema->EnumGlobalElement(); if(pEnumEle) { while(pEnumEle->MoveNext()) { } } }
void CTypeCollector::Collect( XmlSchemaComplexType* complexType, Xsd2CppContext& ctx) { if(!ctx.TypeMask[complexType->SerialNO]) { ctx.TypeMask[complexType->SerialNO] = true; if(complexType->BaseType != INVALIDXMLSCHEMATYPESN) { throw std::exception("when as a schema for config, type definition don't support inherit!"); } Collect(&complexType->Subitems, ctx); ctx.SortedComplexTypes.push_back(complexType); IEnumerator<XmlSchemaAttribute>* pEnumAttr = new_iterator_enumerator(complexType->Attributes.begin(), complexType->Attributes.end()); if(pEnumAttr) { while(pEnumAttr->MoveNext()) { Collect(const_cast<XmlSchemaAttribute*>(&pEnumAttr->Current()), ctx); } } } }
void CCppConfigGenerator::TypeCollect( XmlSchemaComplexType* complexType, TypeCollectContext& ctx) { if(!ctx.TypeMask[complexType->SerialNO]) { ctx.TypeMask[complexType->SerialNO] = true; if(complexType->BaseType != INVALIDXMLSCHEMATYPESN) { throw std::exception("when as a schema for config, type definition don't support inherit!") } TypeCollect(&complexType->Subitems, ctx); ctx.SortedTypes.push_front(complexType); IEnumerator<XmlSchemaAttribute>* pEnumAttr = new_iterator_enumerator(complexType->Attributes.begin(), complexType->Attributes.end()); if(pEnumAttr) { while(pEnumAttr->MoveNext()) { XmlSchemaSimpleType* simpleType = static_cast<XmlSchemaSimpleType*>(ctx.Schema->GetType(pEnumAttr->Current().Type)); TypeCollect(simpleType); } } }
//************************************************************************* // Method: GetContentForPane // Description: gets the content that contains the specified pane // // Parameters: // pane - the pane to get the content for // // Return Value: the content containing the pane, or NULL if failed //************************************************************************* Content *DockablePaneManager::GetContentForPane(DockablePane *pane) { ArrayList *list; IEnumerator *enumerator; // check the pane list for the pane list = dynamic_cast<ArrayList *>(groupToContentListTable->get_Item(pane->Group)); if (list && (list->Count > 0)) { enumerator = list->GetEnumerator(); while (enumerator->MoveNext()) { Content *currContent = dynamic_cast<Content *>(enumerator->Current); if (!currContent) continue; DockablePane *currPane = dynamic_cast<DockablePane *>(currContent->Control); if (currPane && (currPane == pane)) return currContent; } } return NULL; }
// This internal function copies each file into a temporary zip that matches file specification, then does this for each subdirectory if requested void ZipFile::UpdateFilesInZip(ZipFile* TempZipFile, String* FileSpec, String* CurrDirectory, int RootPathLength, UpdateOption UpdateWhen, Boolean AddNewFiles, Boolean RecurseSubdirectories, PathInclusion AddPathMethod, char* Password) { IEnumerator* filesEnum = Directory::GetFiles(CurrDirectory, FileSpec)->GetEnumerator(); String* fullFileName; String* adjustedFileName; CompressedFile* file; DateTime lastUpdate; bool updateFile; while (filesEnum->MoveNext()) { fullFileName = filesEnum->Current->ToString(); adjustedFileName = GetAdjustedFileName(fullFileName, RootPathLength, AddPathMethod); if (file = files->get_Item(adjustedFileName)) { lastUpdate = File::GetLastWriteTime(fullFileName); switch (UpdateWhen) { case UpdateOption::Never: updateFile = false; break; case UpdateOption::Always: updateFile = true; break; case UpdateOption::ZipFileIsNewer: updateFile = (DateTime::Compare(file->get_FileDateTime(), lastUpdate) > 0); break; case UpdateOption::DiskFileIsNewer: updateFile = (DateTime::Compare(file->get_FileDateTime(), lastUpdate) < 0); break; default: updateFile = false; break; } if (updateFile) { // Need to update compressed file from disk, so we add the it the new temporary archive AddFileToZip(TempZipFile, this, fullFileName, adjustedFileName, Password, S"Update Zip File"); } else { // Otherwise we just copy the compressed file from the original archive CopyFileInZip(file, this, TempZipFile, S"Update Zip File"); } } else if (AddNewFiles) { // This was a new file so we just add it the new zip, if requested... AddFileToZip(TempZipFile, this, fullFileName, adjustedFileName, Password, S"Update Zip File"); } } if (RecurseSubdirectories) { IEnumerator* dirsEnum = Directory::GetDirectories(CurrDirectory, "*")->GetEnumerator(); while (dirsEnum->MoveNext()) UpdateFilesInZip(TempZipFile, FileSpec, dirsEnum->Current->ToString(), RootPathLength, UpdateWhen, AddNewFiles, RecurseSubdirectories, AddPathMethod, Password); } }
// Extracts specified files from zip void ZipFile::Extract(String* FileSpec, String* DestPath, UpdateOption OverwriteWhen, Boolean RecurseSubdirectories, PathInclusion CreatePathMethod) { // Any file spec in destination path will be ignored DestPath = JustPath(DestPath); char* pszPassword = NULL; char* pszFileName = NULL; OpenFileForUnzip(); // Just wrapping in a try/catch/finally to make sure unmanaged code allocations always get released try { Regex* filePattern = GetFilePatternRegularExpression(FileSpec, caseSensitive); IEnumerator* filesEnum = files->GetEnumerator(); CompressedFile* file; String* sourceFileName; String* destFileName; bool writeFile; int err; // Get ANSI password, if one was provided if (password) if (password->get_Length()) pszPassword = StringToCharBuffer(password); // Loop through compressed file collection while (filesEnum->MoveNext()) { file = static_cast<CompressedFile*>(filesEnum->Current); sourceFileName = file->get_FileName(); if (filePattern->IsMatch(GetSearchFileName(FileSpec, sourceFileName, RecurseSubdirectories))) { pszFileName = StringToCharBuffer(sourceFileName); err = unzLocateFile(hUnzipFile, pszFileName, (caseSensitive ? 1 : 2)); free(pszFileName); pszFileName = NULL; // We should find file in zip file if it was in our compressed file collection if (err != Z_OK) throw new CompressionException(String::Concat(S"Extract Zip File Error: Compressed file \"", sourceFileName, "\" cannot be found in zip file!")); // Open compressed file for unzipping if (pszPassword) err = unzOpenCurrentFilePassword(hUnzipFile, pszPassword); else err = unzOpenCurrentFile(hUnzipFile); if (err != Z_OK) throw new CompressionException(S"Extract Zip File", err); // Get full destination file name switch (CreatePathMethod) { case PathInclusion::FullPath: destFileName = sourceFileName; break; case PathInclusion::NoPath: destFileName = String::Concat(DestPath, Path::GetFileName(sourceFileName)); break; case PathInclusion::RelativePath: destFileName = String::Concat(DestPath, sourceFileName); break; } // Make sure destination directory exists Directory::CreateDirectory(JustPath(destFileName)); // See if destination file already exists if (File::Exists(destFileName)) { DateTime lastUpdate = File::GetLastWriteTime(destFileName); switch (OverwriteWhen) { case UpdateOption::Never: writeFile = false; break; case UpdateOption::Always: writeFile = true; break; case UpdateOption::ZipFileIsNewer: writeFile = (DateTime::Compare(file->get_FileDateTime(), lastUpdate) > 0); break; case UpdateOption::DiskFileIsNewer: writeFile = (DateTime::Compare(file->get_FileDateTime(), lastUpdate) < 0); break; default: writeFile = false; break; } } else writeFile = true; if (writeFile) { System::Byte buffer[] = new System::Byte[BufferSize]; System::Byte __pin * destBuff = &buffer[0]; // pin buffer so it can be safely passed into unmanaged code... FileStream* fileStream = File::Create(destFileName); int read; __int64 total = 0, len = -1; // Send initial progress event len = file->get_UncompressedSize(); CurrentFile(destFileName, sourceFileName); FileProgress(0, len); // Read initial buffer read = unzReadCurrentFile(hUnzipFile, destBuff, buffer->get_Length()); if (read < 0) throw new CompressionException(S"Extract Zip File", read); while (read) { // Write data to file stream, fileStream->Write(buffer, 0, read); // Raise progress event total += read; FileProgress(total, len); // Read next buffer from source file stream read = unzReadCurrentFile(hUnzipFile, destBuff, buffer->get_Length()); if (read < 0) throw new CompressionException(S"Extract Zip File", read); } fileStream->Close(); } // Close compressed file unzCloseCurrentFile(hUnzipFile); } } } catch (CompressionException* ex) { // We just rethrow any errors back to user throw ex; } catch (Exception* ex) { throw ex; } __finally { if (pszPassword) free(pszPassword); if (pszFileName) free(pszFileName); } }
v8::Handle<v8::Value> Contacts::list(const v8::Arguments& args) { AppLogTag("Contacts", "Entered Contacts::list (args length:%d)", args.Length()); v8::HandleScope scope; AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance(); IList* pCategoryList = pAddressbookManager->GetAllCategoriesN(); AppLogTag("Contacts", "TEST1"); Category* pCategory = null; Contact* pContact = null; AppLogTag("Contacts", "TEST2"); IEnumerator* pCategoryEnum = pCategoryList->GetEnumeratorN(); v8::Local<v8::Object> categoryObject = v8::Object::New(); while (pCategoryEnum->MoveNext() == E_SUCCESS) { AppLogTag("Contacts", "TEST"); pCategory = static_cast<Category*>(pCategoryEnum->GetCurrent()); char category[STRING_MAX]; IList* pContactList = pAddressbookManager->GetContactsByCategoryN(pCategory->GetRecordId()); IEnumerator* pContactEnum = pContactList->GetEnumeratorN(); v8::Local<v8::Array> personList = v8::Array::New(); AppLogTag("Contacts", "Fetching category: %ls", pCategory->GetName().GetPointer()); int person_cnt = 0; while (pContactEnum->MoveNext() == E_SUCCESS) { pContact = static_cast<Contact*>(pContactEnum->GetCurrent()); String fullName = L"", firstName, lastName; v8::Local<v8::Object> personObject = v8::Object::New(); char buf[STRING_MAX]; pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName); pContact->GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName); fullName.Append(firstName); fullName.Append(L" "); fullName.Append(lastName); AppLogTag("Contacts", "Getting person: %ls", fullName.GetPointer()); IList* pPhoneNumberList = pContact->GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS); v8::Local<v8::Array> phoneList = v8::Array::New(); if (pPhoneNumberList != null) { IEnumerator* pEnum = pPhoneNumberList->GetEnumeratorN(); int number_cnt = 0; while (pEnum->MoveNext() == E_SUCCESS) { PhoneNumber* pPhoneNumber = static_cast<PhoneNumber*>(pEnum->GetCurrent()); String number = pPhoneNumber->GetPhoneNumber(); AppLogTag("Contacts", "Getting person's phonenumber: %ls", number.GetPointer()); phoneList->Set(number_cnt++, v8::String::New(Util::toAnsi(buf, number.GetPointer(), STRING_MAX))); } delete pEnum; pPhoneNumberList->RemoveAll(true); delete pPhoneNumberList; } personObject->Set(v8::String::New("name"), v8::String::New(Util::toAnsi(buf, fullName.GetPointer(), STRING_MAX))); personObject->Set(v8::String::New("phoneNumber"), phoneList); personList->Set(person_cnt++, personObject); } categoryObject->Set(v8::String::New(Util::toAnsi(category, pCategory->GetName(), STRING_MAX)), personList); delete pContactEnum; pContactList->RemoveAll(true); delete pContactList; } return scope.Close(categoryObject); }