-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [cxx-parser] Add SimpleType.lenOfArrayType extension
- Loading branch information
1 parent
4247ef7
commit 91080bd
Showing
4 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
export {}; | ||
|
||
declare global { | ||
export interface String { | ||
/** | ||
* This function removes the namespace from a fully qualified name. | ||
* For example, "foo::bar" becomes "bar". | ||
*/ | ||
trimNamespace(): string; | ||
|
||
/** | ||
* Returns the namespace of the class name. | ||
* | ||
* Example: "std::vector::size_type" returns "std::vector" | ||
*/ | ||
getNamespace(): string; | ||
} | ||
} | ||
|
||
/** | ||
* This function removes the namespace from a fully qualified name. | ||
* For example, "foo::bar" becomes "bar". | ||
*/ | ||
String.prototype.trimNamespace = function (): string { | ||
if (this.length === 0) { | ||
return ''; | ||
} | ||
|
||
if (!this.includes('::')) { | ||
return this as string; | ||
} | ||
|
||
const splitted = this.split('::'); | ||
return splitted[splitted.length - 1]; | ||
}; | ||
|
||
/** | ||
* Returns the namespace of the class name. | ||
* | ||
* Example: "std::vector::size_type" returns "std::vector" | ||
*/ | ||
String.prototype.getNamespace = function (): string { | ||
if (this.length === 0) { | ||
return ''; | ||
} | ||
|
||
if (!this.includes('::')) { | ||
return ''; | ||
} | ||
|
||
const splitted = this.split('::'); | ||
return Array.from(splitted.slice(0, splitted.length - 1)).join('::'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters