#!/usr/bin/env python

import clang.cindex
import sys
import os
import json
import logging
import argparse
import fnmatch

from DotGenerator import *

index = clang.cindex.Index.create()
dotGenerator = DotGenerator()


def splitCommand(command):
    args = command.split()

    includes_list = [x for x in args if "-I" in x]

    indecies = [(i, i + 1) for i, x in enumerate(args)
            if "-isystem" in x]

    for x, y in indecies:
        includes_list.append(args[y])

    return includes_list


def findFilesInDir(rootDir, patterns):
from DotGenerator import *

import sys

dot = DotGenerator()

privateFields=[("aa", "int"),("bb","void*"),("cc","NS1::BClass"),("dd", "void")]
privateMethods=[("void", "privateMethod1", "(asdds, dss*)"), ("BClass", "privateMethod2", "(asdf)")]
publicFields=[("publicField1","CClass"), ("publicField2", "none")]
publicMethods=[("void", "publicMethod1", "(asdds, dss*)"), ("BClass", "publicMethod2", "(asdf)")]

c1 = UmlClass()
c1.fqn = "NS1::AClass"
c1.privateFields = privateFields
c1.privateMethods = privateMethods
c1.publicFields = publicFields
c1.publicMethods = publicMethods
dot.addClass(c1)

c2 = UmlClass()
c2.fqn = "NS1::BClass"
c2.parents.append(c1.fqn)
dot.addClass(c2)

c3 = UmlClass()
c3.fqn = "CClass"
dot.addClass(c3)

outputDotFile = ['uml2.dot', sys.argv[1]][len(sys.argv) == 2]

with open(outputDotFile, "w") as dotfile:
from DotGenerator import *

import sys

dot = DotGenerator()
dot.setDrawInheritances(True)
dot.setDrawAssociations(True)
dot.setShowPrivMethods(True)
dot.setShowProtMethods(True)
dot.setShowPubMethods(True)

c1 = UmlClass()
c1.fqn = "NS1::AClass"
c1.addField("aa", "int", private)
c1.addField("bb", "void*", private)
c1.addField("cc", "NS1::BClass", private)
c1.addField("dd", "void", private)
c1.addField("publicField1", "CClass", public)
c1.addField("publicField2", "none", public)

c1.addMethod("void", "privateMethod1", "(asdds, dss*)", private)
c1.addMethod("BClass", "privateMethod2", "(asdf)", private)
c1.addMethod("void", "publicMethod1", "(asdds, dss*)", public)
c1.addMethod("BClass", "publicMethod2", "(asdf)", public)
dot.addClass(c1)

c2 = UmlClass()
c2.fqn = "NS1::BClass"
c2.parents.append(c1.fqn)
dot.addClass(c2)
#!/usr/bin/env python

import clang.cindex
import sys
import os
import logging
import argparse
import fnmatch

from DotGenerator import *

index = clang.cindex.Index.create()
dotGenerator = DotGenerator()


def findFilesInDir(rootDir, patterns):
    """ Searches for files in rootDir which file names mathes the given pattern. Returns
    a list of file paths of found files"""
    foundFiles = []
    for root, dirs, files in os.walk(rootDir):
        for p in patterns:
            for filename in fnmatch.filter(files, p):
                foundFiles.append(os.path.join(root, filename))
    return foundFiles


def processClassField(cursor):
    """ Returns the name and the type of the given class field.
    The cursor must be of kind CursorKind.FIELD_DECL"""
    type = None
    fieldChilds = list(cursor.get_children())
from DotGenerator import *

import sys

dot = DotGenerator()

privateFields = [("aa", "int"), ("bb", "void*"), ("cc", "NS1::BClass"),
                 ("dd", "void")]
privateMethods = [("void", "privateMethod1", "(asdds, dss*)"),
                  ("BClass", "privateMethod2", "(asdf)")]
publicFields = [("publicField1", "CClass"), ("publicField2", "none")]
publicMethods = [("void", "publicMethod1", "(asdds, dss*)"),
                 ("BClass", "publicMethod2", "(asdf)")]

c1 = UmlClass()
c1.fqn = "NS1::AClass"
c1.privateFields = privateFields
c1.privateMethods = privateMethods
c1.publicFields = publicFields
c1.publicMethods = publicMethods
dot.addClass(c1)

c2 = UmlClass()
c2.fqn = "NS1::BClass"
c2.parents.append(c1.fqn)
dot.addClass(c2)

c3 = UmlClass()
c3.fqn = "CClass"
dot.addClass(c3)
#!/usr/bin/env python

import clang.cindex
import sys
import os
import logging
import argparse
import fnmatch

from DotGenerator import *

index = clang.cindex.Index.create()
dotGenerator = DotGenerator()


def findFilesInDir(rootDir, patterns):
    """ Searches for files in rootDir which file names mathes the given pattern. Returns
    a list of file paths of found files"""
    foundFiles = []
    for root, dirs, files in os.walk(rootDir):
        for p in patterns:
            for filename in fnmatch.filter(files, p):
                foundFiles.append(os.path.join(root, filename))
    return foundFiles


def processClassField(cursor):
    """ Returns the name and the type of the given class field.
    The cursor must be of kind CursorKind.FIELD_DECL"""
    type = None
    fieldChilds = list(cursor.get_children())