cmCableClassSet.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2001 Insight Consortium
  8. All rights reserved.
  9. Redistribution and use in source and binary forms, with or without
  10. modification, are permitted provided that the following conditions are met:
  11. * Redistributions of source code must retain the above copyright notice,
  12. this list of conditions and the following disclaimer.
  13. * Redistributions in binary form must reproduce the above copyright notice,
  14. this list of conditions and the following disclaimer in the documentation
  15. and/or other materials provided with the distribution.
  16. * The name of the Insight Consortium, nor the names of any consortium members,
  17. nor of any contributors, may be used to endorse or promote products derived
  18. from this software without specific prior written permission.
  19. * Modified source versions must be plainly marked as such, and must not be
  20. misrepresented as being the original software.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
  22. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
  25. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  27. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  28. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  29. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. =========================================================================*/
  32. #include "cmCableClassSet.h"
  33. /**
  34. * Add to the set of required sources to define the class.
  35. */
  36. void cmCableClass::AddSources(const Sources& sources)
  37. {
  38. for(Sources::const_iterator s = sources.begin(); s != sources.end(); ++s)
  39. {
  40. m_Sources.insert(*s);
  41. }
  42. }
  43. /**
  44. * Add to the set of required sources to define the class.
  45. */
  46. void cmCableClass::AddSource(const char* source)
  47. {
  48. m_Sources.insert(source);
  49. }
  50. /**
  51. * The destructor frees all the cmCableClass instances in the set.
  52. */
  53. cmCableClassSet::~cmCableClassSet()
  54. {
  55. for(CableClassMap::const_iterator i = m_CableClassMap.begin();
  56. i != m_CableClassMap.end(); ++i)
  57. {
  58. delete i->second;
  59. }
  60. }
  61. /**
  62. * Add a class to the set.
  63. */
  64. void cmCableClassSet::AddClass(const char* name,
  65. cmCableClass* cableClass)
  66. {
  67. m_CableClassMap.insert(CableClassMap::value_type(name, cableClass));
  68. }
  69. /**
  70. * Add a source to every class in the set. This should only be done after
  71. * all classes have been inserted.
  72. */
  73. void cmCableClassSet::AddSource(const char* name)
  74. {
  75. for(CableClassMap::iterator c = m_CableClassMap.begin();
  76. c != m_CableClassMap.end(); ++c)
  77. {
  78. c->second->AddSource(name);
  79. }
  80. }
  81. /**
  82. * Get the size of the internal CableClassMap used to store the set.
  83. */
  84. unsigned int cmCableClassSet::Size() const
  85. {
  86. return m_CableClassMap.size();
  87. }
  88. /**
  89. * Get a begin iterator to the internal CableClassMap used to store the
  90. * set.
  91. */
  92. cmCableClassSet::CableClassMap::const_iterator cmCableClassSet::Begin() const
  93. {
  94. return m_CableClassMap.begin();
  95. }
  96. /**
  97. * Get an end iterator to the internal CableClassMap used to store the
  98. * set.
  99. */
  100. cmCableClassSet::CableClassMap::const_iterator cmCableClassSet::End() const
  101. {
  102. return m_CableClassMap.end();
  103. }
  104. /**
  105. * A utility class to generate element combinations from all possible
  106. * substitutions of set members into a $ token.
  107. */
  108. class ElementCombinationGenerator
  109. {
  110. public:
  111. ElementCombinationGenerator(const char* in_element, cmMakefile* in_makefile,
  112. cmCableClassSet* out_set):
  113. m_Makefile(in_makefile), m_OutputSet(out_set)
  114. {
  115. this->ParseInputElement(in_element);
  116. }
  117. ~ElementCombinationGenerator();
  118. void Generate();
  119. private:
  120. /**
  121. * Represent a substitution.
  122. */
  123. class Substitution
  124. {
  125. public:
  126. Substitution() {}
  127. void Bind(const std::string& in_code, const cmCableClass* in_class)
  128. {
  129. m_Code = in_code;
  130. m_Class = in_class;
  131. }
  132. const cmCableClass* GetClass() const
  133. { return m_Class; }
  134. const std::string& GetCode() const
  135. { return m_Code; }
  136. private:
  137. /**
  138. * The cmCableClass associated with this substitution.
  139. */
  140. const cmCableClass* m_Class;
  141. /**
  142. * The code to be used for the substitution.
  143. */
  144. std::string m_Code;
  145. };
  146. /**
  147. * Interface to the parts of an input string of code, possibly with
  148. * $SomeSetName tokens in it. An indivitual Portion will be either
  149. * a StringPortion, which has no substitutions, or a ReplacePortion,
  150. * which has only a substitution, and no hard-coded text.
  151. *
  152. * This is used by cmCableClassSet::GenerateElementCombinations() to
  153. * hold the pieces of a string after the set substitution tokens
  154. * have been extracted.
  155. */
  156. class Portion
  157. {
  158. public:
  159. /**
  160. * Get the C++ code corresponding to this Portion of a string.
  161. */
  162. virtual std::string GetCode() const =0;
  163. /**
  164. * Get the class corresponding to this Portion of a string. This is NULL
  165. * for StringPortion, and points to a cmCableClass for ReplacePortion.
  166. */
  167. virtual const cmCableClass* GetClass() const
  168. { return NULL; }
  169. virtual ~Portion() {}
  170. };
  171. /**
  172. * Represent a hard-coded part of an input string, that has no substitutions
  173. * in it. The tag for this part of a string is always empty.
  174. */
  175. class StringPortion: public Portion
  176. {
  177. public:
  178. StringPortion(const std::string& in_code): m_Code(in_code) {}
  179. virtual std::string GetCode() const
  180. { return m_Code; }
  181. virtual const cmCableClass* GetClass() const
  182. { return NULL; }
  183. virtual ~StringPortion() {}
  184. private:
  185. /**
  186. * Hold this Portion's contribution to the output string.
  187. */
  188. std::string m_Code;
  189. };
  190. /**
  191. * Represent the "$SomeSetName" portion of an input string. This has a
  192. * reference to the Substitution holding the real output to generate.
  193. */
  194. class ReplacePortion: public Portion
  195. {
  196. public:
  197. ReplacePortion(const Substitution& in_substitution):
  198. m_Substitution(in_substitution) {}
  199. virtual std::string GetCode() const
  200. { return m_Substitution.GetCode(); }
  201. virtual const cmCableClass* GetClass() const
  202. { return m_Substitution.GetClass(); }
  203. virtual ~ReplacePortion() {}
  204. private:
  205. /**
  206. * Refer to the real Substitution for this Portion's contribution.
  207. */
  208. const Substitution& m_Substitution;
  209. };
  210. typedef std::list<Portion*> Portions;
  211. typedef std::map<const cmCableClassSet*, Substitution*> Substitutions;
  212. /**
  213. * The makefile in which to lookup set names.
  214. */
  215. cmMakefile* m_Makefile;
  216. /**
  217. * The cmCableClassSet instance to be filled with combinations.
  218. */
  219. cmCableClassSet* m_OutputSet;
  220. /**
  221. * The class name parsed out for this element, before set expansion.
  222. */
  223. std::string m_ClassName;
  224. /**
  225. * The tag name parsed out or generated for this element.
  226. */
  227. std::string m_Tag;
  228. /**
  229. * The set of sources parsed out for this element.
  230. */
  231. cmCableClass::Sources m_Sources;
  232. /**
  233. * The parts of the input string after parsing of the tokens.
  234. */
  235. Portions m_Portions;
  236. /**
  237. * Map from substitution's Set to actual Substitution.
  238. */
  239. Substitutions m_Substitutions;
  240. private:
  241. void Generate(Substitutions::const_iterator);
  242. void ParseInputElement(const char*);
  243. void SplitClassName();
  244. std::string ParseSetName(std::string::const_iterator&,
  245. std::string::const_iterator) const;
  246. void FindTagSource();
  247. bool GenerateTag(const std::string&);
  248. };
  249. /**
  250. * Destructor frees portions and substitutions that were allocated by
  251. * constructor.
  252. */
  253. ElementCombinationGenerator
  254. ::~ElementCombinationGenerator()
  255. {
  256. // Free the string portions that were allocated.
  257. for(Portions::iterator portion = m_Portions.begin();
  258. portion != m_Portions.end(); ++portion)
  259. {
  260. delete *portion;
  261. }
  262. // Free the substitutions that were allocated.
  263. for(Substitutions::iterator sub = m_Substitutions.begin();
  264. sub != m_Substitutions.end(); ++sub)
  265. {
  266. delete sub->second;
  267. }
  268. }
  269. /**
  270. * Generate all element combinations possible with the set of
  271. * substitutions available. The given output set is filled with
  272. * all the combinations.
  273. */
  274. void
  275. ElementCombinationGenerator
  276. ::Generate()
  277. {
  278. // If there are no substitutions to be made, just generate this
  279. // single combination.
  280. if(m_Substitutions.empty())
  281. {
  282. cmCableClass* cableClass = new cmCableClass(m_Tag);
  283. cableClass->AddSources(m_Sources);
  284. m_OutputSet->AddClass(m_ClassName.c_str(), cableClass);
  285. return;
  286. }
  287. // We must generate all combinations of substitutions.
  288. // Begin the recursion with the first substitution.
  289. this->Generate(m_Substitutions.begin());
  290. }
  291. /**
  292. * Internal helper to Generate() which generates all
  293. * combinations in a recursive, depth-first order.
  294. */
  295. void
  296. ElementCombinationGenerator
  297. ::Generate(Substitutions::const_iterator substitution)
  298. {
  299. // Test our position in the list of substitutions to be bound.
  300. if(substitution == m_Substitutions.end())
  301. {
  302. // All substitutions have been prepared. Generate this combination.
  303. std::string tag = m_Tag;
  304. std::string code = "";
  305. // The set of sources for the generated combination. It will
  306. // always include the sources parsed from the original element
  307. // string.
  308. cmCableClass::Sources sources = m_Sources;
  309. // Put together all the pieces, with substitutions.
  310. for(Portions::const_iterator i = m_Portions.begin();
  311. i != m_Portions.end(); ++i)
  312. {
  313. // See if there is a class associated with this portion.
  314. const cmCableClass* curClassPortion = (*i)->GetClass();
  315. if(curClassPortion)
  316. {
  317. // Append the tag from the class portion.
  318. tag.append(curClassPortion->GetTag());
  319. // Include any sources needed by the class in this combination's set.
  320. for(cmCableClass::Sources::const_iterator
  321. s = curClassPortion->SourcesBegin();
  322. s != curClassPortion->SourcesEnd(); ++s)
  323. {
  324. sources.insert(*s);
  325. }
  326. }
  327. // Append the portion's code to this combination's code.
  328. code.append((*i)->GetCode());
  329. }
  330. // Add this combination to the output set.
  331. cmCableClass* cableClass = new cmCableClass(tag);
  332. cableClass->AddSources(sources);
  333. m_OutputSet->AddClass(code.c_str(), cableClass);
  334. }
  335. else
  336. {
  337. // Get the set for this substitution.
  338. const cmCableClassSet* set = substitution->first;
  339. if(set == m_OutputSet)
  340. {
  341. // We cannot iterate over the set currently being defined.
  342. cmSystemTools::Error("CABLE class set self-reference!");
  343. return;
  344. }
  345. // Prepare an iterator to the next substitution.
  346. Substitutions::const_iterator nextSubstitution = substitution;
  347. ++nextSubstitution;
  348. // We must iterate over all possible values for this substitution.
  349. for(cmCableClassSet::CableClassMap::const_iterator element = set->Begin();
  350. element != set->End(); ++element)
  351. {
  352. // Bind the substitution to this element.
  353. substitution->second->Bind(element->first, element->second);
  354. // Move on to the next substitution.
  355. this->Generate(nextSubstitution);
  356. }
  357. }
  358. }
  359. /**
  360. * Called from constructor. Parses the given string to extract the
  361. * class information specified.
  362. *
  363. * The format of the string is
  364. * [tag:]class_name[;source1;source2;...]
  365. */
  366. void
  367. ElementCombinationGenerator
  368. ::ParseInputElement(const char* in_element)
  369. {
  370. // A regular expression to match the tagged element specification.
  371. cmRegularExpression taggedElement =
  372. "^([A-Za-z_0-9]*)[ \t]*:[ \t]*([^:].*|::.*)$";
  373. // A regular expression to match the element when more source files are given.
  374. cmRegularExpression sourcesRemain("^([^;]*);(.*)$");
  375. std::string elementWithoutTag;
  376. std::string sourceString;
  377. bool tagGiven = false;
  378. // See if the element was tagged, and if so, pull off the tag.
  379. if(taggedElement.find(in_element))
  380. {
  381. // A tag was given. Use it.
  382. tagGiven = true;
  383. m_Tag = taggedElement.match(1);
  384. elementWithoutTag = taggedElement.match(2);
  385. }
  386. else
  387. {
  388. // No tag was given. We will try to generate it later.
  389. elementWithoutTag = in_element;
  390. }
  391. // Separate the class name.
  392. if(sourcesRemain.find(elementWithoutTag.c_str()))
  393. {
  394. m_ClassName = sourcesRemain.match(1);
  395. sourceString = sourcesRemain.match(2);
  396. }
  397. else
  398. {
  399. m_ClassName = elementWithoutTag;
  400. }
  401. // Find any source files specified with the ";source" syntax.
  402. while(sourcesRemain.find(sourceString.c_str()))
  403. {
  404. m_Sources.insert(sourcesRemain.match(1));
  405. sourceString = sourcesRemain.match(2);
  406. }
  407. if(sourceString != "")
  408. {
  409. m_Sources.insert(sourceString);
  410. }
  411. // If no tag was given, try to generate one.
  412. if(!tagGiven)
  413. {
  414. if(!this->GenerateTag(m_ClassName))
  415. {
  416. cmSystemTools::Error("Cannot generate tag for class name: ",
  417. m_ClassName.c_str(),
  418. "\nPlease supply one with the \"tag:..\" syntax.");
  419. }
  420. }
  421. // If there is a .h with the name of the tag, add it as a source.
  422. this->FindTagSource();
  423. // Split the class name up into portions for the combination
  424. // generation method.
  425. this->SplitClassName();
  426. }
  427. /**
  428. * Parses the class name into portions. Plain text in the string is
  429. * held by a StringPortion, and a $ token for replacement is
  430. * represented by a ReplacePortion.
  431. */
  432. void
  433. ElementCombinationGenerator
  434. ::SplitClassName()
  435. {
  436. // Break the input code into blocks alternating between literal code and
  437. // set-substitution tokens (like $SomeSetName).
  438. std::string currentPortion = "";
  439. for(std::string::const_iterator c=m_ClassName.begin();
  440. c != m_ClassName.end(); ++c)
  441. {
  442. // Look for the '$' to mark the beginning of a token.
  443. if(*c != '$')
  444. {
  445. currentPortion.insert(currentPortion.end(), *c);
  446. }
  447. else
  448. {
  449. // If there is a portion of the string, record it.
  450. if(currentPortion.length() > 0)
  451. {
  452. m_Portions.push_back(new StringPortion(currentPortion));
  453. currentPortion = "";
  454. }
  455. // Skip over the '$' character.
  456. ++c;
  457. // Get element set name token.
  458. std::string setName = this->ParseSetName(c, m_ClassName.end());
  459. // We have a complete set name. Look it up in makefile's data
  460. // collection.
  461. cmData* d = m_Makefile->LookupData(setName.c_str());
  462. // This should be a dynamic_cast, but we don't want to require RTTI.
  463. cmCableClassSet* set = static_cast<cmCableClassSet*>(d);
  464. if(set)
  465. {
  466. // We have a valid set name. Prepare the substitution entry
  467. // for it.
  468. Substitution* sub;
  469. if(m_Substitutions.count(set) == 0)
  470. {
  471. sub = new Substitution();
  472. m_Substitutions[set] = sub;
  473. }
  474. else
  475. {
  476. sub = m_Substitutions[set];
  477. }
  478. m_Portions.push_back(new ReplacePortion(*sub));
  479. setName = "";
  480. }
  481. else
  482. {
  483. // Invalid set name. Complain.
  484. cmSystemTools::Error("Unknown name of CABLE class set: ",
  485. setName.c_str());
  486. }
  487. // Let the loop look at this character again.
  488. --c;
  489. }
  490. }
  491. // If there is a final portion of the string, record it.
  492. if(currentPortion.length() > 0)
  493. {
  494. m_Portions.push_back(new StringPortion(currentPortion));
  495. }
  496. }
  497. /**
  498. * Parse out the name of a Set specified after a $ in the element's string.
  499. * This is called with "c" pointing to the first character after the $,
  500. * and "end" equal to the string's end iterator.
  501. *
  502. * Returns the set name after parsing. "c" will point to the first
  503. * character after the end of the set name.
  504. */
  505. std::string
  506. ElementCombinationGenerator
  507. ::ParseSetName(std::string::const_iterator& c, std::string::const_iterator end) const
  508. {
  509. std::string setName = "";
  510. // Check for the $(setName) syntax.
  511. // If the first character after the '$' is a left paren, we scan for the
  512. // matching paren, and take everything in-between as the set name.
  513. if((c != end) && (*c == '('))
  514. {
  515. unsigned int depth = 1;
  516. ++c;
  517. while(c != end)
  518. {
  519. char ch = *c++;
  520. if(ch == '(') { ++depth; }
  521. else if(ch == ')') { --depth; }
  522. if(depth == 0) { break; }
  523. setName.insert(setName.end(), ch);
  524. }
  525. return setName;
  526. }
  527. // The $(setName) syntax was not used.
  528. // Look for all characters that can be part of a qualified C++
  529. // identifier.
  530. while(c != end)
  531. {
  532. char ch = *c;
  533. if(((ch >= 'a') && (ch <= 'z'))
  534. || ((ch >= 'A') && (ch <= 'Z'))
  535. || ((ch >= '0') && (ch <= '9'))
  536. || (ch == '_') || (ch == ':'))
  537. {
  538. setName.insert(setName.end(), ch);
  539. ++c;
  540. }
  541. else
  542. {
  543. break;
  544. }
  545. }
  546. return setName;
  547. }
  548. /**
  549. * After the tag for an element has been determined, but before
  550. * combination expansion is done, this is called to search for a
  551. * header file in the makefile's include path with the name of the
  552. * tag. This makes specifying lists of classes that are declared in
  553. * header files with their own name very convenient.
  554. */
  555. void ElementCombinationGenerator::FindTagSource()
  556. {
  557. // If there is no tag, don't bother with this step.
  558. if(m_Tag == "")
  559. {
  560. return;
  561. }
  562. // Get the makefile's include path.
  563. const std::vector<std::string>& includePath =
  564. m_Makefile->GetIncludeDirectories();
  565. // Search the path for a file called "(m_Tag).h".
  566. for(std::vector<std::string>::const_iterator dir = includePath.begin();
  567. dir != includePath.end(); ++dir)
  568. {
  569. std::string filePath = *dir;
  570. m_Makefile->ExpandVariablesInString(filePath);
  571. filePath += "/"+m_Tag+".h";
  572. if(cmSystemTools::FileExists(filePath.c_str()))
  573. {
  574. m_Sources.insert(m_Tag+".h");
  575. return;
  576. }
  577. }
  578. }
  579. /**
  580. * Given the string representing a set element, automatically generate
  581. * the element tag for it. This function determines how the output
  582. * language of all CABLE-generated wrappers will look.
  583. */
  584. bool ElementCombinationGenerator::GenerateTag(const std::string& element)
  585. {
  586. // Hold the regular expressions for matching against the element.
  587. cmRegularExpression regex;
  588. // If the element's code begins in a $, it is referring to a set name.
  589. // The set's elements have their own tags, so we don't need one.
  590. regex.compile("^[ \t]*\\$");
  591. if(regex.find(element))
  592. { m_Tag = ""; return true; }
  593. // Test for simple integer
  594. regex.compile("^[ \t]*([0-9]*)[ \t]*$");
  595. if(regex.find(element))
  596. {
  597. m_Tag = "_";
  598. m_Tag.append(regex.match(1));
  599. return true;
  600. }
  601. // Test for basic integer type
  602. regex.compile("^[ \t]*(unsigned[ ]|signed[ ])?[ \t]*(char|short|int|long|long[ ]long)[ \t]*$");
  603. if(regex.find(element))
  604. {
  605. m_Tag = "_";
  606. if(regex.match(1) == "unsigned ")
  607. { m_Tag.append("u"); }
  608. if(regex.match(2) == "long long")
  609. { m_Tag.append("llong"); }
  610. else
  611. { m_Tag.append(regex.match(2)); }
  612. return true;
  613. }
  614. // Test for basic floating-point type
  615. regex.compile("^[ \t]*(long[ ])?[ \t]*(float|double)[ \t]*$");
  616. if(regex.find(element))
  617. {
  618. m_Tag = "_";
  619. if(regex.match(1) == "long ")
  620. m_Tag.append("l");
  621. m_Tag.append(regex.match(2));
  622. return true;
  623. }
  624. // Test for basic wide-character type
  625. regex.compile("^[ \t]*(wchar_t)[ \t]*$");
  626. if(regex.find(element))
  627. {
  628. m_Tag = "_wchar";
  629. return true;
  630. }
  631. // Test for type name (possibly with template arguments).
  632. regex.compile("^[ \t]*([A-Za-z_][A-Za-z0-9_]*)(<.*)?[ \t]*$");
  633. if(regex.find(element))
  634. {
  635. // The tag is the same as the type. If there were template arguments,
  636. // they are ignored since they may have their own tags.
  637. m_Tag = regex.match(1);
  638. return true;
  639. }
  640. // Test for a name with a single namespace qualifier.
  641. regex.compile("^[ \t]*([A-Za-z_][A-Za-z0-9_]*)::([A-Za-z_][A-Za-z0-9_]*)(<.*)?[ \t]*$");
  642. if(regex.find(element))
  643. {
  644. // The tag is the same as the namespace and type concatenated together.
  645. m_Tag = regex.match(1);
  646. m_Tag.append(regex.match(2));
  647. return true;
  648. }
  649. // We can't generate a tag.
  650. m_Tag = "";
  651. return false;
  652. }
  653. /**
  654. * Given an element in string form, parse out the information from it,
  655. * generate the combinations of set substitutions, and add all the
  656. * elements that result.
  657. */
  658. void cmCableClassSet::ParseAndAddElement(const char* in_element,
  659. cmMakefile* makefile)
  660. {
  661. // Create an object to handle the generation.
  662. ElementCombinationGenerator combinationGenerator(in_element, makefile, this);
  663. // Generate the combinations.
  664. combinationGenerator.Generate();
  665. }