forked from appsquickly/XcodeEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXCClassDefinition.m
More file actions
executable file
·105 lines (81 loc) · 2.69 KB
/
XCClassDefinition.m
File metadata and controls
executable file
·105 lines (81 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
////////////////////////////////////////////////////////////////////////////////
//
// JASPER BLUES
// Copyright 2012 - 2013 Jasper Blues
// All Rights Reserved.
//
// NOTICE: Jasper Blues permits you to use, modify, and distribute this file
// in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
#import "XCClassDefinition.h"
@implementation XCClassDefinition
@synthesize className = _className;
@synthesize header = _header;
@synthesize source = _source;
/* ====================================================================================================================================== */
#pragma mark - Class Methods
+ (XCClassDefinition*)classDefinitionWithName:(NSString*)fileName
{
return [[XCClassDefinition alloc] initWithName:fileName];
}
+ (XCClassDefinition*)classDefinitionWithName:(NSString*)className language:(ClassDefinitionLanguage)language
{
return [[XCClassDefinition alloc] initWithName:className language:language];
}
/* ====================================================================================================================================== */
#pragma mark - Initialization & Destruction
- (id)initWithName:(NSString*)className
{
return [self initWithName:className language:ObjectiveC];
}
- (id)initWithName:(NSString*)className language:(ClassDefinitionLanguage)language
{
self = [super init];
if (self)
{
_className = [className copy];
if (!(language == ObjectiveC || language == ObjectiveCPlusPlus || language == CPlusPlus))
{
[NSException raise:NSInvalidArgumentException format:@"Language must be one of ObjectiveC, ObjectiveCPlusPlus"];
}
_language = language;
}
return self;
}
/* ====================================================================================================================================== */
#pragma mark - Interface Methods
- (BOOL)isObjectiveC
{
return _language == ObjectiveC;
}
- (BOOL)isObjectiveCPlusPlus
{
return _language == ObjectiveCPlusPlus;
}
- (BOOL)isCPlusPlus
{
return _language == CPlusPlus;
}
- (NSString*)headerFileName
{
return [_className stringByAppendingString:@".h"];
}
- (NSString*)sourceFileName
{
NSString* sourceFileName = nil;
if ([self isObjectiveC])
{
sourceFileName = [_className stringByAppendingString:@".m"];
}
else if ([self isObjectiveCPlusPlus])
{
sourceFileName = [_className stringByAppendingString:@".mm"];
}
else if ([self isCPlusPlus])
{
sourceFileName = [_className stringByAppendingString:@".cpp"];
}
return sourceFileName;
}
@end