// -------- // Strings // -------- void KStrings::SplitString( const KString& String, LPCTSTR pSplitter, bool bAddEmpty, bool bClearFirst) { if(bClearFirst) Clear(); const size_t szSplitterLength = _tcslen(pSplitter); size_t szPos = 0; for(;;) { size_t szOldPos = szPos; szPos = String.Find(pSplitter, szPos); if(szPos == UINT_MAX) { if(bAddEmpty || szOldPos < String.GetLength()) *AddLast() = String.Mid(szOldPos); break; } if(bAddEmpty || szPos > szOldPos) *AddLast() = String.Mid(szOldPos, szPos - szOldPos), szPos += szSplitterLength; } }
Node *create_scene_city_bmap() { // casita3/house01 // casa5/wachhaus // dom/dom Node * aux; list *gObj_list; Node *myNode; static trfm3D TT; gObj_list = CreateVoidList(); AddLast(gObj_list, SceneRegisterGObject( "./obj/casita3/", "house01.obj")); AddLast(gObj_list, SceneRegisterGObject( "./obj/casa5/", "wachhaus.obj")); AddLast(gObj_list, SceneRegisterGObject( "./obj/dom/", "dom.obj")); aux = create_city(500, gObj_list); SetTransTrfm3D(&TT, 0, -5, 00); //SetTransTrfm3D(&TT, 0, 0, 0); myNode = CreateNode("root"); SetTrfmNode(myNode, &TT); //SetShaderNode(myNode, SceneFindShader("pervertex")); SetShaderNode(myNode, SceneFindShader("perfragment")); AttachNodeScene(myNode); AttachNode(myNode, aux); aux = create_floor_city( "./obj/floor/", "cityfloor_grass.obj"); SetShaderNode(aux, SceneFindShader("bump")); AttachNode(myNode, aux); // takes ownership return aux; }
void CreateList(NodeT* root,NodeL*head) { if (root==NULL) AddLast(head,"*"); else { AddLast(head,root->data); CreateList(root->left,head); CreateList(root->right,head); } }
void GStringList::DeSerializeAppend(const char *pzDelimiter, const char *pzSource, int nItemCount/* = -1*/) { if (!pzDelimiter || !pzSource || !pzDelimiter[0] || !pzSource[0]) return; __int64 nSourceLen = strlen(pzSource); __int64 nDelimiterLen = strlen(pzDelimiter); if (!nSourceLen) return; int nAdded = 0; char *beg = (char *)pzSource; char *del = strstr(beg,pzDelimiter); while(1) { if ( !del ) { // there is only one entry in the list if (nItemCount > -1 && nAdded == nItemCount) break; AddLast(beg); nAdded++; break; } if (nItemCount > -1 && nAdded == nItemCount) break; // add this entry AddLast(beg, del - beg); nAdded++; // advance to the next string beg = del + nDelimiterLen; // advance to the next delimiter, break if none del = strstr(beg,pzDelimiter); if ( !del ) { if (nItemCount > -1 && nAdded == nItemCount) break; AddLast(beg); nAdded++; break; } } }
/*********************************************************************************** ** ** TreeViewModel::OnItemAdded ** ***********************************************************************************/ void TreeViewModel::OnItemAdded(OpTreeModel* tree_model, INT32 index) { TreeViewModelItem* item = OP_NEW(TreeViewModelItem, (m_model->GetItemByPosition(index))); if (!item) return; if (GetSortListener()) { INT32 parent = GetIndexByModelIndex(m_model->GetItemParent(index)); if (parent == -1 && GetTreeModelGrouping() && GetTreeModelGrouping()->HasGrouping()) { parent = static_cast<TreeViewModelItem*>(GetTreeModelGrouping()->GetGroupHeader(GetTreeModelGrouping()->GetGroupForItem(item)))->GetIndex(); } AddSorted(item, parent); } else { INT32 parent = m_model->GetItemParent(index); if (index < GetCount() && GetParentIndex(index) == parent) { InsertBefore(item, index); } else { AddLast(item, parent); } } }
/*********************************************************************************** ** ** TreeViewModel::Resort ** ***********************************************************************************/ void TreeViewModel::Resort() { if (!m_model) return; ModelLock lock(this); if (GetSortListener()) { Sort(); } else { m_resorting = TRUE; RemoveAll(); INT32 count = m_model->GetItemCount(); for (INT32 i = 0; i < count; i++) { void *item = NULL; m_hash_table.GetData(m_model->GetItemByPosition(i), &item); OP_ASSERT(item); INT32 parent = m_model->GetItemParent(i); AddLast((TreeViewModelItem*)item, parent); } m_resorting = FALSE; } }
void GStringList::DeSerialize(const char *pzDelimiter, const char *pzSource) { if (!pzDelimiter || !pzSource || !pzDelimiter[0] || !pzSource[0]) return; int nSourceLen = strlen(pzSource); int nDelimiterLen = strlen(pzDelimiter); if (!nSourceLen) return; char *beg = (char *)pzSource; char *del = strstr(beg,pzDelimiter); while(1) { if ( !del ) { // there is only one entry in the list AddLast(beg); break; } // temporarily null on the delimiter char chOld = *del; *del = 0; // add this (now null terminated) entry AddLast(beg); // advance to the next string beg = del + nDelimiterLen; // unnull the previous *del = chOld; // advance to the next delimiter, break if none del = strstr(beg,pzDelimiter); if ( !del ) { AddLast(beg); break; } } }
void Apollo::ValueList::add(int n) { Apollo::ValueElem* e = new Apollo::ValueElem(); if (e != 0) { e->setInt(n); AddLast((Elem*) e); } }
void Apollo::ValueList::add(const ApHandle& h) { Apollo::ValueElem* e = new Apollo::ValueElem(); if (e != 0) { e->setHandle(h); AddLast((Elem*) e); } }
void Apollo::KeyValueList::add(const String& sKey, const String& s) { Apollo::KeyValueElem* e = new Apollo::KeyValueElem(sKey); if (e != 0) { e->setString(s); AddLast((Elem*) e); } }
void Apollo::KeyValueList::add(const String& sKey, const ApHandle& h) { Apollo::KeyValueElem* e = new Apollo::KeyValueElem(sKey); if (e != 0) { e->setHandle(h); AddLast((Elem*) e); } }
NodeT* MatrixToList(int** adjMatrix) { int i,j; for(i=0; i<nrOfVerteces; i++) { printf("%d:",i); for(j=0; j<nrOfVerteces; j++) { if(adjMatrix[i][j]==1) { AddLast(j); printf("%d ",j); } } AddLast(-1);//! adding to the list -1 to mark the end of a line in the adjMatrix printf("\n"); } return L; }
INT32 GroupsModel::AddFolder(const OpStringC& name, const OpStringC& path, BOOL subscribedLocally, INT32 subscribedOnServer, BOOL editable, BOOL manually, BOOL force_create) { // Note that for irc: (will clean up later) // name = topic // path = room name // subscribedOnServer = INT32 number of users BOOL exists = m_groups_hash_table.Contains(path.CStr()); if (exists && !force_create) return 0; GroupsModelItem* item = OP_NEW(GroupsModelItem, (m_folder_type)); if (!item) return 0; item->SetName(name); item->SetEditable(editable); if (!exists) { item->SetPath(path); } else //force_create { int i=2; //Start with appending '#2' to string while (exists) { OpString probe_path; probe_path.AppendFormat(UNI_L("%s#%i"), path.CStr(), i++); if (probe_path.IsEmpty()) //Out of memory? return 0; exists = m_groups_hash_table.Contains(probe_path.CStr()); if (!exists) { if (name.Compare(path)==0) item->SetName(probe_path); item->SetPath(probe_path); } } } item->SetWasSubscribed(subscribedLocally); item->SetIsSubscribed(subscribedOnServer); item->m_id = m_next_id++; item->SetIsManuallyAdded(manually); item->m_account_id = m_account_id; m_groups_hash_table.Add(item->GetPathCStr(), item); AddLast(item, FindParent(path)); return item->m_id; }
void GStringList::AppendList(const GStringList *pListToCopy) { if (pListToCopy) { GStringIterator it( pListToCopy ); while (it()) { AddLast((const char *)it++); } } }
void GList::AppendList(const GList *pListToCopy) { if (pListToCopy) { GListIterator it( pListToCopy ); while (it()) { void *p = (void *)it++; AddLast(p); } } }
void AttachNode(Node *theNode, Node *theChild) { if(!theNode) return; if(theNode->gObject == NULL) { // node does not have gObject, so attach child AddLast(theNode->nodeChilds, theChild); theChild->parent = theNode; nodeUpdateGS(theNode); } else { printf("El nodo padre tiene un objeto, no se puede realizar AttachNode\n"); } }
int main() { FILE *p; p=fopen("input.dat","r"); o=fopen("output.dat","w"); char a[100],*c,*d; while(fgets(a,100,p)) { c=strtok(a," \n"); d=strtok(NULL," \n"); if(strcmp(c,"AF") == 0) { AddFirst(atoi(d), &Works); } else if (strcmp(c,"AL") == 0) { AddLast(atoi(d), &Works); } else if(strcmp(c,"DF")==0) { DeleteFirst(&Works); } else if(strcmp(c,"DL")==0) { DeleteLast(&Works); } else if(strcmp(c,"DE")==0) { DeleteElement(atoi(d), &Works); } else if(strcmp(c,"PRINT_ALL")==0) { print(&Works); } else if(strcmp(c,"PRINT_F")==0) { PrintNrOfElements(atoi(d), &Works); } else if(strcmp(c,"PRINT_L")==0) { PrintNrOfElementsLast(atoi(d), &Works); } else if(strcmp(c,"DOOM_THE_LIST")==0) { Doom(&Works); } } return 0; }
INT32 SpeedDialSuggestionsModel::AddSuggestion(const OpStringC &title, const OpStringC &url, const INT32 parent) { OpString actual_url, display_url; actual_url.Set(url); // Look up for the display url or redirect url if any HotlistModelItem* bookmark = g_desktop_bookmark_manager->FindDefaultBookmarkByURL(url); if (bookmark) { actual_url.Set(bookmark->GetUrl()); display_url.Set(bookmark->GetDisplayUrl()); } //Removes duplicated URLs from the treeview list if (parent == -1) { SpeedDialSuggestionsModelItem *item; for (INT32 index = 0; index < GetItemCount() && (item = GetItemByIndex(index)); index++) { if (item->GetURL().Compare(actual_url) == 0 || item->GetURL().Compare(display_url) == 0) return -1; } } // Don't add urls already in speed dial if (g_speeddial_manager->SpeedDialExists(actual_url) || g_speeddial_manager->SpeedDialExists(display_url)) return -1; for (UINT32 i = 0; i < ARRAY_SIZE(LIST_OF_BLACKLISTED_URLS); i++) if (url == LIST_OF_BLACKLISTED_URLS[i]) return -1; SpeedDialSuggestionsModelItem* item = OP_NEW(SpeedDialSuggestionsModelItem, (SpeedDialSuggestionsModelItem::LINK_TYPE)); if (item) { if (OpStatus::IsSuccess(item->SetLinkData(title, actual_url, display_url))) { Image favico = g_favicon_manager->Get(url.CStr()); item->SetBitmap(favico); INT32 idx = AddLast(item, parent); if (idx != -1) { return idx; } } OP_DELETE(item); } return -1; }
int main() { FILE *pf_in=fopen("input.dat", "r"); FILE *pf_out=fopen("output.dat", "w"); char action[20]; int value; while(fscanf(pf_in,"%s %d", &action, &value)!=EOF) { if((strcmp(action,"AF"))==0) { AddFirst(value); } if((strcmp(action,"AL"))==0) { AddLast(value); } if((strcmp(action,"DF"))==0) { DelFirst(); } if((strcmp(action,"DL"))==0) { DelLast(); } if((strcmp(action,"DOOM_THE_LIST"))==0) { DoomList(); } if((strcmp(action,"DE"))==0) { DeleteCertainElement(value); } if((strcmp(action,"PRINT_ALL"))==0) { PrintAll(pf_out); } if((strcmp(action,"PRINT_F"))==0) { PrintFirst(value, pf_out); } if((strcmp(action,"PRINT_L"))==0) { PrintLast(value, pf_out); } } fclose(pf_in); return 0; }
int main() { FILE *f1=fopen("input.dat","r"); FILE *f2=fopen("output.dat","w"); char s[15]; int data; p->head=0; p->tail=0; while(fscanf(f1, "%s", s)==1) { if(strcmp(s, "AF")==0) { fscanf(f1, " %d", &data); AddFirst(data); } if(strcmp(s, "AL")==0) { fscanf(f1, " %d", &data); AddLast(data); } if(strcmp(s, "DF")==0) DeleteFirst(); if(strcmp(s, "DL")==0) DeleteLast(); if(strcmp(s, "DE")==0) { fscanf(f1, "%d", &data); DeleteElem(data); } if(strcmp(s, "DOOM_THE_LIST")==0) Doom_The_List(); if(strcmp(s, "PRINT_ALL")==0) PrintAll(f2); if(strcmp(s, "PRINT_F")==0) { fscanf(f1, "%d", &data); PrintFirst(data, f2); } if (strcmp(s,"PRINT_L")==0) { fscanf(f1, "%d", &data); PrintLast(p->tail, data, f2); fprintf(f2, "\n"); } } return 0; }
INT32 SpeedDialSuggestionsModel::AddLabel(const OpStringC &title, const INT32 parent) { SpeedDialSuggestionsModelItem* item = OP_NEW(SpeedDialSuggestionsModelItem, (SpeedDialSuggestionsModelItem::LABEL_TYPE)); if (item) { if (OpStatus::IsSuccess(item->SetTitle(title))) { INT32 idx = AddLast(item, parent); if (idx != -1) return idx; } OP_DELETE(item); } return -1; }
INT32 SpeedDialSuggestionsModel::AddFolder(const OpStringC &title, const OpStringC8 &skin_image) { SpeedDialSuggestionsModelItem* item = OP_NEW(SpeedDialSuggestionsModelItem, (SpeedDialSuggestionsModelItem::FOLDER_TYPE)); if (item) { if (OpStatus::IsSuccess(item->SetTitle(title)) && OpStatus::IsSuccess(item->SetImage(skin_image))) { INT32 idx = AddLast(item); if (idx != -1) return idx; } OP_DELETE(item); } return -1; }
void KStrings::SplitToTokens( const KString& String, LPCTSTR pDelimeters, bool bClearFirst) { if(bClearFirst) Clear(); KString TempString = String; TCHAR *pToken; for(pToken = _tcstok(TempString.GetDataPtr(), pDelimeters) ; pToken ; pToken = _tcstok(NULL, pDelimeters)) { *AddLast() = pToken; } }
BOOL ChattersModel::OnChatterJoining(UINT16 account_id, const ChatInfo& room, const OpStringC& chatter, BOOL is_operator, BOOL is_voiced, const OpStringC& prefix, BOOL initial) { if (!IsModelForRoom(account_id, room.ChatName())) { return TRUE; } if (GetChatter(chatter)) return FALSE; ChattersModelItem* item = OP_NEW(ChattersModelItem, (m_account_id, chatter, is_operator, is_voiced, prefix)); if (!item) return FALSE; m_chatters_hash_table.Add(item->GetName(), item); AddLast(item); return TRUE; }
int main() { char strng[20]; int value; FILE *d; d= fopen("input.dat", "r"); while(fscanf(d, "%s %d", &strng, &value)!=EOF) { if (strcmp(strng,"AF")==0) AddFirst(value); if (strcmp(strng,"AL")==0) AddLast(value); if (strcmp(strng,"PRINT_ALL")==0) print_list(); if (strcmp(strng,"DF")==0) DelFirst(); if (strcmp(strng,"DL")==0) DelLast(); if (strcmp(strng,"DOOM_THE_LIST")==0) DoomTheList(); if (strcmp(strng,"DE")==0) DelAnElement(value); if (strcmp(strng,"PRINT_F")==0) PRINT_F(value); if (strcmp(strng,"PRINT_L")==0) PRINT_L(value); } fclose(d); return 0; }
void GadgetsTreeModel::RefreshModel() { // Refreshing the model involves deleting all existing items. We can't do // that if any item is in use (DSK-292233). for (INT32 i = 0; i < GetItemCount(); ++i) { if (GetItemByIndex(i)->IsLocked()) { return; } } // Refresh all gadget sources. for (UINT32 i = 0; i < m_sources.GetCount(); ++i) { const OP_STATUS status = m_sources.Get(i)->Refresh(); OP_ASSERT(OpStatus::IsSuccess(status) || !"Failed to refresh gadget source"); } m_platform_timestamp = op_time(NULL); // (Re)build the model. ModelLock model_lock(this); DeleteAll(); for (UINT32 i = 0; i < m_sources.GetCount(); ++i) { const Source& source = *m_sources.Get(i); for (UINT32 j = 0; j < source.GetItemCount(); ++j) { GadgetsTreeModelItemImpl* item_impl = source.CreateItemImpl(j); if (NULL != item_impl) { AddLast(OP_NEW(GadgetsTreeModelItem, (item_impl))); } } } }
XnStatus FromElement(const TiXmlElement* pLicenses) { XnStatus nRetVal = XN_STATUS_OK; Clear(); // read licenses const TiXmlElement* pLicense = pLicenses->FirstChildElement(XN_XML_LICENSE_NODE); while (pLicense != NULL) { XnLicenseXml license; nRetVal = license.FromElement(pLicense); XN_IS_STATUS_OK(nRetVal); nRetVal = AddLast(license); XN_IS_STATUS_OK(nRetVal); pLicense = pLicense->NextSiblingElement(XN_XML_LICENSE_NODE); } return (XN_STATUS_OK); }
/*********************************************************************************** ** ** TreeViewModel::Init ** ***********************************************************************************/ void TreeViewModel::Init() { INT32 count = m_model->GetItemCount(); //SetInitialSize(count); for (INT32 i = 0; i < count; i++) { TreeViewModelItem* item = OP_NEW(TreeViewModelItem, (m_model->GetItemByPosition(i))); if (!item) break; INT32 parent = m_model->GetItemParent(i); AddLast(item, parent); } if (GetTreeModelGrouping()) { Regroup(); } if (GetSortListener()) Sort(); }
void GStringList::operator+=(const char *szSrc) { AddLast(szSrc); }
void GStringList::operator+=(const GStringList &src) { GStringIterator it(&src); while (it()) AddLast(it++); }