MCPcopy Create free account
hub / github.com/bwapi/bwapi / getType

Method getType

bwapi/include/BWAPI/Type.h:141–161  ·  view source on GitHub ↗

Searches for the type associated with the given string and returns it. A string containing the name of the type. @returns The type that resolves to the given name.

Source from the content-addressed store, hash-verified

139 /// </param>
140 /// @returns The type that resolves to the given name.
141 static T getType(std::string name)
142 {
143 // Mapping of strings to types
144 static const typeMapT typeMap( typeMapInit() );
145
146 // erase-remove idiom, eliminates spaces and underscores from the string to search
147 name.erase( std::remove_if(name.begin(), name.end(), [](char const &c){ return isspace(c) || c == '_'; }), name.end() );
148
149 // Make lowercase
150 std::transform(name.begin(), name.end(), name.begin(),
151 [](std::string::const_reference c) { return static_cast<char>(std::tolower(c)); }
152 );
153
154 // Find the type
155 auto it = typeMap.find(name);
156 if ( it != typeMap.end() )
157 return it->second;
158
159 // Return unknown if it wasn't found
160 return T(UnknownId);
161 };
162 };
163
164}

Callers 2

executeMethod · 0.45

Calls 2

beginMethod · 0.80
endMethod · 0.80

Tested by

no test coverage detected