ACAPI_​Element_​GetNoteAutotexts

Returns a map that contains an element type set for every available autotext regards to the note owner’s type.

    GSErrCode  ACAPI_Element_GetNoteAutotexts (
        const API_ElemType&     noteOwnerType,
        std::unordered_map<API_NoteAutotextID, std::unordered_set<API_ElemType>>&     elemTypesForAutotextIDs,
        const GS::Optional<API_AppearID>&     dimAppear = GS::NoValue
    );

 

Parameters

noteOwnerType
[in] The note owner’s type.
elemTypesForAutotextIDs
[out] The result map for the note owner’s type. The autotext is evaluable for the note if the parent element type is contained by the set. The empty set means the autotext is generally evaluable.
dimAppear
[in] The dimAppear is an optional parameter. It is only needed when the note owner’s type is API_DimensionID.

 

Return Values

APIERR_BADID
The given element type is not a note owner type or if it is API_DimensionID then the given dimAppear is nullptr.

For other common API errors see the API Errors document.

 

Remarks

This function is used to get a map for the note owner that contains every available autotexts and on which elements are they evaluable. The empty element type set means the autotext is generally evaluable.

 

Example


void	Do_LevelDimension_Edit ()
{
    API_Element element = {}, mask;

    if (!ClickAnElem ("Click a dimension to modify", API_LevelDimensionID, nullptr, &element.header.type, &element.header.guid)) {
        WriteReport_Alert ("No level dimension was clicked");
        return;
    }

    GSErrCode err = ACAPI_Element_Get (&element);
    if (err != NoError) {
        return;
    }

    ACAPI_ELEMENT_MASK_CLEAR (mask);
    ACAPI_ELEMENT_MASK_SET (mask, API_LevelDimensionType, note1.contentType);
    ACAPI_ELEMENT_MASK_SET (mask, API_LevelDimensionType, note1.contentUStr);

    element.levelDimension.note1.contentType = API_NoteContent_Custom;

    auto buildContentWithAllAvailableAutotexts = [&element] () -> GS::UniString {
        std::unordered_map<API_NoteAutotextID, std::unordered_set<API_ElemType>> autotextMap;
		const GSErrCode err = ACAPI_Element_GetNoteAutotexts (API_LevelDimensionID, autotextMap);
		if (err != NoError) {
			return "Custom";
		}

		GS::UniString content;
		for (auto& pairItem : autotextMap) {
			const API_NoteAutotextID autotextID = pairItem.first;
			const std::unordered_set<API_ElemType>& currentSet = pairItem.second;

			const bool isGeneralOrParentElemTypeSpecificAutotext =
				currentSet.empty () ||
				currentSet.find (element.levelDimension.parentType) != currentSet.end ();
			if (!isGeneralOrParentElemTypeSpecificAutotext) {
				continue;
			}
			GS::UniString keyword;
			ACAPI_Element_GetNoteKeywordForAutotextID (autotextID, keyword);

			if (!content.IsEmpty ()) {
				const GS::UniString separator = " ";
				content += separator;
			}
			content += keyword;
		}
		return content;
	};

	GS::UniString content = buildContentWithAllAvailableAutotexts ();
	element.levelDimension.note1.contentUStr = &content;

	err = ACAPI_Element_Change (&element, &mask, nullptr, 0, true);
}		// Do_LevelDimension_Edit

 

Requirements

Version: API 26 or later
Header: ACAPinc.h

See Also

API_NoteAutotextID, ACAPI_Element_GetNoteKeywordForAutotextID, API_NoteType
API Functions