bool GetProperty(const mstrings_t& properties, const ACE_TString& prop, std::vector<int>& vec) { ACE_TString value; mstrings_t::const_iterator ite = properties.find(prop); if( ite != properties.end() ) { value = (*ite).second; ACE_TString token; size_t offset = 0; size_t i = value.find(',', offset);//Tokenize(ACE_TEXT(","),offset); while(i != ACE_TString::npos) { token = value.substr(offset, i-offset); offset = i+1; vec.push_back(int(string2i(token))); i = value.find(',', offset); } if( value.length() && (value.length() - 1) >= offset ) { token = value.substr(offset, value.length()-offset); offset = i+1; vec.push_back(int(string2i(token))); } return true; } return false; }
int BE_save_orb_args (int &argc, ACE_TCHAR *argv[]) { int i = 1; ACE_TString holder; while (i < argc) { if (ACE_OS::strncmp (argv[i], ACE_TEXT("-ORB"), 4) == 0) { holder += ACE_TString (argv[i]); holder += ACE_TEXT(" "); // Could be another -ORBxxx arg or an IDL compiler arg. if (*argv[i + 1] == '-') { ++i; continue; } // No-copy constructor. ACE_TString tmp (argv[i + 1], 0, false); // If the arg ends with either .idl or .pidl, we're done. size_t len = tmp.length (); ssize_t pos = tmp.find (ACE_TEXT(".idl")); if (len - pos == 4) { return 0; } pos = tmp.find (ACE_TEXT(".pidl")); if (len - pos == 5) { return 0; } // If we're here, the next arg goes with the preceding -ORBxxx. holder += tmp; holder += ACE_TEXT(" "); i += 2; } else { ++i; } } be_global->orb_args (ACE_TEXT_ALWAYS_CHAR(holder.c_str())); return 0; }
bool init (const ACE_TCHAR *inst) { ACE_TString tmp (inst); size_t begin = 0; size_t pos = tmp.find (',', begin); if (pos != ACE_TString::npos) path_ = tmp.substring (begin, pos - begin); else { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Options::Creation::init - ") ACE_TEXT ("Creation directive missing name, base location, and replace parameters, ") ACE_TEXT ("must have form path,name,base,replace\n"))); return false; } begin = pos + 1; pos = tmp.find (',', begin); if (pos != ACE_TString::npos) name_ = tmp.substring (begin, pos - begin); else { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Options::Creation::init - ") ACE_TEXT ("Creation directive mssing base location and replace parameter, ") ACE_TEXT ("must have form path,name,base,replace\n"))); return false; } begin = pos + 1; pos = tmp.find (',', begin); if (pos != ACE_TString::npos) base_location_ = tmp.substring (begin, pos - begin); else { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Options::Creation::init - ") ACE_TEXT ("Creation directive mssing replace parameter, ") ACE_TEXT ("must have form path,name,base,replace\n"))); return false; } begin = pos + 1; if (tmp[begin] == '0') replace_ = false; else if (tmp[begin] == '1') replace_ = true; else { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Options::Creation::init - ") ACE_TEXT ("Replace directive muse be 1 or 0.\n"))); return false; } return true; }
void TAO_IMR_Op_Register::addenv (ACE_TCHAR *opt) { CORBA::ULong length = this->environment_vars_.length (); // Increase the length of the sequence this->environment_vars_.length (length + 1); ACE_TString tokens (opt); size_t index = tokens.find (ACE_TEXT("=")); // Insert at position length since that is our new element this->environment_vars_ [length].name = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(tokens.substr (0, index).c_str ())); this->environment_vars_ [length].value = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(tokens.substr (index + 1).c_str ())); }
// Convert a <string> to a <name> ACE_Registry::Name ACE_Registry::make_name (const ACE_TString &string) { ACE_TString::size_type new_position = 0; ACE_TString::size_type last_position = 0; Name name; // Rememeber: NPOS is -1 while (new_position != ACE_TString::npos) { Name_Component component; // Find the separator new_position = string.find (STRING_SEPARATOR, new_position); if (new_position != ACE_TString::npos) // If we have not gone past the end { // Get the substring component.id_ = string.substr (last_position, new_position - last_position); // Skip past the seperator new_position += ACE_OS::strlen (STRING_SEPARATOR); } else { // Get the last substring component.id_ = string.substr (last_position); } // Update positions last_position = new_position; // Insert component into name name.insert (component); } return name; }
int ExtractProperties(const ACE_TString& input, mstrings_t& properties) { TTASSERT(input.find('\n') == input.rfind('\n')); bool bSyntaxError = false; if( input.length() == 0 ) bSyntaxError = true; size_t offset = input.find(' ');//past command if(offset == ACE_TString::npos) return 0; while(offset < input.length() && !bSyntaxError) { //past any spaces offset = pastBlanks(offset, input); if(offset == input.length()) { break; } size_t propBegin = offset; ACE_TString prop; ACE_TString value; while(offset < input.length()) //extract property name { if( input[offset] != ' ' && input[offset] != '=') offset ++; else break; } if(offset == input.length()) { bSyntaxError = true; //no properties in ACE_TString break; } prop = input.substr(propBegin, offset-propBegin); //set propertyname TTASSERT(properties.find(prop) == properties.end()); offset = pastBlanks(offset, input); //past spaces if(offset == input.length()) { bSyntaxError = true; break; } if(input[offset] != '=') { bSyntaxError = true; break; } else offset ++; //past = offset = pastBlanks(offset, input); //past spaces if(offset == input.length()) { bSyntaxError = true; break; } //determine whether it's a string or an integer if(input[offset] == '"') //a ACE_TString { bool found = false; size_t strBegin = ++offset; //past " while(!found && offset<input.length()) { /* if(input[offset]==ACE_TEXT('\"') && input[offset-1] != ACE_TEXT('\\')) found = true; offset++; */ if(input[offset] == '\\') offset += 2; else if(input[offset] == '"') { found = true; offset++; } else offset++; } if(!found) { bSyntaxError = true; break; } value = input.substr(strBegin, offset-strBegin-1); offset ++; //past \" properties[prop] = RebuildString(value); //properties.SetAt(prop, RebuildString(value)); } else if(input[offset] == '[') // an int list { bool found = false; size_t listBegin = ++offset; //past " while(!found && offset<input.length()) { if(input[offset] == ']') found = true; offset++; } if(!found) { bSyntaxError = true; break; } value = input.substr(listBegin, offset-listBegin-1); offset ++; //past ] properties[prop] = RebuildString(value); //properties.SetAt(prop, RebuildString(value)); } else //eat what's left until space { size_t intBegin = offset; while(offset<input.length() && input[offset] != ' ' && input[offset] != '\r' && input[offset] != '\n') offset ++; //past spaces value = input.substr(intBegin, offset-intBegin); properties[prop] = RebuildString(value); //properties.SetAt(prop, RebuildString(value)); } } return bSyntaxError? -1 : (int)properties.size(); }