PropertyMap Mod::Tag::setProperties(const PropertyMap &origProps) { PropertyMap properties(origProps); properties.removeEmpty(); StringList oneValueSet; if(properties.contains("TITLE")) { d->title = properties["TITLE"].front(); oneValueSet.append("TITLE"); } else d->title = String::null; if(properties.contains("COMMENT")) { d->comment = properties["COMMENT"].front(); oneValueSet.append("COMMENT"); } else d->comment = String::null; if(properties.contains("TRACKERNAME")) { d->trackerName = properties["TRACKERNAME"].front(); oneValueSet.append("TRACKERNAME"); } else d->trackerName = String::null; // for each tag that has been set above, remove the first entry in the corresponding // value list. The others will be returned as unsupported by this format. for(StringList::Iterator it = oneValueSet.begin(); it != oneValueSet.end(); ++it) { if(properties[*it].size() == 1) properties.erase(*it); else properties[*it].erase( properties[*it].begin() ); } return properties; }
void FrameFactory::updateGenre(TextIdentificationFrame *frame) const { StringList fields; String s = frame->toString(); while(s.startsWith("(")) { int closing = s.find(")"); if(closing < 0) break; fields.append(s.substr(1, closing - 1)); s = s.substr(closing + 1); } if(!s.isEmpty()) fields.append(s); if(fields.isEmpty()) fields.append(String::null); frame->setText(fields); }
void FrameFactory::updateGenre(TextIdentificationFrame *frame) const { StringList fields = frame->fieldList(); StringList newfields; for(StringList::Iterator it = fields.begin(); it != fields.end(); ++it) { String s = *it; int end = s.find(")"); if(s.startsWith("(") && end > 0) { // "(12)Genre" String text = s.substr(end + 1); bool ok; int number = s.substr(1, end - 1).toInt(&ok); if(ok && number >= 0 && number <= 255 && !(ID3v1::genre(number) == text)) newfields.append(s.substr(1, end - 1)); if(!text.isEmpty()) newfields.append(text); } else { // "Genre" or "12" newfields.append(s); } } if(newfields.isEmpty()) fields.append(String::null); frame->setText(newfields); }
// Return all suffix-matched files in the directory 'dirpath' bool suffix_matched_files_in_dir(const char *dirpath, StringList &file_list, const char *suffix, bool use_fullname) { Directory dir(dirpath); bool found_it = false; file_list.clearAll(); const char *f = NULL; dir.Rewind(); while( (f=dir.Next()) ) { if( dir.IsDirectory() ) { continue; } if( has_suffix(f, suffix) ) { if( use_fullname ) { file_list.append(dir.GetFullPath()); }else { file_list.append(f); } found_it = true; } } return found_it; }
String AudioProperties::toString() const { StringList desc; desc.append("Audio"); desc.append(String::number(length()) + " seconds"); desc.append(String::number(bitrate()) + " kbps"); return desc.toString(", "); }
StringList FileRef::defaultFileExtensions() { StringList l; l.append("ogg"); l.append("flac"); l.append("oga"); l.append("mp3"); l.append("mpc"); // l.append("wv"); // l.append("spx"); // l.append("tta"); l.append("m4a"); l.append("m4r"); l.append("m4b"); l.append("m4p"); l.append("3g2"); l.append("mp4"); l.append("wma"); l.append("asf"); // l.append("aif"); // l.append("aiff"); // l.append("wav"); l.append("ape"); // l.append("mod"); // l.append("module"); // alias for "mod" // l.append("nst"); // alias for "mod" // l.append("wow"); // alias for "mod" // l.append("s3m"); // l.append("it"); // l.append("xm"); return l; }
TextIdentificationFrame *TextIdentificationFrame::createTIPLFrame(const PropertyMap &properties) // static { TextIdentificationFrame *frame = new TextIdentificationFrame("TIPL"); StringList l; for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it){ l.append(it->first); l.append(it->second.toString(",")); // comma-separated list of names } frame->setText(l); return frame; }
StringList FileRef::defaultFileExtensions() { StringList l; l.append("ogg"); l.append("flac"); l.append("mp3"); l.append("mpc"); return l; }
int main() { /* Hint 4: * Since all c-string allocation is done in the main program * we do not need any limits */ char word1[] = "Knüppel"; char word2[] = "Baum"; char word3[] = "Masche"; char word4[] = "Kreuz"; char word5[] = "XXX"; char word6[] = "Arabisch"; char word7[] = "Ball"; char word8[] = "Alaun"; biTree_t t; t.insert(word1); t.insert(word2); t.insert(word3); t.insert(word4); t.insert(word5); t.insert(word6); t.insert(word7); t.insert(word8); t.print(); #ifdef VERBOSE char checked_key1 = 'B'; char checked_key2 = 'X'; char searched_string1[] = "Alaun"; char searched_string2[] = "nix"; printf("Stringcount in key %c: %d\n", checked_key1, t.count(checked_key1)); printf("Stringcount in key %c: %d\n", checked_key2, t.count(checked_key2)); printf("String %s is in tree: %d\n", searched_string1, t.exists(searched_string1)); printf("String %s is in tree: %d\n", searched_string2, t.exists(searched_string2)); #endif StringList sl; sl.append(word1); sl.append(word2); sl.append(word3); sl.print(); }
TextIdentificationFrame *TextIdentificationFrame::createTMCLFrame(const PropertyMap &properties) // static { TextIdentificationFrame *frame = new TextIdentificationFrame("TMCL"); StringList l; for(PropertyMap::ConstIterator it = properties.begin(); it != properties.end(); ++it){ if(!it->first.startsWith(instrumentPrefix)) // should not happen continue; l.append(it->first.substr(instrumentPrefix.size())); l.append(it->second.toString(",")); } frame->setText(l); return frame; }
//------------------------------------------------------------ static void writeTOC(BookCaseDB &db, info_lib *mmdb, const char *bcname, const char *thisBook, DBCursor &toc_cursor ) { DBTable *out = db.DB::table(DATABASE_STDIO, TOC_CODE, NUM_TOC_FIELDS, DB::CREATE); const char *aBook; const char *nodeLoc; const char *parent; int childQty; char **children; int treeSize; while(toc_cursor.next(STRING_CODE, &aBook, STRING_CODE, &nodeLoc, STRING_CODE, &parent, SHORT_LIST_CODE, &childQty, STRING_CODE, &children, INTEGER_CODE, &treeSize, NULL)){ StringList heap; if(strcmp(aBook, thisBook) != 0){ /* book id has changed! We're done... */ toc_cursor.undoNext(); break; } for(int i = 0; i < childQty; i++){ heap.append(to_oid(mmdb, bcname, children[i])); } const char *nodeOID = heap.append(to_oid(mmdb, bcname, nodeLoc)); const char *parentOID = heap.append(to_oid(mmdb, bcname, parent)); #ifdef FISH_DEBUG DBUG_PRINT("TOC", ("TOC Entry: O:%s treesize: %d\n", nodeOID, treeSize)); #endif out->insert(OID_CODE, nodeOID, OID_CODE, parentOID, INTEGER_CODE, treeSize, /* first childQty strings in heap are oids for children */ OID_LIST_CODE, childQty, heap.array(), NULL); } delete out; }
StringList StringList::split(const String &s, const String &pattern) { StringList l; int previousOffset = 0; for(int offset = s.find(pattern); offset != -1; offset = s.find(pattern, offset + 1)) { l.append(s.substr(previousOffset, offset - previousOffset)); previousOffset = offset + 1; } l.append(s.substr(previousOffset, s.size() - previousOffset)); return l; }
int EC2GahpClient::ec2_spot_status_all( const std::string & service_url, const std::string & publickeyfile, const std::string & privatekeyfile, StringList & returnStatus, std::string & error_code ) { static const char * command = "EC2_VM_STATUS_ALL_SPOT"; // callGahpFunction() checks if this command is supported. CHECK_COMMON_ARGUMENTS; Gahp_Args * result = NULL; std::vector< YourString > arguments; PUSH_COMMON_ARGUMENTS; int cgf = callGahpFunction( command, arguments, result, high_prio ); if( cgf != 0 ) { return cgf; } if( result ) { // We expect results of the form // <request ID> 0 // <request ID> 0 (<SIR ID> <status> <ami ID> <instance ID|NULL> <status code|NULL>)+ // <request ID> 1 // <request ID> 1 <error code> <error string> if( result->argc < 2 ) { EXCEPT( "Bad %s result", command ); } int rc = atoi( result->argv[1] ); if( result->argc == 2 ) { if( rc == 1 ) { error_string = ""; } } else if( result->argc == 4 ) { if( rc != 1 ) { EXCEPT( "Bad %s result", command ); } error_code = result->argv[2]; error_string = result->argv[3]; } else if( (result->argc - 2) % 5 == 0 ) { for( int i = 2; i < result->argc; ++i ) { if( strcmp( result->argv[i], NULLSTRING ) ) { returnStatus.append( result->argv[i] ); } else { returnStatus.append( "" ); } } } else { EXCEPT( "Bad %s result", command ); } delete result; return rc; } else { EXCEPT( "callGahpFunction() succeeded but result was NULL." ); } }
// Not sure why this function always returns 0. int EC2GahpClient::ec2_attach_volume( const std::string & service_url, const std::string & publickeyfile, const std::string & privatekeyfile, const std::string & volume_id, const std::string & instance_id, const std::string & device_id, StringList & returnStatus, std::string & error_code ) { static const char* command = "EC2_VM_ATTACH_VOLUME"; // callGahpFunction() checks if this command is supported. CHECK_COMMON_ARGUMENTS; if( volume_id.empty() || instance_id.empty() || device_id.empty() ) { return GAHPCLIENT_COMMAND_NOT_SUPPORTED; } Gahp_Args * result = NULL; std::vector< YourString > arguments; PUSH_COMMON_ARGUMENTS; arguments.push_back( volume_id ); arguments.push_back( instance_id ); arguments.push_back( device_id ); int cgf = callGahpFunction( command, arguments, result, medium_prio ); if( cgf != 0 ) { return 0; } if ( result ) { // command completed and the return value looks like: int result_code = atoi(result->argv[1]); if (result_code == 1) { if (result->argc == 2) { error_string = ""; } else if (result->argc == 4) { error_code = result->argv[2]; error_string = result->argv[3]; } else { EXCEPT("Bad %s Result",command); } } else { // result_code == 0 if ( ( (result->argc-2) % 2) != 0 ) { EXCEPT("Bad %s Result",command); } else { // get the status info for (int i=2; i<result->argc; i++) { returnStatus.append( result->argv[i] ); } returnStatus.rewind(); } } delete result; return 0; } else { EXCEPT( "callGahpFunction() succeeded but result was NULL." ); } }
PropertyMap Ogg::XiphComment::setProperties(const PropertyMap &properties) { // check which keys are to be deleted StringList toRemove; for(FieldListMap::ConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it) if (!properties.contains(it->first)) toRemove.append(it->first); for(StringList::ConstIterator it = toRemove.begin(); it != toRemove.end(); ++it) removeField(*it); // now go through keys in \a properties and check that the values match those in the xiph comment PropertyMap invalid; PropertyMap::ConstIterator it = properties.begin(); for(; it != properties.end(); ++it) { if(!checkKey(it->first)) invalid.insert(it->first, it->second); else if(!d->fieldListMap.contains(it->first) || !(it->second == d->fieldListMap[it->first])) { const StringList &sl = it->second; if(sl.size() == 0) // zero size string list -> remove the tag with all values removeField(it->first); else { // replace all strings in the list for the tag StringList::ConstIterator valueIterator = sl.begin(); addField(it->first, *valueIterator, true); ++valueIterator; for(; valueIterator != sl.end(); ++valueIterator) addField(it->first, *valueIterator, false); } } } return invalid; }
// ============================================================================ // // Potentially adds a string to the table and returns the index of it. // int getStringTableIndex (const String& a) { // Find a free slot in the table. int idx; for (idx = 0; idx < g_StringTable.size(); idx++) { // String is already in the table, thus return it. if (g_StringTable[idx] == a) return idx; } // Must not be too long. if (a.length() >= gMaxStringLength) error ("string `%1` too long (%2 characters, max is %3)\n", a, a.length(), gMaxStringLength); // Check if the table is already full if (g_StringTable.size() == gMaxStringlistSize - 1) error ("too many strings!\n"); // Now, dump the string into the slot g_StringTable.append (a); return (g_StringTable.size() - 1); }
void MP4::Tag::parseFreeForm(const MP4::Atom *atom) { AtomDataList data = parseData2(atom, -1, true); if(data.size() > 2) { String name = "----:" + String(data[0].data, String::UTF8) + ':' + String(data[1].data, String::UTF8); AtomDataType type = data[2].type; for(uint i = 2; i < data.size(); i++) { if(data[i].type != type) { debug("MP4: We currently don't support values with multiple types"); break; } } if(type == TypeUTF8) { StringList value; for(uint i = 2; i < data.size(); i++) { value.append(String(data[i].data, String::UTF8)); } Item item(value); item.setAtomDataType(type); addItem(name, item); } else { ByteVectorList value; for(uint i = 2; i < data.size(); i++) { value.append(data[i].data); } Item item(value); item.setAtomDataType(type); addItem(name, item); } } }
UserTextIdentificationFrame::UserTextIdentificationFrame(String::Type encoding) : TextIdentificationFrame("TXXX", encoding), d(0) { StringList l; l.append(String::null); l.append(String::null); setText(l); }
void testUTF16BEDelimiter() { ID3v2::TextIdentificationFrame f(ByteVector("TPE1"), String::UTF16BE); StringList sl; sl.append("Foo"); sl.append("Bar"); f.setText(sl); CPPUNIT_ASSERT_EQUAL((unsigned int)(4+4+2+1+6+2+6), f.render().size()); }
StringList ID3v1::genreList() { static StringList l; if(l.isEmpty()) { for(int i = 0; i < genresSize; i++) l.append(genres[i]); } return l; }
StringList ID3v1::genreList() { StringList l; for(int i = 0; i < genresSize; i++) { l.append(genres[i]); } return l; }
ByteVector UnsynchronizedLyricsFrame::renderFields() const { StringList sl; sl.append(d->description); sl.append(d->text); const String::Type encoding = checkTextEncoding(sl, d->textEncoding); ByteVector v; v.append(char(encoding)); v.append(d->language.size() == 3 ? d->language : "XXX"); v.append(d->description.data(encoding)); v.append(textDelimiter(encoding)); v.append(d->text.data(encoding)); return v; }
void IpVerify::fill_table(PermTypeEntry * pentry, char * list, bool allow) { assert(pentry); NetStringList * whichHostList = new NetStringList(); UserHash_t * whichUserHash = new UserHash_t(1024, compute_host_hash); StringList slist(list); char *entry, * host, * user; slist.rewind(); while ( (entry=slist.next()) ) { if (!*entry) { // empty string? slist.deleteCurrent(); continue; } split_entry(entry, &host, &user); ASSERT( host ); ASSERT( user ); // If this is a hostname, get all IP addresses for it and // add them to the list. This ensures that if we are given // a cname, we do the right thing later when trying to match // this record with the official hostname. StringList host_addrs; ExpandHostAddresses(host,&host_addrs); host_addrs.rewind(); char const *host_addr; while( (host_addr=host_addrs.next()) ) { MyString hostString(host_addr); StringList * userList = 0; // add user to user hash, host to host list if (whichUserHash->lookup(hostString, userList) == -1) { whichUserHash->insert(hostString, new StringList(user)); whichHostList->append(hostString.Value()); } else { userList->append(user); } } free(host); free(user); } if (allow) { pentry->allow_hosts = whichHostList; pentry->allow_users = whichUserHash; } else { pentry->deny_hosts = whichHostList; pentry->deny_users = whichUserHash; } }
StringList String::split(const String &separator) const { StringList list; for(int index = 0;;) { int sep = find(separator, index); if(sep < 0) { list.append(substr(index, size() - index)); break; } else { list.append(substr(index, sep - index)); index = sep + separator.size(); } } return list; }
String MP4::AudioProperties::toString() const { String format; if(d->codec == AAC) { format = "AAC"; } else if(d->codec == ALAC) { format = "ALAC"; } else { format = "Unknown"; } StringList desc; desc.append("MPEG-4 audio (" + format + ")"); desc.append(String::number(length()) + " seconds"); desc.append(String::number(bitrate()) + " kbps"); return desc.toString(", "); }
void UserTextIdentificationFrame::setDescription(const String &s) { StringList l = fieldList(); if(l.isEmpty()) l.append(s); else l[0] = s; TextIdentificationFrame::setText(l); }
void Sinful::addAddrToAddrs( const condor_sockaddr & sa ) { addrs.push_back( sa ); StringList sl; for( unsigned i = 0; i < addrs.size(); ++i ) { sl.append( addrs[i].to_ccb_safe_string().c_str() ); } char * slString = sl.print_to_delimed_string( "+" ); setParam( "addrs", slString ); free( slString ); }
void MP4::Tag::parseText(const MP4::Atom *atom, int expectedFlags) { ByteVectorList data = parseData(atom, expectedFlags); if(data.size()) { StringList value; for(unsigned int i = 0; i < data.size(); i++) { value.append(String(data[i], String::UTF8)); } addItem(atom->name, value); } }
void MP4::Tag::parseText(MP4::Atom *atom, TagLib::File *file, int expectedFlags) { ByteVectorList data = parseData(atom, file, expectedFlags); if(data.size()) { StringList value; for(unsigned int i = 0; i < data.size(); i++) { value.append(String(data[i], String::UTF8)); } d->items.insert(atom->name, value); } }
void MP4::Tag::parseText(const MP4::Atom *atom, int expectedFlags) { ByteVectorList data = parseData(atom, expectedFlags); if(!data.isEmpty()) { StringList value; for(ByteVectorList::ConstIterator it = data.begin(); it != data.end(); ++it) { value.append(String(*it, String::UTF8)); } addItem(atom->name, value); } }