![]() |
ai::ArtMatcher Class ReferenceA stack based wrapper class for inquiring about the selection and matched art over AIMatchingArtSuite. More...
Detailed DescriptionA stack based wrapper class for inquiring about the selection and matched art over AIMatchingArtSuite. Always prefer this class over directly calling APIs in AIMatchingArtSuite. Enhanced to support C++11 semantics. For example, range-based loops, move constructor and assignment, and added support for dynamic spec specification as well as automatic size computation. Example 1.1: Statically allocate spec, let ArtMatcher figure out the size, recommended approach AIMatchingArtSpec spec[] = { { kRasterArt, kArtSelected, kArtSelected}, { kPlacedArt, kArtSelected, kArtSelected} }; ArtMatcher matcher(spec); matcher.GetMatchingArt(); for(auto art: matcher) // This loop is safe even if the earlier call didn't return any art, the loop won't enter { work with art } WARNING NOTE!!! Don't create a spec array with single braces even for one element e.g, never do this, AIMatchingArtSpec now has a default constructor and it creates an array with size 3 AIMatchingArtSpec spec[] = { kRasterArt, kArtSelected, kArtSelected}; Example 1.2 Special constructor for one spec ArtMatcher matcher(AIMatchingArtSpec{ kAnyArt, kArtFullySelected, kArtFullySelected }); matcher.GetMatchingArt(); for(auto art: matcher) // This loop is safe even if the earlier call didn't return any art, the loop won't enter { work with art } Example 2: Push specs at runtime, without worrying about upfront allocation ArtMatcher matcher; matcher.PushSpec(kRasterArt, kArtSelected, kArtSelected); matcher.PushSpec(kPlacedArt, kArtSelected, kArtSelected); AIErr err = matcher.GetMatchingArt(); if(!err) { auto count = matcher.GetNumMatches(); for(decltype(count) i = 0; i < count; ++i) { auto art = matcher.GetMatchedArt(i); } } Example 3: Reserve space and set index based specs. The old way is still supported. It will work even if you don't reserve space upfront ArtMatcher matcher(1); matcher.SetSpec(0, kArtSelected, kArtSelected); AIErr err = matcher.GetMatchingArt(); ... use range based or direct access loop Example 4: Bool operator ArtMatcher matcher(spec); matcher.GetMatchingArt(); if(matcher) // Has at least one element; this check is not required for range-based loops { auto firstObject = *(matcher.begin()); } Example 5: Reverse iterator (last to first) ArtMatcher matcher(spec); matcher.GetMatchingArt(); for (auto iter = matcher.rbegin(); iter != matcher.rend(); ++iter) { auto art = *iter; } Example 6: Fetch all selected objects ArtMatcher matcher; matcher.GetSelectedArt(); for(auto art: matcher) // This loop is safe even if the earlier call didn't return any art, the loop won't enter { process selected objects } Member Enumeration DocumentationErrors returned by ai::ArtMatcher. Constructor & Destructor Documentation
Default constructor.
Constructor with one spec.
Copy is not allowed.
Move Constructor. Member Function Documentation
iterators for range based for loops Referenced by rend().
Clear the stored handles only, the spec is intact and will be used in next query. References AIMdMemorySuite::MdMemoryDisposeHandle.
iterators for range based for loops Referenced by rbegin().
Returns a stack based AIArtSet Object which can be used in APIs which needs an AIArtSet.
Get AIErr for the last query, though it is usually not required.
Returns nth AIArtHandle if the last GetMatchingArt() or GetSelectedArt() call succeeded. Referenced by operator[]().
Returns the number of art objects matched by last GetMatchingArt() or GetSelectedArt() call.
Check if the last query has some interesting data.
Move Assignment.
Assignment is not allowed.
References GetMatchedArt().
Add spec to the end. References kMatchDictionaryArt, kNoErr, and kOutOfMemoryErr.
References end().
Transfer the ownership of stored art handles, call it only if you know what you are doing.
References begin().
Set spec if size is already allocated. References kMatchDictionaryArt, and kNoErr. The documentation for this class was generated from the following files: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||