int ACE_TMAIN (int, ACE_TCHAR *[]) { ACE_Array<DataElement*> arr (10); DataElement *elem = 0; // Allocate and insert elements. for (int i = 0; i < 10; i++) { ACE_NEW_RETURN (elem, DataElement (i), -1); arr[i] = elem; } // Checked access. ACE_ASSERT (arr.set (elem, 11) == -1); ACE_ASSERT (arr.get (elem, 11) == -1); // Make a copy and compare to the original. ACE_Array<DataElement*> copy = arr; ACE_ASSERT (copy == arr); ACE_Array<DataElement*>::ITERATOR iter (arr); while (!iter.done ()) { DataElement** data; iter.next (data); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%d\n"), (*data)->getData ())); delete (*data); iter.advance (); } return 0; }
void HeaderBase::get_values(const ACE_CString& name, ACE_Array<ACE_CString> & values) const { TNVMap::ITERATOR it (const_cast<TNVMap&> (this->header_values_)); if (this->header_values_.find (name, it) == 0) { for (; !it.done () && ((*it).second () == name) ;it.advance ()) { if (values.size (values.size ()+1) == 0) { values.set ((*it).second (), values.size ()-1); } } } }
int Get_Task::svc () { ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) task started\n"))); ACE::HTTP::URL http_url; if (http_url.parse ("http://www.theaceorb.nl")) { ACE::HTTP::ClientRequestHandler rh; ACE::INet::URLStream urlin = http_url.open (rh); if (urlin) { ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) opened URL %C\n"), http_url.to_string ().c_str ())); ACE::IOS::CString_OStream sos; sos << urlin->rdbuf (); ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) result downloaded\n"))); if (!sos.bad ()) { ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard_, lock_, 0); ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) storing result\n"))); results_.size (results_.size () + 1); results_[results_.size ()-1] = sos.str (); } } else ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) failed to open URL %C\n"), http_url.to_string ().c_str ())); shutdown (); } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) failed to parse URL : result = %C\n"), http_url.to_string ().c_str ())); } ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) task finished\n"))); return 0; }
void Request::arguments (ACE_Array<ACE_CString> & args) const { ACE::IOS::CString_IStream sis (this->args_); int ch = sis.get (); while (ch != eof_) { // skip whitespace while (ACE_OS::ace_isspace (ch)) ch = sis.get (); if (ch != eof_) { // get arg ACE_Array<ACE_CString>::size_type n = args.size (); args.size (n + 1); ACE_CString& arg = args[n]; while (ch != eof_ && !ACE_OS::ace_isspace (ch)) { arg += ch; ch = sis.get (); } } } }
void ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, ACE_Array<ACE_TString> &try_names) { // Build the array of DLL names to try on this platform by applying the // proper prefixes and/or suffixes to the specified dll_name. ACE_TString base (dll_name); ACE_TString base_dir, base_file, base_suffix; // 1. Separate the dll_name into the dir part and the file part. We // only decorate the file part to determine the names to try loading. ACE_TString::size_type pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR); if (pos != ACE_TString::npos) { base_dir = base.substr (0, pos + 1); base_file = base.substr (pos + 1); } else base_file = base; // 2. Locate the file suffix, if there is one. Move the '.' and the // suffix to base_suffix. if ((pos = base_file.rfind (ACE_TEXT ('.'))) != ACE_TString::npos) { base_suffix = base_file.substr (pos); base_file = base_file.substr (0, pos); } // 3. Build the combinations to try for this platform. // Try these combinations: // - name with decorator and platform's suffix appended (if not supplied) // - name with platform's suffix appended (if not supplied) // - name with platform's dll prefix (if it has one) and suffix // - name with platform's dll prefix, decorator, and suffix. // - name as originally given // We first try to find the file using the decorator so that when a // filename with and without decorator is used, we get the file with // the same decorator as the ACE dll has and then as last resort // the one without. For example with msvc, the debug build has a "d" // decorator, but the release build has none and we really want to get // the debug version of the library in a debug application instead // of the release one. // So we need room for 5 entries in try_names. try_names.size (0); if ((try_names.max_size () - try_names.size ()) < 5) try_names.max_size (try_names.max_size () + 5); #if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) ACE_TString decorator (ACE_LD_DECORATOR_STR); #endif ACE_TString suffix (ACE_DLL_SUFFIX); ACE_TString prefix (ACE_DLL_PREFIX); for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i) { ACE_TString try_this; size_t j = try_names.size (); switch (i) { case 0: // Name + decorator + suffix case 1: // Name + suffix case 2: // Prefix + name + decorator + suffix case 3: // Prefix + name + suffix if ( base_suffix.length () > 0 #if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)) || (i == 1 || i == 3) // No decorator desired; skip #endif ) break; try_this = base_dir; if (i > 1) try_this += prefix; try_this += base_file; if (base_suffix.length () > 0) try_this += base_suffix; else { #if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) try_this += decorator; #endif try_this += suffix; } break; case 4: try_this = dll_name; break; } if (try_this.length ()) { try_names.size (j + 1); try_names.set (try_this, j); } } return; }
void ACE_DLL_Handle::get_dll_names (const ACE_TCHAR *dll_name, ACE_Array<ACE_TString> &try_names) { // Build the array of DLL names to try on this platform by applying the // proper prefixes and/or suffixes to the specified dll_name. ACE_TString base (dll_name); ACE_TString base_dir, base_file, base_suffix; // 1. Separate the dll_name into the dir part and the file part. We // only decorate the file part to determine the names to try loading. int pos = base.rfind (ACE_DIRECTORY_SEPARATOR_CHAR); if (pos != ACE_TString::npos) { base_dir = base.substr (0, static_cast<ssize_t>(pos) + 1); base_file = base.substr (static_cast<size_t>(pos) + 1); } else base_file = base; // 2. Locate the file suffix, if there is one. Move the '.' and the // suffix to base_suffix. if ((pos = base_file.rfind (ACE_LIB_TEXT ('.'))) != ACE_TString::npos) { base_suffix = base_file.substr (static_cast<size_t>(pos)); base_file = base_file.substr (0, static_cast<ssize_t>(pos)); } // 3. Build the combinations to try for this platform. // Try these combinations: // - name as originally given // - name with decorator and platform's suffix appended (if not supplied) // - name with platform's suffix appended (if not supplied) // - name with platform's dll prefix (if it has one) and suffix // - name with platform's dll prefix, decorator, and suffix. // So we need room for 5 entries in try_names. try_names.size (0); if ((try_names.max_size () - try_names.size ()) < 5) try_names.max_size (try_names.max_size () + 5); #if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) ACE_TString decorator (ACE_LD_DECORATOR_STR); #endif ACE_TString suffix (ACE_DLL_SUFFIX); ACE_TString prefix (ACE_DLL_PREFIX); for (size_t i = 0; i < 5 && try_names.size () < try_names.max_size (); ++i) { ACE_TString try_this; size_t j = try_names.size (); switch (i) { case 0: try_this = dll_name; break; case 1: // Name + decorator + suffix case 2: // Name + suffix case 3: // Prefix + name + decorator + suffix case 4: // Prefix + name + suffix if ( base_suffix.length () > 0 #if !(defined(ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK)) || (i == 2 || i == 4) // No decorator desired; skip #endif ) break; try_this = base_dir; if (i > 2) try_this += prefix; try_this += base_file; if (base_suffix.length () > 0) try_this += base_suffix; else { #if defined (ACE_WIN32) && defined (ACE_LD_DECORATOR_STR) && !defined (ACE_DISABLE_DEBUG_DLL_CHECK) try_this += decorator; #endif try_this += suffix; } break; } if (try_this.length ()) { try_names.size (j + 1); try_names.set (try_this, j); } } return; }