Adobe.com
Contents Suites Classes Class Index Member Index

AIAutoNameGenerator Struct Reference

Information about the kind of names allowed for a named entity (such as layers, swatches, and styles). More...

#include <AIUser.h>

List of all members.

Public Attributes

ai::int32 maximumLength
 The maximum length for names in the collection, a number of ASUnicode elements.
AIBoolean uniqueNames
 True if names in the collection must be unique.
ai::UnicodeString baseName
 A base for generating names, a Unicode-encoded string.
ai::int32 nextNewNameIndex
 The index to use for the next new name generated.
AIAPI AIErr(* HasName )(AIAutoNameGenerator &self, const ai::UnicodeString &name, AIBoolean &hasit)
 A callback function to determine whether a given name is already in the set.

Detailed Description

Information about the kind of names allowed for a named entity (such as layers, swatches, and styles).

Used to generate a legal name, using AIUserSuite::NextName() and AIUserSuite::CopyOfName().

The following pseudocode indicates how you can create your own AutoNameGenerator class by publicly inheriting AIAutoNameGenerator and following the implementation guidelines.

        class AutoNameGenerator : public AIAutoNameGenerator {
        public:
                // Constructor for a name generator. Its supplied with the pluginref in
                // case the name generator needs to look in the plugin's resources e.g for
                // the default name. The next new name index is supplied since the plugin
                // probably needs to store this in its globals so that it can be preserved
                // across unload and reload.
                AutoNameGenerator (SPPluginRef pluginref, int nextNameIndex)
                {
                        // fill in fDefaultName
                        GetDefaultName(pluginref);

                        // initialize the base members
                        // note kMaxCollectionStringLength accounts for null terminator and maximumLength does not
                        maximumLength = kMaxCollectionStringLength-1;
                        uniqueNames = true;
                        baseName = fDefaultName;
                        nextNewNameIndex = nextNameIndex;
                        HasName = sHasName;
                }

        private:
                void GetDefaultName (SPPluginRef pluginref)
                {
                        // Somehow initialize fDefaultName with the default name for the
                        // collection. The pluginref is probably needed in order to look
                        // up the name in the plugin resources.
                }

                AIErr hasName (const ai::UnicodeString &name, AIBoolean &hasit)
                {
                        // Code to answer the question. When comparing 'name' against
                        // names of objects in the collection it's important to use the
                        // AIUserSuite::SameName() API. The name generation process does
                        // not use a simple string comparison.
                }

                static AIAPI AIErr sHasName (AIAutoNameGenerator &self, const ai::UnicodeString &name, AIBoolean &hasit)
                {
                        return static_cast<AutoNameGenerator&>(self).hasName(name, hasit);
                }

                ai::UnicodeString fDefaultName;
        };

Member Data Documentation

A base for generating names, a Unicode-encoded string.

A callback function to determine whether a given name is already in the set.

Use AIUserSuite::SameName() to compare names, not simple string equality.

Parameters:
self This structure.
name The name to test.
hasit [out] An AIBoolean reference in which to return true if the name is already in the collection.
Returns:
An error to abort name generation; the error code is returned to the caller.

The maximum length for names in the collection, a number of ASUnicode elements.

Excludes the null terminator.

The index to use for the next new name generated.

Name generation functions automatically increment the index.

True if names in the collection must be unique.


The documentation for this struct was generated from the following file:


Contents Suites Classes Class Index Member Index
Adobe Solutions Network
 
Copyright © 2016 Adobe Systems Incorporated. All rights reserved.
Terms of Use Online Privacy Policy Adobe and accessibility Avoid software piracy Permissions and Trademarks