repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
KhunLam/OC-weibo
OC_weibo/OC_weibo/Classes/Module/Discover/Controller/LKDiscoverViewController.h
<reponame>KhunLam/OC-weibo // // LKDiscoverViewController.h // OC_weibo // // Created by lamkhun on 15/10/27. // Copyright © 2015年 lamKhun. All rights reserved. // #import "LKBaseTableViewController.h" @interface LKDiscoverViewController : LKBaseTableViewController @end
KhunLam/OC-weibo
OC_weibo/OC_weibo/Classes/Module/Main/Controller/LKBaseTableViewController.h
// // LKBaseTableViewController.h // OC_weibo // // Created by lamkhun on 15/10/27. // Copyright © 2015年 lamKhun. All rights reserved. // #import <UIKit/UIKit.h> #import "LKVistorView.h" @interface LKBaseTableViewController : UITableViewController @end
KhunLam/OC-weibo
OC_weibo/OC_weibo/Classes/Module/Main/Controller/LKTabBarViewController.h
// // LKTabBarViewController.h // OC_weibo // // Created by lamkhun on 15/10/26. // Copyright © 2015年 lamKhun. All rights reserved. // #import <UIKit/UIKit.h> #import <Foundation/Foundation.h> @interface LKTabBarViewController : UITabBarController @end
KhunLam/OC-weibo
OC_weibo/OC_weibo/Classes/Module/Profile/Controller/LKProfileViewController.h
// // LKProfileViewController.h // OC_weibo // // Created by lamkhun on 15/10/27. // Copyright © 2015年 lamKhun. All rights reserved. // #import "LKBaseTableViewController.h" @interface LKProfileViewController : LKBaseTableViewController @end
RJL22/repetitive-dna
tests/test.c
<gh_stars>0 #include <stdio.h> #include "../src/sequence_repetition.h" #include "../src/sequence_repetition.h" //Compile code: gcc test.c ../src/sequence_repetition.c ../src/integer_array.c int main() { int index = findDNARepetition("ABAABABBABABA", "BBAB"); printf("Index of Repetition: %d\n", index); struct IntegerArray* indices = findAllDNARepetitions("BABABABA", "BA"); struct Node* current = indices->root; for (int i = 0; i < indices->count; i++) { printf("Index: %d\n", current->value); current = current->next_node; } }
RJL22/repetitive-dna
src/sequence_repetition.h
#ifndef SEQUENCE_REPETITION_H #define SEQUENCE_REPETITION_H #include <math.h> #include <string.h> #include <stdio.h> #include "integer_array.h" #define PRIME_MODULUS 101 //Returns the index of the first repetition int findDNARepetition(const char* sequence, const char* motif); //Returns indices of all repetitions struct IntegerArray* findAllDNARepetitions(const char* sequence, const char* motif); #endif
RJL22/repetitive-dna
src/integer_array.h
<reponame>RJL22/repetitive-dna<filename>src/integer_array.h #ifndef INTEGER_ARRAY_H #define INTEGER_ARRAY_H #include <stdlib.h> struct Node { int value; struct Node* next_node; }; struct IntegerArray { int count; struct Node* root; struct Node* end; }; void addItem(struct IntegerArray* integerArray, int newValue); void deleteIntegerArray(struct IntegerArray* integerArray); #endif
RJL22/repetitive-dna
src/sequence_repetition.c
#include "sequence_repetition.h" static int getSequenceHash(const char* sequence) { int hash = sequence[0]; for (int i = 1; i < strlen(sequence); i++) { hash = (hash * 256) % PRIME_MODULUS; hash += sequence[i]; } hash = hash % PRIME_MODULUS; return hash; } int findDNARepetition(const char* sequence, const char* motif) { int r = getSequenceHash(motif); //First characters of the sequence char possibleSub[strlen(motif) + 1]; strncpy(possibleSub, sequence, strlen(motif)); possibleSub[strlen(motif)] = '\0'; int h = getSequenceHash(possibleSub); int leftBaseOffset = 1; for (int i = 0; i < strlen(motif) - 1; i++) { leftBaseOffset = (leftBaseOffset * 256) % PRIME_MODULUS; } //Computing rolling hash for (int i = 0; i < strlen(sequence) - strlen(motif) + 1; i++) { if (r == h) { strncpy(possibleSub, sequence + i, strlen(motif)); if (strcmp(motif, possibleSub) == 0) { return i; } } h += PRIME_MODULUS - ((leftBaseOffset * sequence[i]) % PRIME_MODULUS); h *= 256; h += sequence[i + strlen(motif)]; h = h % PRIME_MODULUS; if (h < 0) { h += PRIME_MODULUS; } } return -1; } struct IntegerArray* findAllDNARepetitions(const char* sequence, const char* motif) { int r = getSequenceHash(motif); //First characters of the sequence char possibleSub[strlen(motif) + 1]; strncpy(possibleSub, sequence, strlen(motif)); possibleSub[strlen(motif)] = '\0'; int h = getSequenceHash(possibleSub); int leftBaseOffset = 1; for (int i = 0; i < strlen(motif) - 1; i++) { leftBaseOffset = (leftBaseOffset * 256) % PRIME_MODULUS; } struct IntegerArray* integerArray = malloc(sizeof(struct IntegerArray)); integerArray->count = 0; //Computing rolling hash for (int i = 0; i < strlen(sequence) - strlen(motif) + 1; i++) { if (r == h) { strncpy(possibleSub, sequence + i, strlen(motif)); if (strcmp(motif, possibleSub) == 0) { addItem(integerArray, i); } } h += PRIME_MODULUS - ((leftBaseOffset * sequence[i]) % PRIME_MODULUS); h *= 256; h += sequence[i + strlen(motif)]; h = h % PRIME_MODULUS; if (h < 0) { h += PRIME_MODULUS; } } return integerArray; }
RJL22/repetitive-dna
src/integer_array.c
#include "integer_array.h" void addItem(struct IntegerArray* integerArray, int newValue) { if (integerArray->count == 0) { struct Node* new_node = malloc(sizeof(struct Node)); new_node->value = newValue; new_node->next_node = NULL; integerArray->root = new_node; integerArray->end = new_node; } else { struct Node* new_node = malloc(sizeof(struct Node)); new_node->value = newValue; new_node->next_node = NULL; integerArray->end->next_node = new_node; integerArray->end = new_node; } integerArray->count++; } void deleteIntegerArray(struct IntegerArray* integerArray) { struct Node* currentNode = integerArray->root; struct Node* next = currentNode; do { next = currentNode->next_node; free(currentNode); currentNode = next; } while (currentNode->next_node != NULL); }
RJL22/repetitive-dna
src/repetitive_dna.h
#ifndef REPETITIVE_DNA_H #define REPETITIVE_DNA_H #include "integer_array.h" #include "sequence_repetition.h" #endif
markcaudill/mwc6502
Bus_Monitor/65C02S_Mnemonics.h
<gh_stars>0 #ifndef _65C02S_MNEMONICS_H #define _65C02S_MNEMONICS_H const char *mnemonic[0xFF + 1] = { "BRK", // 00 "ORA", // 01 "", // 02 "", // 03 "TSB", // 04 "ORA", // 05 "ASL", // 06 "RMV0", // 07 "PHP", // 08 "ORA", // 09 "ASL", // 0a "", // 0b "TSP", // 0c "ORA", // 0d "ASL", // 0e "BBR0", // 0f "BPL", // 10 "ORA", // 11 "ORA", // 12 "", // 13 "TRB", // 14 "ORA", // 15 "ASL", // 16 "RMB1", // 17 "CLC", // 18 "ORA", // 19 "INC", // 1a "", // 1b "TRB", // 1c "ORA", // 1d "ASL", // 1e "BBR1", // 1f "JSR", // 20 "AND", // 21 "", // 22 "", // 23 "BIT", // 24 "AND", // 25 "ROL", // 26 "RMB2", // 27 "PLP", // 28 "AND", // 29 "ROL", // 2a "", // 2b "BIT", // 2c "AND", // 2d "ROL", // 2e "BBR2", // 2f "BMI", // 30 "AND", // 31 "AND", // 32 "", // 33 "BIT", // 34 "AND", // 35 "ROL", // 36 "RMB3", // 37 "SEC", // 38 "AND", // 39 "DEC", // 3a "", // 3b "BIT", // 3c "AND", // 3d "ROL", // 3e "BBR3", // 3f "RTI", // 40 "EOR", // 41 "", // 42 "", // 43 "", // 44 "EOR", // 45 "LSR", // 46 "RMB4", // 47 "PHA", // 48 "EOR", // 49 "LSR", // 4a "", // 4b "JMP", // 4c "EOR", // 4d "LST", // 4e "BBR4", // 4f "BVC", // 50 "EOR", // 51 "EOR", // 52 "", // 53 "", // 54 "EOR", // 55 "LSR", // 56 "RMB5", // 57 "CLI", // 58 "EOR", // 59 "PHY", // 5a "", // 5b "", // 5c "EOR", // 5d "LSR", // 5e "BBR5", // 5f "RTS", // 60 "ADC", // 61 "", // 62 "", // 63 "STZ", // 64 "ADC", // 65 "ROR", // 66 "RMB6", // 67 "PLA", // 68 "ADC", // 69 "ROR", // 6a "", // 6b "JMP", // 6c "ADC", // 6d "ROR", // 6e "BBR6", // 6f "BVS", // 70 "ADC", // 71 "ADC", // 72 "", // 73 "STZ", // 74 "ADC", // 75 "ROR", // 76 "RMB7", // 77 "SEI", // 78 "ADC", // 79 "PLY", // 7a "", // 7b "JMP", // 7c "ADC", // 7d "ROR", // 7e "BBR7", // 7f "BRA", // 80 "STA", // 81 "", // 82 "", // 83 "STY", // 84 "STA", // 85 "STZ", // 86 "SMB0", // 87 "DEY", // 88 "BIT", // 89 "TXA", // 8a "", // 8b "STY", // 8c "STA", // 8d "STX", // 8e "BBS0", // 8f "BCC", // 90 "STA", // 91 "STA", // 92 "", // 93 "STY", // 94 "STA", // 95 "STZ", // 96 "SMB1", // 97 "TYA", // 98 "STA", // 99 "TSX", // 9a "", // 9b "STZ", // 9c "STA", // 9d "STZ", // 9e "BBS1", // 9f "LDY", // a0 "LDA", // a1 "LDX", // a2 "", // a3 "LDY", // a4 "LDA", // a5 "LDX", // a6 "SMB2", // a7 "TAY", // a8 "LDA", // a9 "TAX", // aa "", // ab "LDY", // ac "LDA", // ad "LDX", // ae "BBS2", // af "BCS", // b0 "LDA", // b1 "LDA", // b2 "", // b3 "LDY", // b4 "LDA", // b5 "LDX", // b6 "SMB3", // b7 "CLV", // b8 "LDA", // b9 "TSX", // ba "", // bb "LDY", // bc "LDA", // bd "LDX", // be "BBS3", // bf "CPY", // c0 "CMP", // c1 "", // c2 "", // c3 "CPY", // c4 "CMP", // c5 "DEC", // c6 "SMB4", // c7 "INY", // c8 "CMP", // c9 "DEX", // ca "WAI", // cb "CPY", // cc "CMP", // cd "DEC", // ce "BBS4", // cf "BNE", // d0 "CMP", // d1 "CMP", // d2 "", // d3 "", // d4 "CMP", // d5 "DEC", // d6 "SMB5", // d7 "CLD", // d8 "CMP", // d9 "PHX", // da "STP", // db "", // dc "CMP", // dd "DEC", // de "BBS5", // df "CPX", // e0 "SBC", // e1 "", // e2 "", // e3 "CPX", // e4 "SBC", // e5 "INC", // e6 "SMB6", // e7 "INX", // e8 "SBC", // e9 "NOP", // ea "", // eb "CPX", // ec "SBC", // ed "INC", // ee "BBS6", // ef "BEQ", // f0 "SBC", // f1 "SBC", // f2 "", // f3 "", // f4 "SBC", // f5 "INC", // f6 "SMB7", // f7 "SED", // f8 "SBC", // f9 "PLX", // fa "", // fb "", // fc "SBC", // fd "INC", // fe "BBS7" // ff }; #endif
gabrielganzer/ARM
shop_list/sample.c
<filename>shop_list/sample.c /*---------------------------------------------------------------------------- * Name: sample.c * * This software is supplied "AS IS" without warranties of any kind. * * Copyright (c) 2019 Politecnico di Torino. All rights reserved. *----------------------------------------------------------------------------*/ #include <stdio.h> #include "LPC17xx.h" /* LPC17xx definitions */ #include "led.h" #include "button.h" #include "timer.h" #include "adc_dac.h" #define MAX 50 const int N = 60; const int M = 8; unsigned int key1, key2; int sum1, sum2; extern int sequentialSearch(unsigned int *var0, unsigned int *var1, const int *var2, const int *var3); extern int binarySearch(unsigned int *var0, unsigned int *var1, const int *var2, const int *var3); unsigned int PriceList[60] = {0x004, 20, 0x006, 15, 0x007, 10, 0x00A, 5, 0x010, 8, 0x012, 7, 0x016, 22, 0x017, 17, 0x018, 38, 0x01A, 22, 0x01B, 34, 0x01E, 11, 0x022, 3, 0x023, 9, 0x025, 40, 0x027, 12, 0x028, 11, 0x02C, 45, 0x02D, 10, 0x031, 40, 0x033, 45, 0x035, 9, 0x036, 11, 0x039, 12, 0x03C, 19, 0x03E, 1, 0x041, 20, 0x042, 30, 0x045, 12, 0x047, 7}; unsigned int ItemList[8] = {0x022, 4, 0x006, 1, 0x03E, 10, 0x017, 2}; /*---------------------------------------------------------------------------- Main Program *----------------------------------------------------------------------------*/ int main (void) { // Uncomment the instructions (and add others) according to your needs //LED_init(); /* LED Initialization */ BUTTON_init(); /* BUTTON Initialization */ init_timer(0,0x0EE6B280); /* TIMER0 Initialization */ init_timer(1,0x02FAF080); /* TIMER0 Initialization */ //enable_timer(0); //ADC_init(); DAC_init(); //LPC_SC->PCON |= 0x1; /* power-down mode */ //LPC_SC->PCON &= 0xFFFFFFFFD; //SCB->SCR |= 0x2; /* set SLEEPONEXIT */ //ADC_start_conversion(); //__ASM("wfi"); while(1){ if (key1){ key1 = 0; if (M>MAX) { enable_timer(0); enable_timer(1); } else { sum1 = sequentialSearch(PriceList, ItemList, &N, &M); } } else if (key2){ key2 = 0; if (M>MAX) { enable_timer(0); enable_timer(1); } else { sum2 = binarySearch(PriceList, ItemList, &N, &M); } } else{ disable_timer(0); reset_timer(1); } } }
gabrielganzer/ARM
shop_list/IRQ_button.c
#include "button.h" #include "lpc17xx.h" extern unsigned int key1, key2; void EINT0_IRQHandler (void) { LPC_SC->EXTINT |= (1 << 0); /* clear pending interrupt */ } void EINT1_IRQHandler (void) { key1 = 1; LPC_SC->EXTINT |= (1 << 1); /* clear pending interrupt */ } void EINT2_IRQHandler (void) { key2 = 1; LPC_SC->EXTINT |= (1 << 2); /* clear pending interrupt */ }
gabrielganzer/ARM
slot_machine/main/sample.c
<reponame>gabrielganzer/ARM /*---------------------------------------------------------------------------- * Name: sample.c * Purpose: to control led through EINT buttons * Note(s): *---------------------------------------------------------------------------- * * This software is supplied "AS IS" without warranties of any kind. * * Copyright (c) 2019 <NAME>. All rights reserved. *----------------------------------------------------------------------------*/ #include <stdio.h> #include "LPC17xx.h" /* LPC17xx definitions */ #include "../LED/led.h" #include "../button/button.h" #include "../timer/timer.h" extern unsigned int timer1, timer2, timer3, wheel1, wheel2, wheel3; /*---------------------------------------------------------------------------- Main Program *----------------------------------------------------------------------------*/ /******************************** Exercise 1 *********************************/ int main (void) { LED_init(); /* LED Initialization */ BUTTON_init(); /* BUTTON Initialization */ //init_timer(0,0x023C3460); /* TIMER0 Initialization */ init_timer(0,0x00000060); /* TIMER0 Initialization */ LED_On(8); while (1) { /* Loop forever */ __ASM("wfi"); } } /******************************** Exercise 2 *********************************/ //int main (void) //{ // LED_init(); /* LED Initialization */ // BUTTON_init(); /* BUTTON Initialization */ // wheel1 = 2; // wheel2 = 2; // wheel3 = 2; // random(); // while (1) { /* Loop forever */ // } //}
gabrielganzer/ARM
shop_list/IRQ_timer.c
/********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: IRQ_timer.c ** Descriptions: interrupt handlers of Timer/Counter 0 and 1 ** Correlated files: timer.h **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ #include "lpc17xx.h" #include "timer.h" uint16_t SinTable[45] = { 410, 467, 523, 576, 627, 673, 714, 749, 778, 799, 813, 819, 817, 807, 789, 764, 732, 694, 650, 602, 550, 495, 438, 381, 324, 270, 217, 169, 125, 87 , 55 , 30 , 12 , 2 , 0 , 6 , 20 , 41 , 70 , 105, 146, 193, 243, 297, 353 }; void TIMER0_IRQHandler (void) { static int ticks = 0; /* DAC management */ LPC_DAC->DACR = (SinTable[ticks]) << 6; ticks ++; if (ticks == 45) ticks=0; LPC_TIM0->IR = 1; /* clear interrupt flag */ return; } void TIMER1_IRQHandler (void) { LPC_DAC->DACR = 0; disable_timer(0); disable_timer(1); LPC_TIM1->IR = 1; /* clear interrupt flag */ return; }
gabrielganzer/ARM
slot_machine/button/button.h
<gh_stars>1-10 void BUTTON_init(void); void BUTTON_debounce(void); void EINT1_IRQHandler(void); void EINT2_IRQHandler(void); void EINT3_IRQHandler(void); void random(void);
gabrielganzer/ARM
simon_game/button/IRQ_button.c
#include "button.h" #include "lpc17xx.h" #include "../led/led.h" unsigned int button, pressed; void EINT0_IRQHandler (void) { button = 0; pressed = 1; LPC_SC->EXTINT |= (1 << 0); /* clear pending interrupt */ } void EINT1_IRQHandler (void) { button = 1; pressed = 1; LPC_SC->EXTINT |= (1 << 1); /* clear pending interrupt */ } void EINT2_IRQHandler (void) { button = 2; pressed = 1; LPC_SC->EXTINT |= (1 << 2); /* clear pending interrupt */ }
gabrielganzer/ARM
arm_c/led.c
<gh_stars>1-10 /********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: lib_led.c ** Last modified Date: 2019-11-26 ** Last Version: V1.00 ** Descriptions: Atomic led init functions ** Correlated files: **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ #include "LPC17xx.h" #include "led.h" /*---------------------------------------------------------------------------- Function that initializes LEDs and switch them on/off *----------------------------------------------------------------------------*/ void LED_init(void) { LPC_PINCON->PINSEL4 &= 0xFFFF0000; // PIN mode GPIO: P2.0-P2.7 are set to zero LPC_GPIO2->FIODIR |= 0x000000FF; // P2.0-P2.7 on PORT2 defined as Output } void LED_deinit(void) { LPC_GPIO2->FIODIR &= 0xFFFFFF00; } void all_LED_on(void) { LPC_GPIO2->FIOSET = 0x000000FF; } void all_LED_off(void) { LPC_GPIO2->FIOCLR = 0x000000FF; }
gabrielganzer/ARM
arm_c/sample.c
/*---------------------------------------------------------------------------- * Name: sample.c * Purpose: to control led through EINT buttons * Note(s): *---------------------------------------------------------------------------- * * This software is supplied "AS IS" without warranties of any kind. * * Copyright (c) 2019 <NAME>. All rights reserved. *----------------------------------------------------------------------------*/ #include <stdio.h> #include "LPC17xx.H" /* LPC17xx definitions */ #include "led.h" /*---------------------------------------------------------------------------- Main Program *----------------------------------------------------------------------------*/ int main (void) { LED_init(); led4and11_On(); led4_Off(); ledEvenOn_OddOf(); LED_On(4); LED_On(6); LED_Off(4); LED_Off(11); while (1); /* Loop forever */ }
gabrielganzer/ARM
slot_machine/button/IRQ_button.c
/********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: IRQ_button.c ** Last modified Date: 2019-12-05 ** Last Version: V1.00 ** Descriptions: Exercise 1 and Exercise 2 ** Correlated files: **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ #include "lpc17xx.h" #include "../LED/led.h" #include "../button/button.h" #include "../timer/timer.h" /********************************************* Exercise 1 **********************************************/ extern unsigned int led_value; unsigned int pressed, button; void EINT0_IRQHandler (void) { pressed = LPC_GPIO2->FIOPIN & (1<<10); NVIC_DisableIRQ(EINT0_IRQn); button = 1; enable_timer(0); BUTTON_debounce(); LPC_SC->EXTINT |= (1 << 0); /* clear pending interrupt */ } void EINT1_IRQHandler (void) { pressed = LPC_GPIO2->FIOPIN & (1<<11); NVIC_DisableIRQ(EINT1_IRQn); button = 2; enable_timer(0); BUTTON_debounce(); if (button == 1) { LED_Off(led_value--); LED_On(led_value); if(led_value == 4) led_value = 11; } LPC_SC->EXTINT |= (1 << 1); /* clear pending interrupt */ } void EINT2_IRQHandler (void) { pressed = LPC_GPIO2->FIOPIN & (1<<12); NVIC_DisableIRQ(EINT2_IRQn); button = 3; BUTTON_debounce(); LED_Off(led_value++); LED_On(led_value); if(led_value == 11) led_value = 4; LPC_SC->EXTINT |= (1 << 2); /* clear pending interrupt */ } /********************************************* Exercise 2 **********************************************/ //unsigned int timer1, timer2, timer3, wheel1, wheel2, wheel3; //void EINT0_IRQHandler (void) //{ // if(timer3%2==1) // { // LED_On(9); // wheel3 = 1; // } // else // { // LED_On(8); // wheel3 = 0; // } // if((wheel1 + wheel2 + wheel3) == 3) // LED_On(11); // else if ((wheel1 + wheel2 + wheel3) == 0) // LED_On(11); // else // LED_On(10); // // LPC_SC->EXTINT |= (1 << 0); /* clear pending interrupt */ //} //void EINT1_IRQHandler (void) //{ // all_LED_off(); // if(timer1%2==1) // { // LED_On(5); // wheel1 = 1; // } // else // { // LED_On(4); // wheel1 = 0; // } // LPC_SC->EXTINT |= (1 << 1); /* clear pending interrupt */ //} //void EINT2_IRQHandler (void) //{ // if(timer2%2==1) // { // LED_On(7); // wheel2 = 1; // } // else // { // LED_On(6); // wheel2 = 0; // } // LPC_SC->EXTINT |= (1 << 2); /* clear pending interrupt */ //} //void random (void) //{ // while(1){ // timer1++; // timer2++; // timer3++; // } //}
gabrielganzer/ARM
slot_machine/LED/led.h
<reponame>gabrielganzer/ARM /********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: led.h ** Last modified Date: 2019-12-05 ** Last Version: V1.00 ** Descriptions: Prototypes of functions included in lib_led.c ** Correlated files: lib_led.c **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ /* lib_led */ void LED_init(void); void LED_deinit(void); void all_LED_on(void); void all_LED_off(void); void LED_On (unsigned int num); void LED_Off (unsigned int num);
gabrielganzer/ARM
shop_list/lib_timer.c
/********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: lib_timer.h ** Descriptions: atomic functions to be used by higher sw levels ** Correlated files: lib_timer.c, funct_timer.c, IRQ_timer.c **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ #include "lpc17xx.h" #include "timer.h" /****************************************************************************** ** Function name: enable_timer ** ** Descriptions: Enable timer ** ** parameters: timer number: 0 or 1 ** Returned value: None ** ******************************************************************************/ void enable_timer( uint8_t timer_num ) { if ( timer_num == 0 ) { LPC_TIM0->TCR = 1; } else { LPC_TIM1->TCR = 1; } return; } /****************************************************************************** ** Function name: disable_timer ** ** Descriptions: Disable timer ** ** parameters: timer number: 0 or 1 ** Returned value: None ** ******************************************************************************/ void disable_timer( uint8_t timer_num ) { if ( timer_num == 0 ) { LPC_TIM0->TCR = 0; } else { LPC_TIM1->TCR = 0; } return; } /****************************************************************************** ** Function name: reset_timer ** ** Descriptions: Reset timer ** ** parameters: timer number: 0 or 1 ** Returned value: None ** ******************************************************************************/ void reset_timer( uint8_t timer_num ) { uint32_t regVal; if ( timer_num == 0 ) { regVal = LPC_TIM0->TCR; regVal |= 0x02; LPC_TIM0->TCR = regVal; } else { regVal = LPC_TIM1->TCR; regVal |= 0x02; LPC_TIM1->TCR = regVal; } return; } uint32_t init_timer ( uint8_t timer_num, uint32_t TimerInterval ) { if ( timer_num == 0 ) { LPC_TIM0->MR0 = TimerInterval; //*** <<< Use Configuration Wizard in Context Menu >>> *** // <h> timer0 MCR // <e.0> MR0I // <i> 1 Interrupt on MR0: an interrupt is generated when MR0 matches the value in the TC. 0 // <i> 0 This interrupt is disabled // </e> // <e.1> MR0R // <i> 1 Reset on MR0: the TC will be reset if MR0 matches it. // <i> 0 Feature disabled. // </e> // <e.2> MR0S // <i> 1 Stop on MR0: the TC and PC will be stopped and TCR[0] will be set to 0 if MR0 matches the TC // <i> 0 Feature disabled. // </e> // <e.3> MR1I // <i> 1 Interrupt on MR1: an interrupt is generated when MR0 matches the value in the TC. 0 // <i> 0 This interrupt is disabled // </e> // <e.4> MR1R // <i> 1 Reset on MR1: the TC will be reset if MR0 matches it. // <i> 0 Feature disabled. // </e> // <e.5> MR1S // <i> 1 Stop on MR1: the TC and PC will be stopped and TCR[1] will be set to 0 if MR1 matches the TC // <i> 0 Feature disabled. // </e> // <e.6> MR2I // <i> 1 Interrupt on MR2: an interrupt is generated when MR2 matches the value in the TC. // <i> 0 This interrupt is disabled // </e> // <e.7> MR2R // <i> 1 Reset on MR2: the TC will be reset if MR2 matches it. // <i> 0 Feature disabled. // </e> // <e.8> MR2S // <i> 1 Stop on MR2: the TC and PC will be stopped and TCR[2] will be set to 0 if MR2 matches the TC // <i> 0 Feature disabled. // </e> // <e.9> MR3I // <i> 1 Interrupt on MR3: an interrupt is generated when MR3 matches the value in the TC. // <i> 0 This interrupt is disabled // </e> // <e.10> MR3R // <i> 1 Reset on MR3: the TC will be reset if MR3 matches it. // <i> 0 Feature disabled. // </e> // <e.11> MR3S // <i> 1 Stop on MR3: the TC and PC will be stopped and TCR[3] will be set to 0 if MR3 matches the TC // <i> 0 Feature disabled. // </e> LPC_TIM0->MCR = 3; // </h> //*** <<< end of configuration section >>> *** NVIC_EnableIRQ(TIMER0_IRQn); return (1); } else if ( timer_num == 1 ) { LPC_TIM1->MR0 = TimerInterval; LPC_TIM1->MCR = 3; /* Interrupt and Reset on MR1 */ NVIC_EnableIRQ(TIMER1_IRQn); return (1); } return (0); } /****************************************************************************** ** End Of File ******************************************************************************/
gabrielganzer/ARM
shop_list/IRQ_adc.c
<filename>shop_list/IRQ_adc.c /********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: IRQ_adc.c ** Descriptions: functions to manage A/D interrupts ** Correlated files: adc.h **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ #include "lpc17xx.h" #include "adc_dac.h" /*---------------------------------------------------------------------------- A/D IRQ: Executed when A/D Conversion is ready (signal from ADC peripheral) *----------------------------------------------------------------------------*/ unsigned short AD_current; void ADC_IRQHandler(void) { unsigned short led_last, led_current; /* Use either one of these instructions to read conversion result */ // AD_current = ((LPC_ADC->ADGDR>>4) & 0xFFF); /* if global interrupts are enabled */ AD_current = ((LPC_ADC->ADDR5 >> 4) & 0xFFF); /* if interrupts on channel 5 are enabled */ }
gabrielganzer/ARM
proc_subroutine/c_functions.c
// --------------------------------------- EX 5 --------------------------------------- //extern int myUADD8(int, int); //int main(void) { // int var1, var2, sum; // // var1 = 2049983885; // var2 = 3272973994; // sum = myUADD8(var1, var2); //} // --------------------------------------- EX 6 --------------------------------------- //#include <math.h> //int hypotenuse(int p, int b) //{ // double h; // h = hypot(p, b); // return h; //}
gabrielganzer/ARM
arm_c/funct_led.c
<filename>arm_c/funct_led.c<gh_stars>1-10 /********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: lib_led.c ** Last modified Date: 2019-11-26 ** Last Version: V1.00 ** Descriptions: Atomic led init functions ** Correlated files: **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ #include "LPC17xx.h" #include "led.h" const unsigned long led_mask[] = {1UL, 1UL<<1, 1UL<<2, 1UL<<3, 1UL<<4, 1UL<<5, 1UL<<6, 1UL<<7}; /*---------------------------------------------------------------------------- Function that initializes LEDs and switch them on/off *----------------------------------------------------------------------------*/ void led4and11_On(void) { LPC_GPIO2->FIOSET = 0x00000081; // P2.0 AND P2.7 on PORT2 active } void led4_Off(void) { LPC_GPIO2->FIOCLR = 0x00000080; } void ledEvenOn_OddOf(void) { LPC_GPIO2->FIOPIN = 0x00000055; } void LED_On(unsigned int num) { LPC_GPIO2->FIOPIN |= led_mask[11-num]; } void LED_Off(unsigned int num) { LPC_GPIO2->FIOPIN &= ~led_mask[11-num]; }
gabrielganzer/ARM
simon_game/sample.c
/*---------------------------------------------------------------------------- * Name: sample.c * * This software is supplied "AS IS" without warranties of any kind. * * Copyright (c) 2019 Politecn<NAME>. All rights reserved. *----------------------------------------------------------------------------*/ #include <stdio.h> #include "LPC17xx.h" /* LPC17xx definitions */ #include "led/led.h" #include "button/button.h" #include "timer/timer.h" enum {s0 = 0, s1 = 1, s2 = 2, s3 = 3, s4 = 4, s5 = 5, s6 = 6}; unsigned int state = s0, i, j, n, seq[256]; extern unsigned int flagT0, pressed, button, led, cnt; /*---------------------------------------------------------------------------- Main Program *----------------------------------------------------------------------------*/ int main (void) { LED_init(); /* LED Initialization */ BUTTON_init(); /* BUTTON Initialization */ init_timer(0,0x023C3460); /* TIMER0 Initialization */ init_timer(1,0x00BEBC20); /* TIMER1 Initialization */ while(1){ switch(state){ case s1: enable_timer(0); if(flagT0){ if (i == (n-1)){ led = LPC_TIM1->TC%3; LED_On(led); seq[i++] = led; } else { LED_On(seq[i++]); } flagT0 = 0; state = s2; } break; case s2: enable_timer(0); if(flagT0){ all_LED_off(); flagT0 = 0; if(cnt<n*2) state = s1; else { cnt = 0; state = s3; } } break; case s3: if(pressed) { pressed = 0; if(button == seq[j]){ j++; state = s5; } else state = s4; } break; case s4: LPC_GPIO2->FIOPIN = ++j; if (pressed){ pressed = 0; state = s0; } else state = s4; break; case s5: if(j<n) state = s3; else state = s6; break; case s6: LPC_GPIO2->FIOPIN = n; i = 0; j = 0; if (pressed) { n++; pressed = 0; all_LED_off(); state = s1; } else state = s6; break; case s0: default: i = 0; j = 0; n = 1; all_LED_off(); enable_timer(1); state = s1; break; } } }
gabrielganzer/ARM
slot_machine/LED/led.c
/********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: lib_led.c ** Last modified Date: 2019-12-05 ** Last Version: V1.00 ** Descriptions: Atomic led init functions ** Correlated files: **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ #define LED_NUM 8 /* Number of user LEDs */ #include "LPC17xx.h" #include "led.h" const unsigned long led_mask[LED_NUM] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; unsigned int led_value; /*---------------------------------------------------------------------------- Function that initializes LEDs *----------------------------------------------------------------------------*/ void LED_init(void) { LPC_PINCON->PINSEL4 &= 0xFFFF0000; // PIN mode GPIO: P2.0-P2.7 are set to zero LPC_GPIO2->FIODIR |= 0x000000FF; // P2.0-P2.7 on PORT2 defined as Output } void LED_deinit(void) { LPC_GPIO2->FIODIR &= 0xFFFFFF00; } /*---------------------------------------------------------------------------- Functions that turn on/off all led *----------------------------------------------------------------------------*/ void all_LED_on(void) { LPC_GPIO2->FIOSET = 0x000000FF; } void all_LED_off(void) { LPC_GPIO2->FIOCLR = 0x000000FF; } /*---------------------------------------------------------------------------- Functions that turn on/off the requested led *----------------------------------------------------------------------------*/ void LED_On(unsigned int num) { led_value = num; LPC_GPIO2->FIOPIN |= led_mask[11-num]; } void LED_Off(unsigned int num) { LPC_GPIO2->FIOPIN &= ~led_mask[11-num]; }
gabrielganzer/ARM
arm_c/led.h
/********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: led.h ** Last modified Date: 2019-11-26 ** Last Version: V1.00 ** Descriptions: Prototypes of functions included in lib_led.c ** Correlated files: lib_led.c **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ /* lib_led */ void LED_init(void); void LED_deinit(void); void all_LED_on(void); void all_LED_off(void); void led4and11_On(void); void led4_Off(void); void ledEvenOn_OddOf(void); void LED_On(unsigned int num); void LED_Off(unsigned int num);
gabrielganzer/ARM
shop_list/lib_adc_dac.c
#include "lpc17xx.h" #include "adc_dac.h" /*---------------------------------------------------------------------------- Function that initializes ADC *----------------------------------------------------------------------------*/ void ADC_init (void) { LPC_PINCON->PINSEL3 |= (3UL<<30); /* P1.31 is AD0.5 */ LPC_SC->PCONP |= (1<<12); /* Enable power to ADC block */ LPC_ADC->ADCR = (1<< 5) | /* select AD0.5 pin */ (4<< 8) | /* ADC clock is 25MHz/5 */ (1<<21); /* enable ADC */ /* Use either one of these instructions to enable interrupt */ // LPC_ADC->ADINTEN = (1 << 8); /* global enable interrupt */ LPC_ADC->ADINTEN = (1 << 5); /* interrupt generated after completing a conversion on channel 5 */ NVIC_EnableIRQ(ADC_IRQn); /* enable ADC Interrupt */ } void ADC_start_conversion (void) { /* Use either one of these instructions */ //LPC_ADC->ADCR |= (1<<24); /* Start one A/D Conversion */ LPC_ADC->ADCR |= (1<<16); /* Start burst A/D Conversion */ } /*---------------------------------------------------------------------------- Function that initializes DAC *----------------------------------------------------------------------------*/ void DAC_init (void) { LPC_PINCON->PINSEL1 |= (1<<21); LPC_PINCON->PINSEL1 &= ~(1<<20); LPC_GPIO0->FIODIR |= (1<<26); }
gabrielganzer/ARM
slot_machine/timer/IRQ_timer.c
/********************************************************************************************************* **--------------File Info--------------------------------------------------------------------------------- ** File name: IRQ_timer.c ** Descriptions: interrupt handlers of Timer/Counter 0 and 1 ** Correlated files: timer.h **-------------------------------------------------------------------------------------------------------- *********************************************************************************************************/ #include "lpc17xx.h" #include "../timer/timer.h" unsigned int flag; void TIMER0_IRQHandler (void) { flag = 1; LPC_TIM0->IR = 1; /* clear interrupt flag */ return; } void TIMER1_IRQHandler (void) { LPC_TIM1->IR = 1; /* clear interrupt flag */ return; }
cclaypool/machine-learning-algorithm-comparison
src/GradMatrix.h
<gh_stars>0 #pragma once #include "Matrix.h" namespace MLComparison { // class template for a matrix with a given type and dimensions which also // stores the gradients of some function with respect to its elements template<typename T, size_t n_rows, size_t n_cols> class GradMatrix : public Matrix<T, n_rows, n_cols> { public: // default constructor which calls the parent Matrix constructor GradMatrix() : Matrix<T, n_rows, n_cols>() { } // destructor ~GradMatrix() { } // copy constructor which copies the data from a matrix GradMatrix(const Matrix<T, n_rows, n_cols>& rhs) : Matrix<T, n_rows, n_cols>(rhs) { } // copy constructor which copies only the data from a gradient-enabled matrix GradMatrix(const GradMatrix<T, n_rows, n_cols>& rhs) : Matrix<T, n_rows, n_cols>(rhs) { } // assignment operator which copies the data from a matrix GradMatrix<T, n_rows, n_cols>& operator=(const Matrix<T, n_rows, n_cols>& rhs) { this->data = rhs.data; return *this; } // assignment operator which copies only the data from a gradient-enabled matrix GradMatrix<T, n_rows, n_cols>& operator=(const GradMatrix<T, n_rows, n_cols>& rhs) { this->data = rhs.data; return *this; } // update the elements based on their gradients and the // learning rate given, i.e. perform one gradient descent step void SGDStep(double learning_rate) { // for each row of the matrix for (int row = 0; row < n_rows; row++) { // for each column of the matrix for (int col = 0; col < n_cols; col++) { // multiply the relevant gradient by the learning rate // and subtract the result from the parameter this->data[row][col] -= learning_rate * grad[row][col]; } } } // matrix which stores the gradients of some function // with respect to the elements of the data matrix Matrix<T, n_rows, n_cols> grad; }; }
cclaypool/machine-learning-algorithm-comparison
src/Linear.h
<gh_stars>0 #pragma once #include <random> #include <cmath> #include "base_layers.h" namespace MLComparison { // class template for a standard linear neural network layer // with a given number of inputs and units (neurons) template<typename T, int n_inputs, int n_units> class Linear : public TrainableLayer<T, n_inputs, n_units> { public: // default constructor which initializes the input matrix pointer as // a null pointer and creates gradient matrices for the weights and biases Linear() { } // constructor which additionally sets the learning rate Linear(T learning_rate) : TrainableLayer<T, n_inputs, n_units>(learning_rate) { } // initializes weights according to the Kaiming He initialization scheme void kaiming_he_init() { // create random number generator std::default_random_engine rng; // normal distribution with mean 0 and sd of sqrt(2 / n_inputs) std::normal_distribution<T> dist_norm(0, std::sqrt(2.0 / n_inputs)); // for each row of weights matrix for (int row = 0; row < n_inputs; row++) { // for each column of weights matrix for (int col = 0; col < n_units; col++) { // set weight to random number drawn from specified distribution weights[row][col] = dist_norm(rng); } } } // performs the forward pass, calculating outputs based on the inputs, weights and biases virtual Matrix<T, 1, n_units>* operator()(Matrix<T, 1, n_inputs>* x) override { // save pointer to the input matrix so its gradients can be set during the backward pass forward_record.input_matrix = x; // output matrix is the biases added to the dot product of input matrix and weights, // i.e the output of each unit is the sum of each input multiplied by that unit's corresponding // weight parameter, plus the bias terms forward_record.output_matrix = x->dot(weights).add(biases); // return the outputs return &forward_record.output_matrix; } // performs the backwards pass, calculating the gradients of the input matrix and the parameters // based on the gradients of the output matrix and the derivative of the current function virtual void backward() override { // if input matrix exists if (forward_record.input_matrix != nullptr) { // gradients of the input matrix are the dot product of the gradients of the output matrix and the // transpose of the weights, i.e the gradient of an input element is the sum of the elementwise // product of the gradients of each neuron's output and the weights of each neuron for that input if (auto* ptr = dynamic_cast<GradMatrix<T, 1, n_inputs>*>(forward_record.input_matrix)) { ptr->grad = forward_record.output_matrix.grad.dot_t(weights); } // gradients of the weights are the dot product of the transpose of the input matrix and the gradients // of the output matrix, i.e. the gradient of each weight is the product of the input corresponding to // that weight and the gradient of the output of the unit to which that weight belongs weights.grad = forward_record.input_matrix->t_dot(forward_record.output_matrix.grad); // gradients of the biases are simply the gradients of the outputs biases.grad = forward_record.output_matrix.grad; } } // updates the weights and biases virtual void update() override { weights.SGDStep(this->learning_rate); biases.SGDStep(this->learning_rate); } private: // record of forward pass ForwardRecord<T, n_inputs, n_units> forward_record; // matrix of weights GradMatrix<T, n_inputs, n_units> weights; // matrix of biases GradMatrix<T, 1, n_units> biases; }; }
cclaypool/machine-learning-algorithm-comparison
src/test_decision_tree.h
<reponame>cclaypool/machine-learning-algorithm-comparison #pragma once #include <string> #include <fstream> #include "DecisionTreeModel.h" namespace MLComparison { // function to record the training time of the decision tree algorithm using // different numbers of training samples and independent variables within these void test_decision_tree(const std::string& train_timings_csv); }
cclaypool/machine-learning-algorithm-comparison
src/Sigmoid.h
<reponame>cclaypool/machine-learning-algorithm-comparison #pragma once #include <cmath> #include "base_layers.h" namespace MLComparison { // class template for a sigmoid activation function layer whose inputs are of the given dimensions template<typename T, int cols> class Sigmoid : public Layer<T, cols, cols> { public: // default constructor Sigmoid() { } // forward pass which applies the sigmoid function to each input element virtual Matrix<T, 1, cols>* operator()(Matrix<T, 1, cols>* x) override { // set pointer to address of matrix given as input forward_record.input_matrix = x; // for each column of input/output matrices for (int col = 0; col < cols; col++) { // set element of output matrix to current item if positive, else 0 forward_record.output_matrix[0][col] = sigmoid(x->at(0)[col]); } // return reference to output matrix return &forward_record.output_matrix; } // backward pass which sets gradient of each input based on gradients of outputs // and derivative of sigmoid function virtual void backward() override { // GradMatrix pointer to input matrix auto* grad_input_ptr = static_cast<GradMatrix<T, 1, cols>*>(forward_record.input_matrix); // temporary variable for current element of input matrix T current_elem; // for each column of input.output matrices for (int col = 0; col < cols; col++) { current_elem = forward_record.input_matrix->at(0)[col]; // gradient of input is derivative of sigmoid function times gradient of corresponding output grad_input_ptr->grad[0][col] = sigmoid(current_elem) * (1 - sigmoid(current_elem)) * forward_record.output_matrix.grad[0][col]; } } private: // sigmoid function T sigmoid(T x) { // 1 / (1 + e^-x) return 1 / (1 + std::exp(-x)); } // record of forward pass ForwardRecord<T, cols, cols> forward_record; }; }
cclaypool/machine-learning-algorithm-comparison
src/DecisionTreeNode.h
#pragma once #include <vector> #include <array> #include <memory> #include <iterator> #include <iostream> #include <algorithm> #include "DecisionTreeDataset.h" namespace MLComparison { // class template for a binary classification decision tree node which deals with data samples of a certain type and size template<typename T, int dataset_x_vars> class DecisionTreeNode { public: // constructor which takes the depth of the current node, iterators defining the training group, // a pointer to the training dataset, and the number of training set indepenent variables to use DecisionTreeNode(int node_depth, std::vector<int>::iterator group_begin_it, std::vector<int>::iterator group_end_it, std::shared_ptr<DecisionTreeDataset<T, dataset_x_vars>> training_dataset, int dataset_x_vars_to_use = dataset_x_vars) : depth(node_depth), group_begin(group_begin_it), group_end(group_end_it), training_set(training_dataset), x_vars_to_use(dataset_x_vars_to_use) { group_size = std::distance(group_begin, group_end); } // copy constructor, which does not copy child nodes or pointers to them DecisionTreeNode(const DecisionTreeNode<T, dataset_x_vars>& rhs) : split_var(rhs.split_var), split_val(rhs.split_val), class_prediction(rhs.class_prediction), depth(rhs.depth), left(nullptr), right(nullptr), training_set(rhs.training_set), x_vars_to_use(rhs.x_vars_to_use), group_begin(rhs.group_begin), group_end(rhs.group_end), group_size(rhs.group_size) { } // assignment operator, which does not copy child nodes or pointers to them DecisionTreeNode<T, dataset_x_vars>& operator=(const DecisionTreeNode<T, dataset_x_vars>& rhs) { split_var = rhs.split_var; split_val = rhs.split_var; class_prediction = rhs.class_prediction; depth = rhs.depth; left.reset(nullptr); right.reset(nullptr); training_set = rhs.training_set; x_vars_to_use = rhs.x_vars_to_use; group_begin = rhs.group_begin; group_end = rhs.group_end; group_size = rhs.group_size; return *this; } // trains the node on its group of training samples, determining the optimal split variable and value // and either setting its class prediction or recursively creating and training its child nodes void train() { // if depth is low enough and group size large enough if (depth < 6 && group_size > 10) { // determine best split variable and value get_best_split(); // partition the node's group of training row indices and return an iterator pointing to the split point auto split_point = split_group(); // become leaf node if best split is not to split if (split_point == group_begin || split_point == group_end) { become_leaf(); } // otherwise, create and train child nodes else { left.reset(new DecisionTreeNode<T, dataset_x_vars>(depth + 1, group_begin, split_point, training_set, x_vars_to_use)); right.reset(new DecisionTreeNode<T, dataset_x_vars>(depth + 1, split_point, group_end, training_set, x_vars_to_use)); left->train(); right->train(); } } // otherwise, become leaf node else { become_leaf(); } } // method template for making a prediction based on a sample template<int sample_length> int predict(const std::array<T, sample_length>& sample) { // if node is leaf node, return prediction if (class_prediction >= 0) { return class_prediction; } // if node is not leaf and sample's split variable is less than split value, // return left child node's prediction else if (sample[split_var] < split_val) { return left->predict(sample); } // otherwise, return right child node's prediction else { return right->predict(sample); } } private: // default constructor does not make sense for this class, so it is kept private and without definition DecisionTreeNode(); // calculates the Gini index of a split point defined by a split variable and value double calculate_gini_index(int split_variable, T split_value) { // array of subgroup sizes std::array<double, 2> subgroup_sizes = {}; // array of subgroup class value sums std::array<double, 2> subgroup_class_val_sums = {}; // subgroup current row belongs in uint8_t row_subgroup = 0; // for each row in the group for (auto it = group_begin; it < group_end; ++it) { // get a reference to the current row const auto& row = training_set->at(*it); // determine which subgroup the row belongs in row_subgroup = row[split_variable] >= split_value; // increment the revelvant subgroup size and class value sum appropriately ++subgroup_sizes[row_subgroup]; subgroup_class_val_sums[row_subgroup] += row[dataset_x_vars]; } // subgroup sizes as proportions std::array<double, 2> subgroup_size_proportions; subgroup_size_proportions[0] = subgroup_sizes[0] / group_size; subgroup_size_proportions[1] = 1 - subgroup_size_proportions[0]; // proportion of each class in current group std::array<double, 2> class_proportions; // final gini index double gini_index = 0; // for each subgroup for (int subgroup = 0; subgroup <= 1; subgroup++) { // prevent division by zero if a group has 0 size if (subgroup_sizes[subgroup] > 0) { // proportion of positive class is sum of group class values / size of group class_proportions[1] = subgroup_class_val_sums[subgroup] / subgroup_sizes[subgroup]; // proportion of negative class is 1 - proportion of positive class class_proportions[0] = 1 - class_proportions[1]; // calculate the gini index for the group, weight it by subgroup size and add it to the final gini index gini_index += (1 - ((class_proportions[0] * class_proportions[0]) + (class_proportions[1] * class_proportions[1]))) * subgroup_size_proportions[subgroup]; } } // return final gini index return gini_index; } // find the split point (variable and value) in this node's training group which has // the lowest gini index, and set the node's split variable and value accordingly void get_best_split() { // split value being tested T current_val = 0; // gini index of current split point double current_gini_index = 0; // best gini index found double best_gini_index = 0.5; // split value associated with best gini index double best_val = 0; // split variable associated with best gini index int best_var = 0; // whether perfect gini index has been found bool done = false; // for each row index of the current group for (auto it = group_begin; it < group_end && !done; ++it) { // get reference to current row const auto& row = training_set->at(*it); // for each field to use in the current row for (int col = 0; col < x_vars_to_use && !done; col++) { // get the field's value current_val = row[col]; // calculate Gini index of split at current row & col current_gini_index = calculate_gini_index(col, current_val); // update best if necessary if (current_gini_index < best_gini_index) { best_gini_index = current_gini_index; best_val = current_val; best_var = col; // stop if perfect Gini score has been found if (best_gini_index == 0) { done = true; } } } } // set split variable and value fields once the best are found split_var = best_var; split_val = best_val; } // paritions the node's group of rows based on its split point and returns // an iterator pointing to the split point (first row index of the second group) auto split_group() { // sort group based on split variable and value and return iterator pointing to split point (first element of second group) return std::partition(group_begin, group_end, [this](int i) -> bool { return training_set->at(i)[split_var] < split_val; } ); } // set the leaf prediction value based on node's group of training samples void become_leaf() { // get sum of class values in group int sum = 0; for (auto it = group_begin; it < group_end; ++it) { sum += training_set->at(*it)[dataset_x_vars]; } // set leaf class prediction based on whichever class is more prevalent class_prediction = (sum > group_size / 2) ? 1 : 0; } // split variable and value if the node is not a leaf int split_var = -1; T split_val = -1; // class prediction if the node is a leaf int class_prediction = -1; // depth of node in tree int depth; // pointers to left and right child nodes std::unique_ptr<DecisionTreeNode<T, dataset_x_vars>> left = nullptr; std::unique_ptr<DecisionTreeNode<T, dataset_x_vars>> right = nullptr; // pointer to the dataset on which to train std::shared_ptr<DecisionTreeDataset<T, dataset_x_vars>> training_set; // number of dependent variables in the dataset to use int x_vars_to_use; // iterators pointing to the elements in the training set's vector of row indices // which define the start and end of the group of samples on which to train std::vector<int>::iterator group_begin; std::vector<int>::iterator group_end; // number of rows in the node's training group int group_size = 0; }; }
cclaypool/machine-learning-algorithm-comparison
src/Relu.h
<gh_stars>0 #pragma once #include "base_layers.h" namespace MLComparison { // class template for a ReLU activation function layer whose inputs are of the given dimensions template<typename T, int cols> class Relu : public Layer<T, cols, cols> { public: // default constructor Relu() { } // forward pass which replaces all negative values with 0 virtual Matrix<T, 1, cols>* operator()(Matrix<T, 1, cols>* x) override { // set pointer to address of matrix given as input forward_record.input_matrix = x; // temporary variable to hold the current element T current_elem; // for each column of input/output matrices for (int col = 0; col < cols; col++) { // get element from input matrix current_elem = x->at(0)[col]; // set element of output matrix to current item if positive, else 0 forward_record.output_matrix[0][col] = current_elem > 0 ? current_elem - 0.5 : -0.5; } // return pointer to output matrix return &forward_record.output_matrix; } // backward pass which sets gradient of each input to gradient of output if the input is positive, else 0 void backward() override { // GradMatrix pointer to input matrix auto* grad_input_ptr = static_cast<GradMatrix<T, 1, cols>*>(forward_record.input_matrix); // for each column of input.output matrices for (int col = 0; col < cols; col++) { // gradient of input is gradient of corresponding output if input is positive, otherwise 0 grad_input_ptr->grad[0][col] = forward_record.input_matrix->at(0)[col] > 0 ? forward_record.output_matrix.grad[0][col] : 0; } } private: // record of forward pass ForwardRecord<T, cols, cols> forward_record; }; }
cclaypool/machine-learning-algorithm-comparison
src/calculate_rows_to_use.h
<reponame>cclaypool/machine-learning-algorithm-comparison<filename>src/calculate_rows_to_use.h #pragma once #include <cmath> namespace MLComparison { // function to calculate a number of samples to use based on a number // of divisions, a number of these to use, and the total number of rows size_t calculate_rows_to_use(int total_divisions, int divisions_to_use, size_t total_rows); }
cclaypool/machine-learning-algorithm-comparison
src/test_neural_network.h
<reponame>cclaypool/machine-learning-algorithm-comparison #pragma once #include <string> #include <fstream> #include "NeuralNetModel.h" namespace MLComparison { // function template which generates a neural network model which uses a given // number of the independent variables in the banknote authentication dataset template<typename T, size_t x_vars_to_use> NeuralNetModel<T, 4, x_vars_to_use> make_banknote_authentication_nn_model(T learning_rate) { return NeuralNetModel<T, 4, x_vars_to_use>("banknote_train.csv", "banknote_valid.csv", learning_rate); } // function template to test a neural network model on a given number // of the independent variables in the banknote authentication dataset template<typename T, size_t x_vars_to_use> void test_model_with_n_x_vars(std::ofstream& timings_file) { // for each possible row number preset, i.e. using 1 to 8 8ths of the data samples for (int eighths_rows_to_use = 1; eighths_rows_to_use <= 8; eighths_rows_to_use++) { // create a model auto model = make_banknote_authentication_nn_model<T, x_vars_to_use>(0.1); // train the model and record the time taken auto train_time = model.train(eighths_rows_to_use, 5); // write details to timings file timings_file << eighths_rows_to_use << "," << x_vars_to_use << "," << train_time; // record the model's validation time auto valid_time = model.validate(eighths_rows_to_use); // write details to timings file timings_file << "," << valid_time << "," << model.get_accuracy() << std::endl; } } // function template to time the training of a neural network as // the input dimensions change template<typename T> void test_neural_network(const std::string& timings_csv) { // open the given timings file std::ofstream train_timings_file(timings_csv, std::ios::trunc); // write header to timings file train_timings_file << "samples_proportion,x_vars_proportion,train_time,valid_time,accuracy" << std::endl; // take 100 measurements of each combination of numbers of rows and columns to use for (int i = 0; i < 100; i++) { test_model_with_n_x_vars<T, 1>(train_timings_file); test_model_with_n_x_vars<T, 2>(train_timings_file); test_model_with_n_x_vars<T, 3>(train_timings_file); test_model_with_n_x_vars<T, 4>(train_timings_file); } // close timings file train_timings_file.close(); } }
cclaypool/machine-learning-algorithm-comparison
src/NeuralNet.h
#pragma once #include "base_layers.h" #include "Linear.h" #include "Relu.h" #include "Sigmoid.h" namespace MLComparison { // class template for a simple artificial neural network suitable for binary classification template<typename T, size_t input_cols> class NeuralNet : public TrainableLayer<T, input_cols, 1> { public: // constructor which takes a learning rate NeuralNet(T learning_rate) : TrainableLayer<T, input_cols, 1>(learning_rate), linear_layer_1(learning_rate), linear_layer_2(learning_rate) { // initialize weights of each linear layer linear_layer_1.kaiming_he_init(); linear_layer_2.kaiming_he_init(); } // call operator which performs the forward pass virtual Matrix<T, 1, 1>* operator()(Matrix<T, 1, input_cols>* x) override { return layer_2_sigmoid_activation(linear_layer_2(layer_1_relu_activation(linear_layer_1(x)))); } // backward pass virtual void backward() override { layer_2_sigmoid_activation.backward(); linear_layer_2.backward(); layer_1_relu_activation.backward(); linear_layer_1.backward(); } // updates the parameters of both linear layers virtual void update() override { linear_layer_1.update(); linear_layer_2.update(); } // sets the learning rate virtual void set_lr(T new_learning_rate) override { this->learning_rate = new_learning_rate; linear_layer_1.set_lr(new_learning_rate); linear_layer_2.set_lr(new_learning_rate); } private: // first linear layer with 8 units (neurons) Linear<T, input_cols, 8> linear_layer_1; // relu activation function for first linear layer Relu<T, 8> layer_1_relu_activation; // second linear layer with a single unit Linear<T, 8, 1> linear_layer_2; // sigmoid activation function for second linear layer Sigmoid<T, 1> layer_2_sigmoid_activation; }; }
cclaypool/machine-learning-algorithm-comparison
src/base_layers.h
#pragma once #include "GradMatrix.h" namespace MLComparison { // abstract class template for a neural network layer template<typename T, size_t input_size, size_t output_size> class Layer { public: // pure virtual function which takes a pointer to an input matrix, // calculates an output matrix and returns a pointer to it virtual Matrix<T, 1, output_size>* operator()(Matrix<T, 1, input_size>*) = 0; // pure virtual function to calculate and set the relevant gradients virtual void backward() = 0; }; // abstract class template for a layer with trainable parameters template<typename T, size_t input_size, size_t output_size> class TrainableLayer : public Layer<T, input_size, output_size> { public: // default constructor which sets the learning rate to 0 TrainableLayer() { } // constructor which sets the learning rate to the given value TrainableLayer(T layer_learning_rate) : learning_rate(layer_learning_rate) { } // destructor ~TrainableLayer() { } // getter for learning rate T get_lr() { return learning_rate; } // setter for learning rate virtual void set_lr(T new_learning_rate) { learning_rate = new_learning_rate; } // pure virtual function to update the layer's parameters virtual void update() = 0; protected: // learning rate for the layer's parameters T learning_rate = 0; }; // class template for a loss function layer template<typename T> class LossLayer { public: // pure virtual call operator function which takes a pointer // to the input as well as the target number virtual T operator()(Matrix<T, 1, 1>* x, T target) = 0; // pure virtual function for backward pass virtual void backward() = 0; protected: // pointer to input matrix Matrix<T, 1, 1>* input_matrix = nullptr; // target T target = 0; }; // struct template for a record of the forward pass, made up of // a pointer to the input matrix and the matrix of outputs template<typename T, size_t input_size, size_t output_size> struct ForwardRecord { // pointer to the matrix of inputs Matrix<T, 1, input_size>* input_matrix = nullptr; // matrix of outputs GradMatrix<T, 1, output_size> output_matrix; }; }
cclaypool/machine-learning-algorithm-comparison
src/NeuralNetModel.h
<reponame>cclaypool/machine-learning-algorithm-comparison #pragma once #include <chrono> #include <string> #include <cmath> #include "NeuralNetDataset.h" #include "NeuralNet.h" #include "MSELoss.h" #include "calculate_rows_to_use.h" namespace MLComparison { // class template for a neural network prediction model suitable for binary classification template<typename T, size_t dataset_x_vars, size_t model_x_vars = dataset_x_vars> class NeuralNetModel { public: // default constructor NeuralNetModel() { } // constructor which takes filenames for the training and validation sets and the network's learning rate NeuralNetModel(const std::string& train_csv, const std::string& valid_csv, T learning_rate) : training_set(train_csv), validation_set(valid_csv), neural_net(learning_rate) { } // get accuracy T get_accuracy() { return validation_accuracy; } // sets the learning rate void set_learning_rate(T new_learning_rate) { neural_net.set_lr(new_learning_rate); } // loads a csv file as the training set void load_training_set_file(const std::string& csv_file) { training_set.load_data(csv_file); } // loads a csv file as the validation set void load_validation_set_file(const std::string& csv_file) { validation_set.load_data(csv_file); } // trains the neural network on the given subset of the // rows of the dataset and for a given number of epochs long long train(uint8_t eighths_rows_to_use, size_t n_epochs) { // number of rows to use, calculated from the given preset number size_t rows_to_use = calculate_rows_to_use(8, eighths_rows_to_use, training_set.size()); // get start time the_clock::time_point start = the_clock::now(); // for each epoch for (size_t epoch = 0; epoch < n_epochs; epoch++) { // for each training sample to use for (auto it = training_set.begin(); it < training_set.end(rows_to_use); ++it) { // get reference to current sample auto& row = *it; // perform forward pass loss(neural_net(&row.first), row.second); // perform backward pass loss.backward(); neural_net.backward(); // update the parameters neural_net.update(); } } // get end time the_clock::time_point end = the_clock::now(); // return number of microseconds taken return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count(); } // determine the model's accuracy using the validation set long long validate(uint8_t eighths_rows_to_use) { // number of rows to use, calculated from the given preset number size_t rows_to_use = calculate_rows_to_use(8, eighths_rows_to_use, validation_set.size()); // get start time the_clock::time_point start = the_clock::now(); // get end iterator auto end_iterator = validation_set.begin(); std::advance(end_iterator, rows_to_use); // for each sample in the validation set for (auto it = validation_set.begin(); it < end_iterator; ++it) { // get sample auto& row = *it; // calculate the model's prediction neural_net(&row.first); } // get end time the_clock::time_point end = the_clock::now(); // total loss over all samples T total_loss = 0; // total correct predictions T total_correct = 0; // for each sample in the validation set for (auto& row : validation_set) { // calculate the model's prediction auto prediction = neural_net(&row.first); // get the target value auto target = row.second; // calculate the MSE of the model's prediction total_loss += loss(prediction, target); // add whether the prediction was correct to the total of correct predictions total_correct += (std::round(prediction->at(0)[0]) == std::round(target)); } // calculate and save the average loss and the accuracy validation_loss = total_loss / validation_set.size(); validation_accuracy = total_correct / validation_set.size(); // return the number of microseconds taken return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count(); } private: // validation loss and accuracy T validation_loss = 0; T validation_accuracy = 0; // training and validation sets NeuralNetDataset<T, dataset_x_vars, model_x_vars> training_set; NeuralNetDataset<T, dataset_x_vars, model_x_vars> validation_set; // neural network itself NeuralNet<T, model_x_vars> neural_net; // mean squared error loss function object MSELoss<T> loss; // alias for chrono::steady_clock used for performance measurement using the_clock = std::chrono::steady_clock; }; }
cclaypool/machine-learning-algorithm-comparison
src/MSELoss.h
#pragma once #include <cmath> #include "base_layers.h" namespace MLComparison { // class template for mean squared error (MSE) loss function layer template<typename T> class MSELoss : public LossLayer<T> { public: // forward pass which calculates and returns the mean squared error virtual T operator()(Matrix<T, 1, 1>* x, T target) override { // save pointer to input matrix this->input_matrix = x; this->target = target; // calculate and return loss return (x->at(0)[0] - target) * (x->at(0)[0] - target); } // backward pass which sets the gradients of the input matrix void backward() override { // gradient of input is 2 * error static_cast<GradMatrix<T, 1, 1>*>(this->input_matrix)->grad[0][0] = 2 * (this->input_matrix->at(0)[0] - this->target); } }; }
cclaypool/machine-learning-algorithm-comparison
src/DecisionTreeDataset.h
<gh_stars>0 #pragma once #include <string> #include <iterator> #include <fstream> #include <sstream> #include <vector> #include <array> #include <iostream> namespace MLComparison { // class template for a tabular dataset suitable for a decision tree model template<typename T, int x_vars, bool includes_y = true> class DecisionTreeDataset { public: // default constructor which does not immediately load any data DecisionTreeDataset() { } // constructor which takes the name of a csv file from which data is to be loaded DecisionTreeDataset(const std::string& csv_file) { load_data(csv_file); } // element access operator which returns row i of the underlying data table auto& operator[](int i) { return data_table[i]; } // const element access operator const auto& operator[](int i) const { return data_table[i]; } // element access method auto& at(int i) { return data_table[i]; } // const element access method const auto& at(int i) const { return data_table[i]; } // returns an iterator pointing to the first element (row) of the data table auto begin() { return data_table.begin(); } // returns an iterator pointing to the past-the-end element (row) of the data table auto end() { return data_table.end(); } // returns an iterator pointing to the first element of the vector of row indices auto indices_begin() { return row_indices.begin(); } // returns an iterator pointing to the past-the-end element of the vector of row indices auto indices_end() { return row_indices.end(); } // returns an end iterator based on a number of rows to use auto indices_end(unsigned int rows_to_use) { // if rows to use is non-negative and less than number of rows in dataset if (rows_to_use < row_indices.size() && rows_to_use >= 0) { // create and return iterator pointing to desired element auto end_iterator = row_indices.begin(); std::advance(end_iterator, rows_to_use); return end_iterator; } // otherwise, return end iterator of row indices vector else { return row_indices.end(); } } // returns the number of rows in the dataset auto size() { return row_indices.size(); } // returns the number of rows in the dataset auto get_n_rows() { return row_indices.size(); } // returns the number of columns in the dataset auto get_n_cols() { return n_cols; } // returns the number of independent variables in the dataset auto get_n_x_vars() { return n_x_vars; } // loads data from a csv file void load_data(const std::string& csv_file) { // clear data table and row indices data_table.clear(); row_indices.clear(); // open csv file std::ifstream infile(csv_file); // create string and stream for storing the current line std::string line; std::istringstream line_stream; // create string to store the current item in the line/row std::string item; // for each row in the file, get the current line for (int row = 0; std::getline(infile, line); row++) { // add current row index to vector of row indices row_indices.emplace_back(row); // construct a new array in the vector of rows for the current row data_table.emplace_back(); // set up line stream line_stream = std::istringstream(line); // for each field in the row for (int col = 0; col < n_cols; col++) { // get item from row std::getline(line_stream, item, ','); // convert string to number and store in data table data_table[row][col] = std::stod(item); } } } // outputs all the rows in the dataset void print() { for (auto& row : data_table) { for (auto i : row) { std::cout << i << " "; } std::cout << std::endl; } } private: // number of dependent variables in the dataset static const int n_x_vars = x_vars; // total number of columns in the dataset including the independent variable if present static const int n_cols = x_vars + (includes_y ? 1 : 0); // vector of arrays where each array corresponds to a data sample/row std::vector<std::array<T, n_cols>> data_table = {}; // vector of row indices determining the order in which rows are accessed, // which is recursively partitioned into groups as a decision tree is trained std::vector<int> row_indices = {}; }; }
cclaypool/machine-learning-algorithm-comparison
src/DecisionTreeModel.h
<reponame>cclaypool/machine-learning-algorithm-comparison #pragma once #include <chrono> #include <string> #include <cmath> #include <memory> #include <iterator> #include "DecisionTreeDataset.h" #include "DecisionTreeNode.h" #include "calculate_rows_to_use.h" namespace MLComparison { // class template for a decision tree prediction model suitable for binary classification template<typename T, size_t dataset_x_vars> class DecisionTreeModel { public: // default constructor DecisionTreeModel() { } // constructor which takes the names of csv files for the training and validation sets DecisionTreeModel(const std::string& train_csv, const std::string& valid_csv) : validation_set(valid_csv) { // construct a new training dataset training_set_ptr.reset(new DecisionTreeDataset<T, dataset_x_vars>); // load training data training_set_ptr->load_data(train_csv); } // get accuracy T get_accuracy() { return validation_accuracy; } // loads a csv file as the training set void load_training_set_file(const std::string& csv_file) { training_set_ptr->load_data(csv_file); } // loads a csv file as the validation set void load_validation_set_file(const std::string& csv_file) { validation_set.load_data(csv_file); } // trains the model using a certain proportion of the training samples // and a given number of fields within these samples long long train(uint8_t eighths_rows_to_use, size_t x_vars_to_use) { // number of rows to use size_t rows_to_use = calculate_rows_to_use(8, eighths_rows_to_use, training_set_ptr->size()); // get iterator pointing to beginning of training set row indices auto training_set_begin = training_set_ptr->indices_begin(); // get iterator pointing to one after the last training sample to use auto training_set_end = training_set_ptr->indices_end(rows_to_use); // create the root node of the decision tree root_node_ptr.reset(new DecisionTreeNode<T, dataset_x_vars>(0, training_set_begin, training_set_end, training_set_ptr, x_vars_to_use)); // get start time the_clock::time_point start = the_clock::now(); // train the root node, which recursively creates and trains child nodes root_node_ptr->train(); // get end time the_clock::time_point end = the_clock::now(); // return number of microseconds taken return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count(); } // determine the model's accuracy using the validation set long long validate(uint8_t eighths_rows_to_use) { // number of rows to use size_t rows_to_use = calculate_rows_to_use(8, eighths_rows_to_use, validation_set.size()); // total correct predictions T total_correct = 0; // get start time the_clock::time_point start = the_clock::now(); // get end iterator auto end_iterator = validation_set.begin(); std::advance(end_iterator, rows_to_use); // for each sample in the validation set for (auto it = validation_set.begin(); it < end_iterator; ++it) { // get sample auto& sample = *it; // get model's prediction auto prediction = root_node_ptr->predict(sample); // get target value auto target = sample[dataset_x_vars]; // add whether prediction is correct to total correct predictions total_correct += (prediction == target); } // get end time the_clock::time_point end = the_clock::now(); // calculate and record validation accuracy validation_accuracy = total_correct / validation_set.size(); // total correct predictions total_correct = 0; // for each sample in the validation set for (auto& sample : validation_set) { // get model's prediction auto prediction = root_node_ptr->predict(sample); // get target value auto target = sample[dataset_x_vars]; // add whether prediction is correct to total correct predictions total_correct += (prediction == target); } // calculate and record validation accuracy validation_accuracy = total_correct / validation_set.size(); // return number of milliseconds taken return std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count(); } private: // accuracy of the model on the validation set T validation_accuracy = 0; // shared pointer to the training set std::shared_ptr<DecisionTreeDataset<T, dataset_x_vars>> training_set_ptr = nullptr; // validation set DecisionTreeDataset<T, dataset_x_vars> validation_set; // unique pointer to the root node of the decision tree std::unique_ptr<DecisionTreeNode<T, dataset_x_vars>> root_node_ptr = nullptr; // alias for chrono::steady_clock used for performance measurement using the_clock = std::chrono::steady_clock; }; }
cclaypool/machine-learning-algorithm-comparison
src/Matrix.h
<reponame>cclaypool/machine-learning-algorithm-comparison #pragma once #include <array> #include <iostream> namespace MLComparison { // forward declaration of GradMatrix class template template<typename T, size_t n_rows, size_t n_cols> class GradMatrix; // class template for a matrix of a given type and dimensions template<typename T, size_t n_rows, size_t n_cols> class Matrix { public: // default constructor which initializes the data with zeroes Matrix() : data({ {{ 0 }} }) { } // copy constructor which copies the data from the given matrix Matrix(const Matrix<T, n_rows, n_cols>& rhs) : data(rhs.data) { } // copy constructor which copies the data from the given gradient-enabled matrix Matrix(const GradMatrix<T, n_rows, n_cols>& rhs) : data(rhs.data) { } // virtual destructor virtual ~Matrix() { } // assignment operator which copies the data from the given matrix Matrix<T, n_rows, n_cols>& operator=(const Matrix<T, n_rows, n_cols>& rhs) { data = rhs.data; return *this; } // assignment operator which copies thr data from the given gradient-enabled matrix Matrix<T, n_rows, n_cols>& operator=(const GradMatrix<T, n_rows, n_cols>& rhs) { data = rhs.data; return *this; } // element access operator std::array<T, n_cols>& operator[](int i) { return data[i]; } // const element access operator const std::array<T, n_cols>& operator[](int i) const { return data[i]; } // element access method std::array<T, n_cols>& at(int i) { return data[i]; } // const element access method const std::array<T, n_cols>& at(int i) const { return data[i]; } // method template which calculates and returns the dot product of // the matrix and a given (possibly gradient-enabled) matrix template<template<typename, size_t, size_t> class MatrixType, size_t right_cols> Matrix<T, n_rows, right_cols> dot(const MatrixType<T, n_cols, right_cols>& rhs) const { // create a result matrix Matrix<T, n_rows, right_cols> result; // for each row of the result for (int row = 0; row < n_rows; row++) { // for each column of the result for (int col = 0; col < right_cols; col++) { // item is sum of elementwise product // of corresponding row of current matrix // and corresponding column of matrix given as argument for (int k = 0; k < n_cols; k++) { result[row][col] += data[row][k] * rhs[k][col]; } } } // return the result return result; } // method template which calculates and returns the dot product of the transpose // of the current matrix and a given (possibly gradient-enabled) matrix template<template<typename, size_t, size_t> class MatrixType, size_t right_cols> Matrix<T, n_cols, right_cols> t_dot(const MatrixType<T, n_rows, right_cols>& rhs) const { // create a result matrix Matrix<T, n_cols, right_cols> result; // for each row of the result for (int row = 0; row < n_cols; row++) { // for each column of the result for (int col = 0; col < right_cols; col++) { // item is sum of elementwise product // of corresponding row of transpose of current matrix // and corresponding column of matrix given as argument for (int k = 0; k < n_rows; k++) { result[row][col] += data[k][row] * rhs[k][col]; } } } // return the result return result; } // method template which calculates and returns the dot product of the current // matrix and the transpose of a given (possibly gradient-enabled) matrix template<template<typename, size_t, size_t> class MatrixType, size_t right_rows> Matrix<T, n_rows, right_rows> dot_t(const MatrixType<T, right_rows, n_cols>& rhs) const { // create a result matrix Matrix<T, n_rows, right_rows> result; // for each row of the result for (int row = 0; row < n_rows; row++) { // for each column of the result for (int col = 0; col < right_rows; col++) { // item is sum of elementwise product // of corresponding row of current matrix and corresponding // column of transpose of matrix given as argument for (int k = 0; k < n_cols; k++) { result[row][col] += data[row][k] * rhs[col][k]; } } } // return the result return result; } // method template which adds the elements of the given // (possibly gradient-enabled) matrix to the current matrix template<template<typename, size_t, size_t> class MatrixType> void add_inplace(const MatrixType<T, n_rows, n_cols>& rhs) { // for each row of the current matrix for (int row = 0; row < n_rows; row++) { // for each column of the current matrix for (int col = 0; col < n_cols; col++) { // add the corresponding element of the // given matrix to that of the current matrix data[row][col] += rhs[row][col]; } } } // method template which creates and returns a new matrix whose elements are the sum // of those in the current matrix and the given (possibly gradient-enabled) matrix template<template<typename, size_t, size_t> class MatrixType> Matrix<T, n_rows, n_cols> add(const MatrixType<T, n_rows, n_cols>& rhs) const { // copy the current matrix Matrix<T, n_rows, n_cols> result = *this; // add the given matrix to this copy result.add_inplace(rhs); // return the result return result; } // returns the transpose of the current matrix Matrix<T, n_cols, n_rows> t() const { // create a matrix to store the result Matrix<T, n_cols, n_rows> result; // for each row of the current matrix for (int row = 0; row < n_rows; row++) { // for each column of the current matrix for (int col = 0; col < n_cols; col++) { // set the diaglonally reflected element // of the result matrix to the corresponding item // of the current matrix result[col][row] = data[row][col]; } } // return the transposed matrix return result; } // prints the matrix void print() const { for (auto& row : data) { for (auto i : row) { std::cout << i << " "; } std::cout << std::endl; } } // two-dimensional array holding the data std::array<std::array<T, n_cols>, n_rows> data; }; }
cclaypool/machine-learning-algorithm-comparison
src/NeuralNetDataset.h
<filename>src/NeuralNetDataset.h #pragma once #include <vector> #include <string> #include <sstream> #include <fstream> #include <iterator> #include "Matrix.h" namespace MLComparison { // class template for a dataset suitable for a neural network model // i.e each row is composed of a Matrix of independent variables // and a dependent variable which is a plain number template<typename T, size_t x_variables, size_t x_variables_to_use = x_variables> class NeuralNetDataset { public: // default constructor which leaves the dataset unpopulated NeuralNetDataset() { } // constructor which takes the name of a csv file to load NeuralNetDataset(const std::string& csv_file) { load_data(csv_file); } Matrix<T, 1, x_variables>& operator[](int i) { return data_table[i]; } const Matrix<T, 1, x_variables>& operator[](int i) const { return data_table[i]; } Matrix<T, 1, x_variables>& at(int i) { return data_table[i]; } const Matrix<T, 1, x_variables>& at(int i) const { return data_table[i]; } auto begin() { return data_table.begin(); } auto end() { return data_table.end(); } auto end(int rows_to_use) { if (rows_to_use < data_table.size() && rows_to_use >= 0) { auto end_iterator = data_table.begin(); std::advance(end_iterator, rows_to_use); return end_iterator; } else { return data_table.end(); } } auto size() { return data_table.size(); } void load_data(const std::string& csv_file) { // open csv file std::ifstream infile(csv_file); // create string and stream to store each line in turn std::string line; std::istringstream line_stream; // create variable for each field std::string item; // for each row for (int row = 0; std::getline(infile, line); row++) { // construct new row in data table data_table.emplace_back(); // create stream for line line_stream = std::istringstream(line); // for each independent variable to use for (int col = 0; col < x_variables_to_use; col++) { // get field from row std::getline(line_stream, item, ','); // set corresponding element in x dataset data_table[row].first[0][col] = std::stod(item); } // skip past each unused independent variable for (int col = 0; col < x_variables - x_variables_to_use; col++) { std::getline(line_stream, item, ','); } // get dependent variable std::getline(line_stream, item, ','); data_table[row].second = std::stod(item); } } void print() { for (auto& row : data_table) { for (auto i : row.first[0]) { std::cout << i << " "; } std::cout << row.second << std::endl; } } private: std::vector<std::pair<Matrix<T, 1, x_variables_to_use>, T>> data_table; }; }
harshavardhana/radhat-trie
src/hat-trie/ahtable.h
<filename>src/hat-trie/ahtable.h<gh_stars>1-10 /* Copyright (c) 2013 Harshavardhana Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This file is part of trie-collection Original Author : <NAME> <<EMAIL>> */ #ifndef HATTRIE_AHTABLE_H #define HATTRIE_AHTABLE_H #ifdef __cplusplus extern "C" { #endif #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include <stdlib.h> #include <stdbool.h> #ifdef HAVE_STDINT_H #include <stdint.h> #else #include "pstdint.h" #endif #include "common.h" typedef unsigned char* slot_t; typedef struct ahtable_t_ { /* these fields are reserved for hattrie to fiddle with */ uint8_t flag; unsigned char c0; unsigned char c1; size_t n; // number of slots size_t m; // numbur of key/value pairs stored size_t max_m; // number of stored keys before we resize size_t* slot_sizes; slot_t* slots; } ahtable_t; extern const double ahtable_max_load_factor; extern const size_t ahtable_initial_size; ahtable_t* ahtable_create (void); // Create an empty hash table. ahtable_t* ahtable_create_n (size_t n); // Create an empty hash table, with // n slots reserved. void ahtable_free (ahtable_t*); // Free all memory used by a table. void ahtable_clear (ahtable_t*); // Remove all entries. size_t ahtable_size (const ahtable_t*); // Number of stored keys. /** Find the given key in the table, inserting it if it does not exist, and * returning a pointer to it's key. * * This pointer is not guaranteed to be valid after additional calls to * ahtable_get, ahtable_del, ahtable_clear, or other functions that modifies the * table. */ value_t* ahtable_get (ahtable_t*, const char* key, size_t len); /** Find a given key in the table, returning a NULL pointer if it does not * exist. */ value_t* ahtable_tryget (ahtable_t*, const char* key, size_t len); int ahtable_del(ahtable_t*, const char* key, size_t len); typedef struct ahtable_iter_t_ ahtable_iter_t; ahtable_iter_t* ahtable_iter_begin (const ahtable_t*, bool sorted); void ahtable_iter_next (ahtable_iter_t*); bool ahtable_iter_finished (ahtable_iter_t*); void ahtable_iter_free (ahtable_iter_t*); const char* ahtable_iter_key (ahtable_iter_t*, size_t* len); value_t* ahtable_iter_val (ahtable_iter_t*); #ifdef __cplusplus } #endif #endif
harshavardhana/radhat-trie
src/hat-trie/hat-trie.h
<filename>src/hat-trie/hat-trie.h /* Copyright (c) 2013 Harshavardhana Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. This file is part of trie-collection Original Author : <NAME> <<EMAIL>> */ #ifndef HATTRIE_HATTRIE_H #define HATTRIE_HATTRIE_H #ifdef __cplusplus extern "C" { #endif #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #include <stdlib.h> #include <stdbool.h> #include "common.h" typedef struct hattrie_t_ hattrie_t; hattrie_t* hattrie_create (void); //< Create an empty hat-trie. void hattrie_free (hattrie_t*); //< Free all memory used by a trie. hattrie_t* hattrie_dup (const hattrie_t*); //< Duplicate an existing trie. void hattrie_clear (hattrie_t*); //< Remove all entries. /** Find the given key in the trie, inserting it if it does not exist, and * returning a pointer to it's key. * * This pointer is not guaranteed to be valid after additional calls to * hattrie_get, hattrie_del, hattrie_clear, or other functions that modifies the * trie. */ value_t* hattrie_get (hattrie_t*, const char* key, size_t len); /** Find a given key in the table, returning a NULL pointer if it does not * exist. */ value_t* hattrie_tryget (hattrie_t*, const char* key, size_t len); /** Delete a given key from trie. Returns 0 if successful or -1 if not found. */ int hattrie_del(hattrie_t* T, const char* key, size_t len); typedef struct hattrie_iter_t_ hattrie_iter_t; hattrie_iter_t* hattrie_iter_begin (const hattrie_t*, bool sorted); void hattrie_iter_next (hattrie_iter_t*); bool hattrie_iter_finished (hattrie_iter_t*); void hattrie_iter_free (hattrie_iter_t*); const char* hattrie_iter_key (hattrie_iter_t*, size_t* len); value_t* hattrie_iter_val (hattrie_iter_t*); #ifdef __cplusplus } #endif #endif
harshavardhana/radhat-trie
src/trie/trie.h
/* trie.h: Trie data structure. Copyright (c) 2013 Harshavardhana Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Original Author: <NAME> <<EMAIL>> */ #ifndef _TRIE_H #define _TRIE_H #ifndef _CONFIG_H #define _CONFIG_H #include "config.h" #endif #define min(a,b) ((a)<(b)?(a):(b)) #define DISTANCE_EDIT 1 #define DISTANCE_INS 1 #define DISTANCE_DEL 1 struct trienode { char id; char eow; int depth; void *data; struct trie *trie; struct trienode *parent; struct trienode *subnodes[255]; }; struct trie { struct trienode root; int nodecnt; size_t len; }; struct trienode; typedef struct trienode trienode_t; struct trie; typedef struct trie trie_t; struct trienodevec { trienode_t **nodes; unsigned cnt; }; struct trienodevec_w { struct trienodevec *vec; const char *word; }; trie_t *trie_new (); int trie_add (trie_t *trie, const char *word); void trie_destroy (trie_t *trie); void trie_destroy_bynode (trienode_t *node); int trie_measure (trie_t *trie, const char *word, trienode_t **nodes, int nodecnt); int trie_measure_vec (trie_t *trie, const char *word, struct trienodevec *nodevec); void trie_reset_search (trie_t *trie); int trienode_get_dist (trienode_t *node); int trienode_get_word (trienode_t *node, char **buf); #endif /* _TRIE_H */
sindresorhus/win-term-size
term-size.c
#include <stdio.h> #include <windows.h> int wmain() { CONSOLE_SCREEN_BUFFER_INFO info; HANDLE tmpConsole = CreateConsoleScreenBuffer(GENERIC_READ, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); // can't use `GetStdHandle(STD_OUTPUT_HANDLE)` as it doesn't work when output is redirected GetConsoleScreenBufferInfo(tmpConsole, &info); CloseHandle(tmpConsole); int columns = info.dwMaximumWindowSize.X; int rows = info.dwMaximumWindowSize.Y; printf("%d\n%d\n", columns, rows); return 0; }
k-tomoyasu/MPPSample
ios/MPPSample/common.framework/Headers/common.h
<gh_stars>0 #import <Foundation/NSArray.h> #import <Foundation/NSDictionary.h> #import <Foundation/NSError.h> #import <Foundation/NSObject.h> #import <Foundation/NSSet.h> #import <Foundation/NSString.h> #import <Foundation/NSValue.h> @class CommonRepositoryList, CommonKotlinException, CommonRepository, CommonKotlinArray, CommonKotlinThrowable, CommonKotlinx_serialization_runtimeEnumDescriptor, CommonKotlinx_serialization_runtimeSerialKind, CommonKotlinNothing, CommonKotlinx_serialization_runtimeUpdateMode, CommonKotlinx_serialization_runtimeSerialClassDescImpl, CommonKotlinEnum; @protocol CommonKotlinx_serialization_runtimeKSerializer, CommonKotlinx_serialization_runtimeEncoder, CommonKotlinx_serialization_runtimeSerialDescriptor, CommonKotlinx_serialization_runtimeSerializationStrategy, CommonKotlinx_serialization_runtimeDecoder, CommonKotlinx_serialization_runtimeDeserializationStrategy, CommonKotlinx_serialization_runtimeGeneratedSerializer, CommonKotlinIterator, CommonKotlinx_serialization_runtimeCompositeEncoder, CommonKotlinx_serialization_runtimeSerialModule, CommonKotlinAnnotation, CommonKotlinx_serialization_runtimeCompositeDecoder, CommonKotlinx_serialization_runtimeSerialModuleCollector, CommonKotlinKClass, CommonKotlinComparable, CommonKotlinKDeclarationContainer, CommonKotlinKAnnotatedElement, CommonKotlinKClassifier; NS_ASSUME_NONNULL_BEGIN #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunknown-warning-option" #pragma clang diagnostic ignored "-Wnullability" #pragma clang diagnostic ignored "-Wnullability-completeness" #pragma clang diagnostic ignored "-Wswift-name-attribute" @interface KotlinBase : NSObject - (instancetype)init __attribute__((unavailable)); + (instancetype)new __attribute__((unavailable)); + (void)initialize __attribute__((objc_requires_super)); @end; @interface KotlinBase (KotlinBaseCopying) <NSCopying> @end; __attribute__((objc_runtime_name("KotlinMutableSet"))) __attribute__((swift_name("KotlinMutableSet"))) @interface CommonMutableSet<ObjectType> : NSMutableSet<ObjectType> @end; __attribute__((objc_runtime_name("KotlinMutableDictionary"))) __attribute__((swift_name("KotlinMutableDictionary"))) @interface CommonMutableDictionary<KeyType, ObjectType> : NSMutableDictionary<KeyType, ObjectType> @end; @interface NSError (NSErrorKotlinException) @property (readonly) id _Nullable kotlinException; @end; __attribute__((objc_runtime_name("KotlinNumber"))) __attribute__((swift_name("KotlinNumber"))) @interface CommonNumber : NSNumber - (instancetype)initWithChar:(char)value __attribute__((unavailable)); - (instancetype)initWithUnsignedChar:(unsigned char)value __attribute__((unavailable)); - (instancetype)initWithShort:(short)value __attribute__((unavailable)); - (instancetype)initWithUnsignedShort:(unsigned short)value __attribute__((unavailable)); - (instancetype)initWithInt:(int)value __attribute__((unavailable)); - (instancetype)initWithUnsignedInt:(unsigned int)value __attribute__((unavailable)); - (instancetype)initWithLong:(long)value __attribute__((unavailable)); - (instancetype)initWithUnsignedLong:(unsigned long)value __attribute__((unavailable)); - (instancetype)initWithLongLong:(long long)value __attribute__((unavailable)); - (instancetype)initWithUnsignedLongLong:(unsigned long long)value __attribute__((unavailable)); - (instancetype)initWithFloat:(float)value __attribute__((unavailable)); - (instancetype)initWithDouble:(double)value __attribute__((unavailable)); - (instancetype)initWithBool:(BOOL)value __attribute__((unavailable)); - (instancetype)initWithInteger:(NSInteger)value __attribute__((unavailable)); - (instancetype)initWithUnsignedInteger:(NSUInteger)value __attribute__((unavailable)); + (instancetype)numberWithChar:(char)value __attribute__((unavailable)); + (instancetype)numberWithUnsignedChar:(unsigned char)value __attribute__((unavailable)); + (instancetype)numberWithShort:(short)value __attribute__((unavailable)); + (instancetype)numberWithUnsignedShort:(unsigned short)value __attribute__((unavailable)); + (instancetype)numberWithInt:(int)value __attribute__((unavailable)); + (instancetype)numberWithUnsignedInt:(unsigned int)value __attribute__((unavailable)); + (instancetype)numberWithLong:(long)value __attribute__((unavailable)); + (instancetype)numberWithUnsignedLong:(unsigned long)value __attribute__((unavailable)); + (instancetype)numberWithLongLong:(long long)value __attribute__((unavailable)); + (instancetype)numberWithUnsignedLongLong:(unsigned long long)value __attribute__((unavailable)); + (instancetype)numberWithFloat:(float)value __attribute__((unavailable)); + (instancetype)numberWithDouble:(double)value __attribute__((unavailable)); + (instancetype)numberWithBool:(BOOL)value __attribute__((unavailable)); + (instancetype)numberWithInteger:(NSInteger)value __attribute__((unavailable)); + (instancetype)numberWithUnsignedInteger:(NSUInteger)value __attribute__((unavailable)); @end; __attribute__((objc_runtime_name("KotlinByte"))) __attribute__((swift_name("KotlinByte"))) @interface CommonByte : CommonNumber - (instancetype)initWithChar:(char)value; + (instancetype)numberWithChar:(char)value; @end; __attribute__((objc_runtime_name("KotlinUByte"))) __attribute__((swift_name("KotlinUByte"))) @interface CommonUByte : CommonNumber - (instancetype)initWithUnsignedChar:(unsigned char)value; + (instancetype)numberWithUnsignedChar:(unsigned char)value; @end; __attribute__((objc_runtime_name("KotlinShort"))) __attribute__((swift_name("KotlinShort"))) @interface CommonShort : CommonNumber - (instancetype)initWithShort:(short)value; + (instancetype)numberWithShort:(short)value; @end; __attribute__((objc_runtime_name("KotlinUShort"))) __attribute__((swift_name("KotlinUShort"))) @interface CommonUShort : CommonNumber - (instancetype)initWithUnsignedShort:(unsigned short)value; + (instancetype)numberWithUnsignedShort:(unsigned short)value; @end; __attribute__((objc_runtime_name("KotlinInt"))) __attribute__((swift_name("KotlinInt"))) @interface CommonInt : CommonNumber - (instancetype)initWithInt:(int)value; + (instancetype)numberWithInt:(int)value; @end; __attribute__((objc_runtime_name("KotlinUInt"))) __attribute__((swift_name("KotlinUInt"))) @interface CommonUInt : CommonNumber - (instancetype)initWithUnsignedInt:(unsigned int)value; + (instancetype)numberWithUnsignedInt:(unsigned int)value; @end; __attribute__((objc_runtime_name("KotlinLong"))) __attribute__((swift_name("KotlinLong"))) @interface CommonLong : CommonNumber - (instancetype)initWithLongLong:(long long)value; + (instancetype)numberWithLongLong:(long long)value; @end; __attribute__((objc_runtime_name("KotlinULong"))) __attribute__((swift_name("KotlinULong"))) @interface CommonULong : CommonNumber - (instancetype)initWithUnsignedLongLong:(unsigned long long)value; + (instancetype)numberWithUnsignedLongLong:(unsigned long long)value; @end; __attribute__((objc_runtime_name("KotlinFloat"))) __attribute__((swift_name("KotlinFloat"))) @interface CommonFloat : CommonNumber - (instancetype)initWithFloat:(float)value; + (instancetype)numberWithFloat:(float)value; @end; __attribute__((objc_runtime_name("KotlinDouble"))) __attribute__((swift_name("KotlinDouble"))) @interface CommonDouble : CommonNumber - (instancetype)initWithDouble:(double)value; + (instancetype)numberWithDouble:(double)value; @end; __attribute__((objc_runtime_name("KotlinBoolean"))) __attribute__((swift_name("KotlinBoolean"))) @interface CommonBoolean : CommonNumber - (instancetype)initWithBool:(BOOL)value; + (instancetype)numberWithBool:(BOOL)value; @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("ApiClient"))) @interface CommonApiClient : KotlinBase - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (void)searchRepositoryValue:(NSString *)value onSuccess:(void (^)(CommonRepositoryList *))onSuccess onError:(void (^)(CommonKotlinException *))onError __attribute__((swift_name("searchRepository(value:onSuccess:onError:)"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("ApiClient.Companion"))) @interface CommonApiClientCompanion : KotlinBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)companion __attribute__((swift_name("init()"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Preference"))) @interface CommonPreference : KotlinBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)preference __attribute__((swift_name("init()"))); - (NSString *)getKey:(NSString *)key __attribute__((swift_name("get(key:)"))); - (void)putKey:(NSString *)key value:(NSString *)value __attribute__((swift_name("put(key:value:)"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("RepositoryList"))) @interface CommonRepositoryList : KotlinBase - (instancetype)initWithSeen1:(int32_t)seen1 count:(int32_t)count items:(NSArray<CommonRepository *> * _Nullable)items serializationConstructorMarker:(id _Nullable)serializationConstructorMarker __attribute__((swift_name("init(seen1:count:items:serializationConstructorMarker:)"))) __attribute__((objc_designated_initializer)); - (instancetype)initWithCount:(int32_t)count items:(NSArray<CommonRepository *> *)items __attribute__((swift_name("init(count:items:)"))) __attribute__((objc_designated_initializer)); - (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)"))); - (NSUInteger)hash __attribute__((swift_name("hash()"))); - (NSString *)description __attribute__((swift_name("description()"))); - (int32_t)component1 __attribute__((swift_name("component1()"))); - (NSArray<CommonRepository *> *)component2 __attribute__((swift_name("component2()"))); - (CommonRepositoryList *)doCopyCount:(int32_t)count items:(NSArray<CommonRepository *> *)items __attribute__((swift_name("doCopy(count:items:)"))); @property (readonly) int32_t count __attribute__((swift_name("count"))); @property (readonly) NSArray<CommonRepository *> *items __attribute__((swift_name("items"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("RepositoryList.Companion"))) @interface CommonRepositoryListCompanion : KotlinBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)companion __attribute__((swift_name("init()"))); - (id<CommonKotlinx_serialization_runtimeKSerializer>)serializer __attribute__((swift_name("serializer()"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeSerializationStrategy"))) @protocol CommonKotlinx_serialization_runtimeSerializationStrategy @required - (void)serializeEncoder:(id<CommonKotlinx_serialization_runtimeEncoder>)encoder obj:(id _Nullable)obj __attribute__((swift_name("serialize(encoder:obj:)"))); @property (readonly) id<CommonKotlinx_serialization_runtimeSerialDescriptor> descriptor __attribute__((swift_name("descriptor"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeDeserializationStrategy"))) @protocol CommonKotlinx_serialization_runtimeDeserializationStrategy @required - (id _Nullable)deserializeDecoder:(id<CommonKotlinx_serialization_runtimeDecoder>)decoder __attribute__((swift_name("deserialize(decoder:)"))); - (id _Nullable)patchDecoder:(id<CommonKotlinx_serialization_runtimeDecoder>)decoder old:(id _Nullable)old __attribute__((swift_name("patch(decoder:old:)"))); @property (readonly) id<CommonKotlinx_serialization_runtimeSerialDescriptor> descriptor __attribute__((swift_name("descriptor"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeKSerializer"))) @protocol CommonKotlinx_serialization_runtimeKSerializer <CommonKotlinx_serialization_runtimeSerializationStrategy, CommonKotlinx_serialization_runtimeDeserializationStrategy> @required @end; __attribute__((swift_name("Kotlinx_serialization_runtimeGeneratedSerializer"))) @protocol CommonKotlinx_serialization_runtimeGeneratedSerializer <CommonKotlinx_serialization_runtimeKSerializer> @required - (CommonKotlinArray *)childSerializers __attribute__((swift_name("childSerializers()"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("RepositoryList.$serializer"))) @interface CommonRepositoryList$serializer : KotlinBase <CommonKotlinx_serialization_runtimeGeneratedSerializer> + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)$serializer __attribute__((swift_name("init()"))); - (CommonKotlinArray *)childSerializers __attribute__((swift_name("childSerializers()"))); - (CommonRepositoryList *)deserializeDecoder:(id<CommonKotlinx_serialization_runtimeDecoder>)decoder __attribute__((swift_name("deserialize(decoder:)"))); - (CommonRepositoryList *)patchDecoder:(id<CommonKotlinx_serialization_runtimeDecoder>)decoder old:(CommonRepositoryList *)old __attribute__((swift_name("patch(decoder:old:)"))); - (void)serializeEncoder:(id<CommonKotlinx_serialization_runtimeEncoder>)encoder obj:(CommonRepositoryList *)obj __attribute__((swift_name("serialize(encoder:obj:)"))); @property (readonly) id<CommonKotlinx_serialization_runtimeSerialDescriptor> descriptor __attribute__((swift_name("descriptor"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Repository"))) @interface CommonRepository : KotlinBase - (instancetype)initWithSeen1:(int32_t)seen1 name:(NSString * _Nullable)name description:(NSString * _Nullable)description starCount:(int32_t)starCount serializationConstructorMarker:(id _Nullable)serializationConstructorMarker __attribute__((swift_name("init(seen1:name:description:starCount:serializationConstructorMarker:)"))) __attribute__((objc_designated_initializer)); - (instancetype)initWithName:(NSString *)name description:(NSString *)description starCount:(int32_t)starCount __attribute__((swift_name("init(name:description:starCount:)"))) __attribute__((objc_designated_initializer)); - (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)"))); - (NSUInteger)hash __attribute__((swift_name("hash()"))); - (NSString *)description __attribute__((swift_name("description()"))); - (NSString *)component1 __attribute__((swift_name("component1()"))); - (NSString *)component2 __attribute__((swift_name("component2()"))); - (int32_t)component3 __attribute__((swift_name("component3()"))); - (CommonRepository *)doCopyName:(NSString *)name description:(NSString *)description starCount:(int32_t)starCount __attribute__((swift_name("doCopy(name:description:starCount:)"))); @property (readonly) NSString *name __attribute__((swift_name("name"))); @property (readonly, getter=description_) NSString *description __attribute__((swift_name("description"))); @property (readonly) int32_t starCount __attribute__((swift_name("starCount"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Repository.Companion"))) @interface CommonRepositoryCompanion : KotlinBase + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)companion __attribute__((swift_name("init()"))); - (id<CommonKotlinx_serialization_runtimeKSerializer>)serializer __attribute__((swift_name("serializer()"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Repository.$serializer"))) @interface CommonRepository$serializer : KotlinBase <CommonKotlinx_serialization_runtimeGeneratedSerializer> + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); + (instancetype)$serializer __attribute__((swift_name("init()"))); - (CommonKotlinArray *)childSerializers __attribute__((swift_name("childSerializers()"))); - (CommonRepository *)deserializeDecoder:(id<CommonKotlinx_serialization_runtimeDecoder>)decoder __attribute__((swift_name("deserialize(decoder:)"))); - (CommonRepository *)patchDecoder:(id<CommonKotlinx_serialization_runtimeDecoder>)decoder old:(CommonRepository *)old __attribute__((swift_name("patch(decoder:old:)"))); - (void)serializeEncoder:(id<CommonKotlinx_serialization_runtimeEncoder>)encoder obj:(CommonRepository *)obj __attribute__((swift_name("serialize(encoder:obj:)"))); @property (readonly) id<CommonKotlinx_serialization_runtimeSerialDescriptor> descriptor __attribute__((swift_name("descriptor"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("CommonKt"))) @interface CommonCommonKt : KotlinBase @property (class, readonly) NSString *KEY_LAST_SEARCH __attribute__((swift_name("KEY_LAST_SEARCH"))); @end; __attribute__((swift_name("KotlinThrowable"))) @interface CommonKotlinThrowable : KotlinBase - (instancetype)initWithMessage:(NSString * _Nullable)message __attribute__((swift_name("init(message:)"))) __attribute__((objc_designated_initializer)); - (instancetype)initWithCause:(CommonKotlinThrowable * _Nullable)cause __attribute__((swift_name("init(cause:)"))) __attribute__((objc_designated_initializer)); - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (instancetype)initWithMessage:(NSString * _Nullable)message cause:(CommonKotlinThrowable * _Nullable)cause __attribute__((swift_name("init(message:cause:)"))) __attribute__((objc_designated_initializer)); - (CommonKotlinArray *)getStackTrace __attribute__((swift_name("getStackTrace()"))); - (void)printStackTrace __attribute__((swift_name("printStackTrace()"))); - (NSString *)description __attribute__((swift_name("description()"))); @property (readonly) CommonKotlinThrowable * _Nullable cause __attribute__((swift_name("cause"))); @property (readonly) NSString * _Nullable message __attribute__((swift_name("message"))); @end; __attribute__((swift_name("KotlinException"))) @interface CommonKotlinException : CommonKotlinThrowable - (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (instancetype)initWithMessage:(NSString * _Nullable)message __attribute__((swift_name("init(message:)"))) __attribute__((objc_designated_initializer)); - (instancetype)initWithMessage:(NSString * _Nullable)message cause:(CommonKotlinThrowable * _Nullable)cause __attribute__((swift_name("init(message:cause:)"))) __attribute__((objc_designated_initializer)); - (instancetype)initWithCause:(CommonKotlinThrowable * _Nullable)cause __attribute__((swift_name("init(cause:)"))) __attribute__((objc_designated_initializer)); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("KotlinArray"))) @interface CommonKotlinArray : KotlinBase + (instancetype)arrayWithSize:(int32_t)size init:(id _Nullable (^)(CommonInt *))init __attribute__((swift_name("init(size:init:)"))); + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); - (id _Nullable)getIndex:(int32_t)index __attribute__((swift_name("get(index:)"))); - (id<CommonKotlinIterator>)iterator __attribute__((swift_name("iterator()"))); - (void)setIndex:(int32_t)index value:(id _Nullable)value __attribute__((swift_name("set(index:value:)"))); @property (readonly) int32_t size __attribute__((swift_name("size"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeEncoder"))) @protocol CommonKotlinx_serialization_runtimeEncoder @required - (id<CommonKotlinx_serialization_runtimeCompositeEncoder>)beginCollectionDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc collectionSize:(int32_t)collectionSize typeParams:(CommonKotlinArray *)typeParams __attribute__((swift_name("beginCollection(desc:collectionSize:typeParams:)"))); - (id<CommonKotlinx_serialization_runtimeCompositeEncoder>)beginStructureDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc typeParams:(CommonKotlinArray *)typeParams __attribute__((swift_name("beginStructure(desc:typeParams:)"))); - (void)encodeBooleanValue:(BOOL)value __attribute__((swift_name("encodeBoolean(value:)"))); - (void)encodeByteValue:(int8_t)value __attribute__((swift_name("encodeByte(value:)"))); - (void)encodeCharValue:(unichar)value __attribute__((swift_name("encodeChar(value:)"))); - (void)encodeDoubleValue:(double)value __attribute__((swift_name("encodeDouble(value:)"))); - (void)encodeEnumEnumDescription:(CommonKotlinx_serialization_runtimeEnumDescriptor *)enumDescription ordinal:(int32_t)ordinal __attribute__((swift_name("encodeEnum(enumDescription:ordinal:)"))); - (void)encodeFloatValue:(float)value __attribute__((swift_name("encodeFloat(value:)"))); - (void)encodeIntValue:(int32_t)value __attribute__((swift_name("encodeInt(value:)"))); - (void)encodeLongValue:(int64_t)value __attribute__((swift_name("encodeLong(value:)"))); - (void)encodeNotNullMark __attribute__((swift_name("encodeNotNullMark()"))); - (void)encodeNull __attribute__((swift_name("encodeNull()"))); - (void)encodeNullableSerializableValueSerializer:(id<CommonKotlinx_serialization_runtimeSerializationStrategy>)serializer value:(id _Nullable)value __attribute__((swift_name("encodeNullableSerializableValue(serializer:value:)"))); - (void)encodeSerializableValueSerializer:(id<CommonKotlinx_serialization_runtimeSerializationStrategy>)serializer value:(id _Nullable)value __attribute__((swift_name("encodeSerializableValue(serializer:value:)"))); - (void)encodeShortValue:(int16_t)value __attribute__((swift_name("encodeShort(value:)"))); - (void)encodeStringValue:(NSString *)value __attribute__((swift_name("encodeString(value:)"))); - (void)encodeUnit __attribute__((swift_name("encodeUnit()"))); @property (readonly) id<CommonKotlinx_serialization_runtimeSerialModule> context __attribute__((swift_name("context"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeSerialDescriptor"))) @protocol CommonKotlinx_serialization_runtimeSerialDescriptor @required - (NSArray<id<CommonKotlinAnnotation>> *)getElementAnnotationsIndex:(int32_t)index __attribute__((swift_name("getElementAnnotations(index:)"))); - (id<CommonKotlinx_serialization_runtimeSerialDescriptor>)getElementDescriptorIndex:(int32_t)index __attribute__((swift_name("getElementDescriptor(index:)"))); - (int32_t)getElementIndexName:(NSString *)name __attribute__((swift_name("getElementIndex(name:)"))); - (NSString *)getElementNameIndex:(int32_t)index __attribute__((swift_name("getElementName(index:)"))); - (NSArray<id<CommonKotlinAnnotation>> *)getEntityAnnotations __attribute__((swift_name("getEntityAnnotations()"))); - (BOOL)isElementOptionalIndex:(int32_t)index __attribute__((swift_name("isElementOptional(index:)"))); @property (readonly) int32_t elementsCount __attribute__((swift_name("elementsCount"))); @property (readonly) BOOL isNullable __attribute__((swift_name("isNullable"))); @property (readonly) CommonKotlinx_serialization_runtimeSerialKind *kind __attribute__((swift_name("kind"))); @property (readonly) NSString *name __attribute__((swift_name("name"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeDecoder"))) @protocol CommonKotlinx_serialization_runtimeDecoder @required - (id<CommonKotlinx_serialization_runtimeCompositeDecoder>)beginStructureDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc typeParams:(CommonKotlinArray *)typeParams __attribute__((swift_name("beginStructure(desc:typeParams:)"))); - (BOOL)decodeBoolean __attribute__((swift_name("decodeBoolean()"))); - (int8_t)decodeByte __attribute__((swift_name("decodeByte()"))); - (unichar)decodeChar __attribute__((swift_name("decodeChar()"))); - (double)decodeDouble __attribute__((swift_name("decodeDouble()"))); - (int32_t)decodeEnumEnumDescription:(CommonKotlinx_serialization_runtimeEnumDescriptor *)enumDescription __attribute__((swift_name("decodeEnum(enumDescription:)"))); - (float)decodeFloat __attribute__((swift_name("decodeFloat()"))); - (int32_t)decodeInt __attribute__((swift_name("decodeInt()"))); - (int64_t)decodeLong __attribute__((swift_name("decodeLong()"))); - (BOOL)decodeNotNullMark __attribute__((swift_name("decodeNotNullMark()"))); - (CommonKotlinNothing * _Nullable)decodeNull __attribute__((swift_name("decodeNull()"))); - (id _Nullable)decodeNullableSerializableValueDeserializer:(id<CommonKotlinx_serialization_runtimeDeserializationStrategy>)deserializer __attribute__((swift_name("decodeNullableSerializableValue(deserializer:)"))); - (id _Nullable)decodeSerializableValueDeserializer:(id<CommonKotlinx_serialization_runtimeDeserializationStrategy>)deserializer __attribute__((swift_name("decodeSerializableValue(deserializer:)"))); - (int16_t)decodeShort __attribute__((swift_name("decodeShort()"))); - (NSString *)decodeString __attribute__((swift_name("decodeString()"))); - (void)decodeUnit __attribute__((swift_name("decodeUnit()"))); - (id _Nullable)updateNullableSerializableValueDeserializer:(id<CommonKotlinx_serialization_runtimeDeserializationStrategy>)deserializer old:(id _Nullable)old __attribute__((swift_name("updateNullableSerializableValue(deserializer:old:)"))); - (id _Nullable)updateSerializableValueDeserializer:(id<CommonKotlinx_serialization_runtimeDeserializationStrategy>)deserializer old:(id _Nullable)old __attribute__((swift_name("updateSerializableValue(deserializer:old:)"))); @property (readonly) id<CommonKotlinx_serialization_runtimeSerialModule> context __attribute__((swift_name("context"))); @property (readonly) CommonKotlinx_serialization_runtimeUpdateMode *updateMode __attribute__((swift_name("updateMode"))); @end; __attribute__((swift_name("KotlinIterator"))) @protocol CommonKotlinIterator @required - (BOOL)hasNext __attribute__((swift_name("hasNext()"))); - (id _Nullable)next __attribute__((swift_name("next()"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeCompositeEncoder"))) @protocol CommonKotlinx_serialization_runtimeCompositeEncoder @required - (void)encodeBooleanElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(BOOL)value __attribute__((swift_name("encodeBooleanElement(desc:index:value:)"))); - (void)encodeByteElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(int8_t)value __attribute__((swift_name("encodeByteElement(desc:index:value:)"))); - (void)encodeCharElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(unichar)value __attribute__((swift_name("encodeCharElement(desc:index:value:)"))); - (void)encodeDoubleElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(double)value __attribute__((swift_name("encodeDoubleElement(desc:index:value:)"))); - (void)encodeFloatElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(float)value __attribute__((swift_name("encodeFloatElement(desc:index:value:)"))); - (void)encodeIntElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(int32_t)value __attribute__((swift_name("encodeIntElement(desc:index:value:)"))); - (void)encodeLongElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(int64_t)value __attribute__((swift_name("encodeLongElement(desc:index:value:)"))); - (void)encodeNonSerializableElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(id)value __attribute__((swift_name("encodeNonSerializableElement(desc:index:value:)"))); - (void)encodeNullableSerializableElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index serializer:(id<CommonKotlinx_serialization_runtimeSerializationStrategy>)serializer value:(id _Nullable)value __attribute__((swift_name("encodeNullableSerializableElement(desc:index:serializer:value:)"))); - (void)encodeSerializableElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index serializer:(id<CommonKotlinx_serialization_runtimeSerializationStrategy>)serializer value:(id _Nullable)value __attribute__((swift_name("encodeSerializableElement(desc:index:serializer:value:)"))); - (void)encodeShortElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(int16_t)value __attribute__((swift_name("encodeShortElement(desc:index:value:)"))); - (void)encodeStringElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index value:(NSString *)value __attribute__((swift_name("encodeStringElement(desc:index:value:)"))); - (void)encodeUnitElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("encodeUnitElement(desc:index:)"))); - (void)endStructureDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc __attribute__((swift_name("endStructure(desc:)"))); - (BOOL)shouldEncodeElementDefaultDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("shouldEncodeElementDefault(desc:index:)"))); @property (readonly) id<CommonKotlinx_serialization_runtimeSerialModule> context __attribute__((swift_name("context"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeSerialClassDescImpl"))) @interface CommonKotlinx_serialization_runtimeSerialClassDescImpl : KotlinBase <CommonKotlinx_serialization_runtimeSerialDescriptor> - (instancetype)initWithName:(NSString *)name generatedSerializer:(id<CommonKotlinx_serialization_runtimeGeneratedSerializer> _Nullable)generatedSerializer __attribute__((swift_name("init(name:generatedSerializer:)"))) __attribute__((objc_designated_initializer)); - (void)addElementName:(NSString *)name isOptional:(BOOL)isOptional __attribute__((swift_name("addElement(name:isOptional:)"))); - (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)"))); - (NSArray<id<CommonKotlinAnnotation>> *)getElementAnnotationsIndex:(int32_t)index __attribute__((swift_name("getElementAnnotations(index:)"))); - (id<CommonKotlinx_serialization_runtimeSerialDescriptor>)getElementDescriptorIndex:(int32_t)index __attribute__((swift_name("getElementDescriptor(index:)"))); - (int32_t)getElementIndexName:(NSString *)name __attribute__((swift_name("getElementIndex(name:)"))); - (NSString *)getElementNameIndex:(int32_t)index __attribute__((swift_name("getElementName(index:)"))); - (NSArray<id<CommonKotlinAnnotation>> *)getEntityAnnotations __attribute__((swift_name("getEntityAnnotations()"))); - (NSUInteger)hash __attribute__((swift_name("hash()"))); - (BOOL)isElementOptionalIndex:(int32_t)index __attribute__((swift_name("isElementOptional(index:)"))); - (void)pushAnnotationA:(id<CommonKotlinAnnotation>)a __attribute__((swift_name("pushAnnotation(a:)"))); - (void)pushClassAnnotationA:(id<CommonKotlinAnnotation>)a __attribute__((swift_name("pushClassAnnotation(a:)"))); - (void)pushDescriptorDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc __attribute__((swift_name("pushDescriptor(desc:)"))); - (NSString *)description __attribute__((swift_name("description()"))); @property (readonly) int32_t elementsCount __attribute__((swift_name("elementsCount"))); @property (readonly) CommonKotlinx_serialization_runtimeSerialKind *kind __attribute__((swift_name("kind"))); @property (readonly) NSString *name __attribute__((swift_name("name"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Kotlinx_serialization_runtimeEnumDescriptor"))) @interface CommonKotlinx_serialization_runtimeEnumDescriptor : CommonKotlinx_serialization_runtimeSerialClassDescImpl - (instancetype)initWithName:(NSString *)name choices:(CommonKotlinArray *)choices __attribute__((swift_name("init(name:choices:)"))) __attribute__((objc_designated_initializer)); - (instancetype)initWithName:(NSString *)name generatedSerializer:(id<CommonKotlinx_serialization_runtimeGeneratedSerializer> _Nullable)generatedSerializer __attribute__((swift_name("init(name:generatedSerializer:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable)); - (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)"))); - (id<CommonKotlinx_serialization_runtimeSerialDescriptor>)getElementDescriptorIndex:(int32_t)index __attribute__((swift_name("getElementDescriptor(index:)"))); - (NSUInteger)hash __attribute__((swift_name("hash()"))); @property (readonly) CommonKotlinx_serialization_runtimeSerialKind *kind __attribute__((swift_name("kind"))); @property (readonly) NSString *name __attribute__((swift_name("name"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeSerialModule"))) @protocol CommonKotlinx_serialization_runtimeSerialModule @required - (void)dumpToCollector:(id<CommonKotlinx_serialization_runtimeSerialModuleCollector>)collector __attribute__((swift_name("dumpTo(collector:)"))); - (id<CommonKotlinx_serialization_runtimeKSerializer> _Nullable)getContextualKclass:(id<CommonKotlinKClass>)kclass __attribute__((swift_name("getContextual(kclass:)"))); - (id<CommonKotlinx_serialization_runtimeKSerializer> _Nullable)getPolymorphicBaseClass:(id<CommonKotlinKClass>)baseClass value:(id)value __attribute__((swift_name("getPolymorphic(baseClass:value:)"))); - (id<CommonKotlinx_serialization_runtimeKSerializer> _Nullable)getPolymorphicBaseClass:(id<CommonKotlinKClass>)baseClass serializedClassName:(NSString *)serializedClassName __attribute__((swift_name("getPolymorphic(baseClass:serializedClassName:)"))); @end; __attribute__((swift_name("KotlinAnnotation"))) @protocol CommonKotlinAnnotation @required @end; __attribute__((swift_name("Kotlinx_serialization_runtimeSerialKind"))) @interface CommonKotlinx_serialization_runtimeSerialKind : KotlinBase @end; __attribute__((swift_name("Kotlinx_serialization_runtimeCompositeDecoder"))) @protocol CommonKotlinx_serialization_runtimeCompositeDecoder @required - (BOOL)decodeBooleanElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeBooleanElement(desc:index:)"))); - (int8_t)decodeByteElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeByteElement(desc:index:)"))); - (unichar)decodeCharElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeCharElement(desc:index:)"))); - (int32_t)decodeCollectionSizeDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc __attribute__((swift_name("decodeCollectionSize(desc:)"))); - (double)decodeDoubleElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeDoubleElement(desc:index:)"))); - (int32_t)decodeElementIndexDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc __attribute__((swift_name("decodeElementIndex(desc:)"))); - (float)decodeFloatElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeFloatElement(desc:index:)"))); - (int32_t)decodeIntElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeIntElement(desc:index:)"))); - (int64_t)decodeLongElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeLongElement(desc:index:)"))); - (id _Nullable)decodeNullableSerializableElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index deserializer:(id<CommonKotlinx_serialization_runtimeDeserializationStrategy>)deserializer __attribute__((swift_name("decodeNullableSerializableElement(desc:index:deserializer:)"))); - (id _Nullable)decodeSerializableElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index deserializer:(id<CommonKotlinx_serialization_runtimeDeserializationStrategy>)deserializer __attribute__((swift_name("decodeSerializableElement(desc:index:deserializer:)"))); - (int16_t)decodeShortElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeShortElement(desc:index:)"))); - (NSString *)decodeStringElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeStringElement(desc:index:)"))); - (void)decodeUnitElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index __attribute__((swift_name("decodeUnitElement(desc:index:)"))); - (void)endStructureDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc __attribute__((swift_name("endStructure(desc:)"))); - (id _Nullable)updateNullableSerializableElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index deserializer:(id<CommonKotlinx_serialization_runtimeDeserializationStrategy>)deserializer old:(id _Nullable)old __attribute__((swift_name("updateNullableSerializableElement(desc:index:deserializer:old:)"))); - (id _Nullable)updateSerializableElementDesc:(id<CommonKotlinx_serialization_runtimeSerialDescriptor>)desc index:(int32_t)index deserializer:(id<CommonKotlinx_serialization_runtimeDeserializationStrategy>)deserializer old:(id _Nullable)old __attribute__((swift_name("updateSerializableElement(desc:index:deserializer:old:)"))); @property (readonly) id<CommonKotlinx_serialization_runtimeSerialModule> context __attribute__((swift_name("context"))); @property (readonly) CommonKotlinx_serialization_runtimeUpdateMode *updateMode __attribute__((swift_name("updateMode"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("KotlinNothing"))) @interface CommonKotlinNothing : KotlinBase @end; __attribute__((swift_name("KotlinComparable"))) @protocol CommonKotlinComparable @required - (int32_t)compareToOther:(id _Nullable)other __attribute__((swift_name("compareTo(other:)"))); @end; __attribute__((swift_name("KotlinEnum"))) @interface CommonKotlinEnum : KotlinBase <CommonKotlinComparable> - (instancetype)initWithName:(NSString *)name ordinal:(int32_t)ordinal __attribute__((swift_name("init(name:ordinal:)"))) __attribute__((objc_designated_initializer)); - (int32_t)compareToOther:(CommonKotlinEnum *)other __attribute__((swift_name("compareTo(other:)"))); - (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)"))); - (NSUInteger)hash __attribute__((swift_name("hash()"))); - (NSString *)description __attribute__((swift_name("description()"))); @property (readonly) NSString *name __attribute__((swift_name("name"))); @property (readonly) int32_t ordinal __attribute__((swift_name("ordinal"))); @end; __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("Kotlinx_serialization_runtimeUpdateMode"))) @interface CommonKotlinx_serialization_runtimeUpdateMode : CommonKotlinEnum + (instancetype)alloc __attribute__((unavailable)); + (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable)); @property (class, readonly) CommonKotlinx_serialization_runtimeUpdateMode *banned __attribute__((swift_name("banned"))); @property (class, readonly) CommonKotlinx_serialization_runtimeUpdateMode *overwrite __attribute__((swift_name("overwrite"))); @property (class, readonly) CommonKotlinx_serialization_runtimeUpdateMode *update __attribute__((swift_name("update"))); - (instancetype)initWithName:(NSString *)name ordinal:(int32_t)ordinal __attribute__((swift_name("init(name:ordinal:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable)); - (int32_t)compareToOther:(CommonKotlinx_serialization_runtimeUpdateMode *)other __attribute__((swift_name("compareTo(other:)"))); @end; __attribute__((swift_name("Kotlinx_serialization_runtimeSerialModuleCollector"))) @protocol CommonKotlinx_serialization_runtimeSerialModuleCollector @required - (void)contextualKClass:(id<CommonKotlinKClass>)kClass serializer:(id<CommonKotlinx_serialization_runtimeKSerializer>)serializer __attribute__((swift_name("contextual(kClass:serializer:)"))); - (void)polymorphicBaseClass:(id<CommonKotlinKClass>)baseClass actualClass:(id<CommonKotlinKClass>)actualClass actualSerializer:(id<CommonKotlinx_serialization_runtimeKSerializer>)actualSerializer __attribute__((swift_name("polymorphic(baseClass:actualClass:actualSerializer:)"))); @end; __attribute__((swift_name("KotlinKDeclarationContainer"))) @protocol CommonKotlinKDeclarationContainer @required @end; __attribute__((swift_name("KotlinKAnnotatedElement"))) @protocol CommonKotlinKAnnotatedElement @required @end; __attribute__((swift_name("KotlinKClassifier"))) @protocol CommonKotlinKClassifier @required @end; __attribute__((swift_name("KotlinKClass"))) @protocol CommonKotlinKClass <CommonKotlinKDeclarationContainer, CommonKotlinKAnnotatedElement, CommonKotlinKClassifier> @required - (BOOL)isInstanceValue:(id _Nullable)value __attribute__((swift_name("isInstance(value:)"))); @property (readonly) NSString * _Nullable qualifiedName __attribute__((swift_name("qualifiedName"))); @property (readonly) NSString * _Nullable simpleName __attribute__((swift_name("simpleName"))); @end; #pragma clang diagnostic pop NS_ASSUME_NONNULL_END
bensengupta/search
include/datasource.h
<filename>include/datasource.h #ifndef DATASOURCE_H #define DATASOURCE_H #include "document.h" class DataSource { public: virtual std::vector<Document> getDocuments(); }; class FileDataSource : public DataSource { public: FileDataSource(std::string filename); std::vector<Document> getDocuments(); private: std::string filename; }; #endif // DATASOURCE_H
bensengupta/search
include/query.h
#ifndef QUERY_H #define QUERY_H #include "document.h" #include <map> #include <string> #include <tuple> #include <unordered_map> #include <vector> class QueryNodeResult { public: bool endReached; int docId; int posStart; int posEnd; static QueryNodeResult EndNode(); static QueryNodeResult Node(int docId, int posStart, int posEnd); private: QueryNodeResult(bool endReached, int docId, int posStart, int posEnd); }; class QueryNode { public: /// Creates the query node on the heap and returns a pointer to it static QueryNode *create(); /// Gets next element from node virtual QueryNodeResult next(); /// Execute query with a given max hits and return a vector of document ids static std::vector<QueryNodeResult> executeQuery(QueryNode *node, int max); virtual ~QueryNode(); }; class QueryNodeTerm : public QueryNode { public: static QueryNode *create(std::vector<std::tuple<int, int>> *index); QueryNodeResult next(); private: size_t i; QueryNodeTerm(std::vector<std::tuple<int, int>> *index); std::vector<std::tuple<int, int>> *index; }; class QueryNodePhrase : public QueryNode { public: static QueryNode *create(QueryNode *node1, QueryNode *node2); QueryNodeResult next(); ~QueryNodePhrase(); private: QueryNode *node1; QueryNode *node2; QueryNodePhrase(QueryNode *node1, QueryNode *node2); }; #endif // QUERY_H
bensengupta/search
include/index.h
#ifndef INDEX_H #define INDEX_H #include "document.h" #include "query.h" #include <map> #include <string> #include <tuple> #include <unordered_map> #include <vector> class Index { public: void indexDocuments(std::vector<Document> documents, std::string delims, std::string charsToSkip); std::vector<Document *> search(std::string query, int maxResults); private: std::unordered_map<int, Document> documentIdMap; /// unordered_map<term, tuple<doc_id, position_in_doc>> std::unordered_map<std::string, std::vector<std::tuple<int, int>>> inverseIndex; void mergeInverseIndex( std::map<std::string, std::vector<std::tuple<int, int>>> newInverseIndex); QueryNode *buildQuery(std::vector<std::string>); static std::vector<std::string> getQueryTerms(std::string query); }; #endif // INDEX_H
bensengupta/search
include/timer.h
<reponame>bensengupta/search #include <chrono> class Timer { public: void start(); void end(); private: std::chrono::high_resolution_clock::time_point start_time; };
bensengupta/search
include/document.h
#ifndef DOCUMENT_H #define DOCUMENT_H #include <map> #include <string> #include <tuple> #include <vector> class Document { public: int id; std::string text; Document(int id, std::string text); std::vector<std::string> getTerms(std::string delims, std::string charsToSkip); }; #endif // DOCUMENT_H
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/DTWebArchive/UIPasteboard+DTWebArchive.h
// // UIPasteboard+DTWebArchive.h // DTWebArchive // // Created by <NAME> on 9/2/11. // Copyright (c) 2011 Cocoanetics. All rights reserved. // #import <UIKit/UIKit.h> @class DTWebArchive; @interface UIPasteboard (DTWebArchive) @property(nonatomic,copy) DTWebArchive *webArchive; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/DTCache.h
// // DTCache.h // CoreTextExtensions // // Created by <NAME> on 7/30/11. // Copyright 2011 <EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> // if we don't support 3.2 then we use NSCache directly #if __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_3_2 #define DTCache NSCache #else typedef enum { DTCacheModeLegacy = 0, DTCacheModeModern } DTCacheMode; @interface DTCache : NSObject { id _cache; // NSCache or NSMutableDictionary DTCacheMode _cacheMode; } - (id)objectForKey:(id)key; - (void)setObject:(id)obj forKey:(id)key; - (void)removeAllObjects; @end #endif
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/NSURL+HTML.h
<filename>StreamGlider App/NSAttributedString-HTML/Classes/NSURL+HTML.h // // NSURL+HTML.h // PagingTextScroller // // Created by <NAME> on 24.03.11. // Copyright 2011 Cocoanetics. All rights reserved. // #import <Foundation/Foundation.h> @interface NSURL (HTML) - (NSURL *)derivedBaseURL; @end
streamglider/streamglider
StreamGlider App/Classes/StreamTitleViewController.h
// // StreamTitleViewController.h // StreamCast // // Created by <NAME> on 05/11/2010. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> @class Stream; @class OtherStreamTableViewCell; @interface StreamTitleViewController : UIViewController <UITextFieldDelegate> @property (nonatomic, assign, setter = setStream:) Stream *stream; @property (nonatomic, assign) OtherStreamTableViewCell *cell; - (void)dropEditing; @end
streamglider/streamglider
StreamGlider App/Classes/TwitterPreviewViewController.h
<filename>StreamGlider App/Classes/TwitterPreviewViewController.h<gh_stars>1-10 // // TwitterPreviewViewController.h // StreamCast // // Created by <NAME> on 26/10/2010. // Copyright 2010 SemantiStar, Inc. All rights reserved. // #import <UIKit/UIKit.h> #import "PreviewViewController.h" @class LocalLinksWebView; @interface TwitterPreviewViewController : PreviewViewController { LocalLinksWebView *webView; UIImageView *userImage; UILabel *userNameLabel; UILabel *createdAtLabel; UITextView *textView; } @property (nonatomic, retain) IBOutlet LocalLinksWebView *webView; @property (nonatomic, retain) IBOutlet UIImageView *userImage; @property (nonatomic, retain) IBOutlet UILabel *userNameLabel; @property (nonatomic, retain) IBOutlet UILabel *createdAtLabel; @property (nonatomic, retain) IBOutlet UITextView *textView; @end
streamglider/streamglider
StreamGlider App/Classes/OtherStreamTableViewCell.h
<reponame>streamglider/streamglider<gh_stars>1-10 // // OtherStreamTableViewCell.h // StreamCast // // Created by <NAME> on 13/09/2010. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> #import "StreamDelegate.h" #import "DNDTarget.h" @class Stream; @class EditStreamViewController; @class StreamTitleViewController; typedef enum { MoveDirectionRight, MoveDirectionLeft } HorizontalMoveDirection; @interface OtherStreamTableViewCell : UITableViewCell <StreamDelegate, DNDTarget> @property (nonatomic, assign, setter = setStream:) Stream *stream; @property (nonatomic, retain) IBOutlet UIView *pagingView; @property (nonatomic, retain) IBOutlet StreamTitleViewController *titleViewController; @property (nonatomic, assign) EditStreamViewController *editStreamViewController; @property (nonatomic) BOOL animate; - (void)setUpTitleLabel; - (void)adjustTableForKeyboardWithHeight:(int)kbHeight; @end
streamglider/streamglider
StreamGlider App/Classes/APIReader.h
<reponame>streamglider/streamglider // // FeedsReader.h // StreamGlider // // Created by <NAME> on 17/08/2011. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "APIDelegate.h" #import "LoginVCDelegate.h" @interface APIReader : NSObject <LoginVCDelegate, APIDelegate> @property (nonatomic, assign) id<APIDelegate> delegate; @property (nonatomic, retain) NSString *postData; @property (nonatomic, assign) BOOL handleAuthError; @property (nonatomic, assign) UIViewController *viewController; @property (nonatomic, assign) BOOL addAuthToken; @property (nonatomic, copy) NSString *pathAndQuery; @property (nonatomic, copy) NSString *method; @property (nonatomic, retain) APIReader *reader; - (void)loadAPIDataFor:(NSString*)pathAndQuery; - (void)loadAPIDataFor:(NSString*)pathAndQuery withMethod:(NSString*)method; - (void)loadAPIDataFor:(NSString*)pathAndQuery withMethod:(NSString*)method addAuthToken:(BOOL)addAuthToken; - (void)loadAPIDataFor:(NSString*)pathAndQuery withMethod:(NSString*)method addAuthToken:(BOOL)addAuthToken handleAuthError:(BOOL)handleAuthError; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/CGUtils.h
<reponame>streamglider/streamglider<gh_stars>1-10 // // CGUtils.h // CoreTextExtensions // // Created by <NAME> on 1/16/11. // Copyright 2011 D<EMAIL>. All rights reserved. // //CGPathRef newPathForRoundedRect(CGRect rect, CGFloat cornerRadius, BOOL roundTopCorners, BOOL roundBottomCorners); CGSize sizeThatFitsKeepingAspectRatio(CGSize originalSize, CGSize sizeToFit); CGPoint CGRectCenter(CGRect rect);
streamglider/streamglider
StreamGlider App/Classes/RSSFeed.h
// // RSSFeed.h // StreamCast // // Created by <NAME> on 12/08/2010. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "Feed.h" @interface RSSFeed : Feed <NSXMLParserDelegate> @property (nonatomic, copy) NSString *link; @property (nonatomic, copy) NSString *feedDescription; @property (nonatomic, copy) NSString *feedTitle; @property (nonatomic, copy) NSDate *lastBuildDate; @property (nonatomic, copy) NSString *imageURL; @property (nonatomic, copy) NSData *imageData; - (NSString *)flattenHTML:(NSString *)html; @end
streamglider/streamglider
StreamGlider App/Classes/SlideShowViewController.h
// // SlideShowViewController.h // StreamCast // // Created by <NAME> on 20/10/2010. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> @class Frame; @class Stream; @class SmallFrameViewController; @class StreamCastViewController; @interface SlideShowViewController : UIViewController <UIScrollViewDelegate> @property (nonatomic, retain) IBOutlet UIScrollView *scrollView; @property (nonatomic, assign, setter = setFrame:) Frame *frame; @property (nonatomic, assign, setter = setStream:) Stream *stream; @property (nonatomic, assign) StreamCastViewController *streamCastViewController; @property (nonatomic, assign) CGFloat scale; @property (nonatomic, retain) UIView *currentView; @property (nonatomic, assign) BOOL shouldResumeTable; - (void)pause; - (void)resume; - (void)updateButtons; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/DTWebArchive/DTWebArchive.h
<reponame>streamglider/streamglider // // DTWebArchive.h // DTWebArchive // // Created by <NAME> on 9/2/11. // Copyright 2011 Cocoanetics. All rights reserved. // #import <Foundation/Foundation.h> #import "DTWebResource.h" extern NSString * WebArchivePboardType; @interface DTWebArchive : NSObject { DTWebResource *_mainResource; NSArray *_subresources; NSArray *_subframeArchives; NSData *_data; } @property (nonatomic, retain, readonly) DTWebResource *mainResource; @property (nonatomic, retain, readonly) NSArray *subresources; @property (nonatomic, retain, readonly) NSArray *subframeArchives; @property (nonatomic, retain, readonly) NSData *data; - (id)initWithData:(NSData *)data; - (id)initWithDictionary:(NSDictionary *)dictionary; - (id)initWithMainResource:(DTWebResource *)mainResource subresources:(NSArray *)subresources subframeArchives:(NSArray *)subframeArchives; - (NSDictionary *)dictionaryRepresentation; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/DTLazyImageView.h
<reponame>streamglider/streamglider // // DTLazyImageView.h // PagingTextScroller // // Created by <NAME> on 5/20/11. // Copyright 2011 . All rights reserved. // #import <Foundation/Foundation.h> #import <ImageIO/ImageIO.h> @class DTLazyImageView; @protocol DTLazyImageViewDelegate <NSObject> @optional - (void)lazyImageView:(DTLazyImageView *)lazyImageView didChangeImageSize:(CGSize)size; @end @interface DTLazyImageView : UIImageView { NSURL *_url; NSURLConnection *_connection; NSMutableData *_receivedData; /* For progressive download */ CGImageSourceRef _imageSource; CGFloat _fullHeight; CGFloat _fullWidth; NSUInteger _expectedSize; BOOL shouldShowProgressiveDownload; id<DTLazyImageViewDelegate> _delegate; } @property (nonatomic, retain) NSURL *url; @property (nonatomic, assign) BOOL shouldShowProgressiveDownload; @property (nonatomic, assign) id<DTLazyImageViewDelegate> delegate; - (void)cancelLoading; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/DTRangedAttribute.h
// // DTRangedAttributes.h // CoreTextExtensions // // Created by <NAME> on 7/31/11. // Copyright 2011 <EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> @interface DTRangedAttribute : NSObject { NSRange _range; id _key; id _value; } + (DTRangedAttribute *)rangedAttribute:(id)key value:(id)value forRange:(NSRange)range; - (id)initWithAttribute:(id)key value:(id)value forRange:(NSRange)range; @property (nonatomic, assign) NSRange range; @property (nonatomic, copy) id key; @property (nonatomic, retain) id value; @end
streamglider/streamglider
StreamGlider App/Classes/StreamCastViewController.h
<reponame>streamglider/streamglider // // StreamCastViewController.h // StreamCast // // Created by <NAME> on 7/15/10. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> #import "LoaderDelegate.h" #import "PageBarViewController.h" @class Stream; @class StreamsTableViewController; @class EditStreamViewController; @class Frame; @class SlideShowViewController; @class PreviewViewController; @class StartupAnimationViewController; @interface StreamCastViewController : UIViewController <LoaderDelegate> @property (nonatomic, retain) IBOutlet StreamsTableViewController *tableViewController; @property (nonatomic, retain) IBOutlet EditStreamViewController *editViewController; @property (nonatomic, retain) IBOutlet SlideShowViewController *slideShowViewController; @property (nonatomic, retain, setter=setPreviewViewController:) IBOutlet PreviewViewController *previewViewController; @property (nonatomic, retain) IBOutlet UIView *tableView; @property (nonatomic, retain) IBOutlet UIView *tableViewContainer; @property (assign) BOOL displayingPreview; - (void)displayViewForFrame:(Frame*)frame; - (void)playPreviewAnimation; - (void)displayBrowserForFrame:(Frame*)frame; - (void)displayBrowserForRequest:(NSURLRequest*)req; - (IBAction)handleSharedStreamsTapped; - (IBAction)handleEditTapped; - (void)updateButtons; - (void)pause; - (void)resume; @end
streamglider/streamglider
StreamGlider App/Classes/Stream.h
<filename>StreamGlider App/Classes/Stream.h // // Stream.h // StreamCast // // Created by <NAME> on 7/15/10. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "StreamDelegate.h" #import "ObjectWithID.h" @class Frame; @class Feed; @interface Stream : ObjectWithID @property (nonatomic, copy, setter=setTitle:) NSString *title; @property (nonatomic, retain) NSMutableArray *feeds; @property (nonatomic, retain) NSMutableArray *frames; @property (nonatomic) BOOL isPaused; @property (assign) BOOL skipNextFrameAddition; @property (assign) BOOL initializing; @property (nonatomic, copy) NSString *remoteID; - (BOOL)addFeed:(Feed*)feed; - (void)removeFeed:(Feed*)feed; - (void)moveFeed:(Feed*)feed fromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex; - (void)insertFeed:(Feed*)feed atIndex:(NSInteger)atIndex; - (void)addStreamDelegate:(id<StreamDelegate>)delegate; - (void)removeStreamDelegate:(id<StreamDelegate>)delegate; - (void)loadNewFrames; - (void)addNextFrame; - (void)removeFrame:(Frame*)frame; - (NSArray*)getImagePaths; - (NSArray*)getResourcePaths; - (void)fireFeedWasChanged:(Feed*)feed; @end
streamglider/streamglider
StreamGlider App/Classes/Frame.h
<reponame>streamglider/streamglider<gh_stars>1-10 // // Frame.h // StreamCast // // Created by <NAME> on 7/15/10. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "ObjectWithID.h" @class Feed; @interface Frame : ObjectWithID @property (nonatomic, assign) Feed *feed; @property (nonatomic, copy) NSString *URLString; @property (nonatomic, copy) NSString *imageURL; @property (nonatomic, copy) NSString *thumbURL; @property (assign) BOOL frameIsReady; @property (nonatomic, assign) BOOL frameWasShown; + (NSString*)formatDate:(NSDate*)date; - (NSArray*)getImagePaths; - (NSArray*)getResourcePaths; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/NSAttributedString+DTWebArchive.h
// // NSAttributedString+DTWebArchive.h // CoreTextExtensions // // Created by <NAME> on 9/6/11. // Copyright 2011 <EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> @class DTWebArchive; @interface NSAttributedString (DTWebArchive) - (id)initWithWebArchive:(DTWebArchive *)webArchive options:(NSDictionary *)options documentAttributes:(NSDictionary **)dict; - (DTWebArchive *)webArchive; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/NSMutableAttributedString+HTML.h
// // NSMutableAttributedString+HTML.h // CoreTextExtensions // // Created by <NAME> on 4/14/11. // Copyright 2011 <EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> @class DTCoreTextParagraphStyle; @interface NSMutableAttributedString (HTML) // appends a string with the same attributes as the suffix - (void)appendString:(NSString *)string; // appends a string with a different paragraph style - (void)appendString:(NSString *)string withParagraphStyle:(DTCoreTextParagraphStyle *)paragraphStyle; // appends a string without any attributes - (void)appendNakedString:(NSString *)string; @end
streamglider/streamglider
StreamGlider App/Config.h
<filename>StreamGlider App/Config.h // // Config.h // StreamCast // // Created by <NAME> on 10/02/2011. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> // Frame size #define FRAME_WIDTH 220 #define FRAME_HEIGHT 155 // Main table cell height #define CELL_HEIGHT 159 // Plus mode main table cell height #define PLUS_MODE_CELL_HEIGHT 203 // Number of feeds per request #define FEEDS_PER_PAGE 15 // max number of frames per stream on screen #define FRAMES_PER_STREAM 10 // caption bar transparency #define CAPTION_BAR_OPACITY 0.75 // gap between frames in the streams table #define FRAMES_GAP 4
streamglider/streamglider
StreamGlider App/Classes/Core.h
<filename>StreamGlider App/Classes/Core.h // // Core.h // StreamCast // // Created by <NAME> on 7/16/10. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "CoreDelegate.h" #import "StreamDelegate.h" #import "SettingsDelegate.h" @class Stream; @class FeedSource; @class BrowserViewController; @class SmallFrameViewController; @class FeedSourceCategory; @class PageOfStreams; @interface Core : NSObject <StreamDelegate, SettingsDelegate> @property (nonatomic, assign) NSMutableArray *streams; @property (nonatomic, retain) NSMutableArray *pages; @property (nonatomic, assign) BOOL isPaused; @property (nonatomic, retain) BrowserViewController *browserViewController; @property (nonatomic, retain) FeedSourceCategory *rootCategory; @property (nonatomic, retain) UIImage *cardImage; @property (nonatomic, retain) NSArray *featuredFeeds; // user api token and email with the SG system @property (nonatomic, copy, setter = setApiToken:, getter = getApiToken) NSString *apiToken; @property (nonatomic, copy, setter = setUserEmail:, getter = getUserEmail) NSString *userEmail; + (Core*)sharedInstance; // streams - (void)addStream:(Stream*)stream skipStoring:(BOOL)skipStoring; - (void)removeStream:(Stream*)stream; - (void)moveStream:(Stream*)stream fromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex; // pages - (void)addPage:(PageOfStreams*)page makeActive:(BOOL)makeActive; - (void)removePage:(PageOfStreams*)page; - (void)setActivePage:(PageOfStreams*)page; - (PageOfStreams*)getActivePage; // feed sources - (void)addSource:(FeedSource*)source; - (void)removeSource:(FeedSource*)source; // delegates - (void)addCoreDelegate:(id<CoreDelegate>)delegate; - (void)removeCoreDelegate:(id<CoreDelegate>)delegate; // pause / resume - (void)togglePause; - (void)pauseAllStreamsExcept:(Stream*)stream; - (void)resumeAllStreams; - (void)pauseAllStreams; // image paths - (NSArray*)getImagePaths; - (NSArray*)getResourcePaths; // viewed frames - (BOOL)frameWasViewed:(SmallFrameViewController*)viewController; - (void)viewFrame:(NSString*)frameURL; - (void)releaseFrameFromViewed:(SmallFrameViewController*)viewController; - (void)removeAllFramesWithURL:(NSString*)frameURL; // new frames - (BOOL)isFrameNew:(NSString*)frameURL; - (BOOL)isFrameDeleted:(NSString*)frameURL; // timers - (void)installTimers; - (void)killTimers; // cookies + (void)clearCookies:(NSURL*)url; @end
streamglider/streamglider
StreamGlider App/Classes/SettingsTableViewController.h
// // SettingsViewController.h // StreamGlider // // Created by <NAME> on 05/05/2011. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> #import "OAuthDelegate.h" #import "GoogleReaderLoginDelegate.h" @interface SettingsTableViewController : UITableViewController <OAuthDelegate, GoogleReaderLoginDelegate> @property (nonatomic, assign) IBOutlet UIViewController *viewController; @property (nonatomic, assign) BOOL emailPanel; @property (nonatomic, copy) NSString *realm; @end
streamglider/streamglider
StreamGlider App/Classes/BaseCacheController.h
// // BaseCacheController.h // StreamGlider // // Created by <NAME> on 13/10/2010. // Refactoring by <NAME> on 11-07-12. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "CoreDelegate.h" #import "StreamDelegate.h" @class Stream; @class CacheData; @interface BaseCacheController : NSObject <CoreDelegate, StreamDelegate> @property (assign) BOOL syncingImages; - (Feed*)findFeed:(NSString*)feedID; - (NSArray*)getFramesForStream:(Stream*)stream; - (NSData*)loadImageData:(NSString*)url; - (void)storeCacheData; - (void)loadCacheData; - (void)dumpCache; // images - (NSString*)storeImageData:(NSString*)imageUrl withThumb:(BOOL)withThumb; - (UIImage*)getImage:(NSString*)path; - (void)releaseImage:(NSString*)path; // resources - (NSString*)storeResourceData:(NSData*)resData; - (NSData*)getResourceData:(NSString*)path; - (void)releaseResourceData:(NSString*)path; - (void)syncResourcesAndImagesCache; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/DTWebArchive/NSDictionary+Data.h
// // NSDictionary+Data.h // DTWebArchive // // Created by <NAME> on 9/2/11. // Copyright 2011 Cocoanetics. All rights reserved. // #import <Foundation/Foundation.h> @interface NSDictionary (Data) + (NSDictionary *)dictionaryWithData:(NSData *)data; - (id)initWithData:(NSData *)data; - (NSData *)dataRepresentation; @end
streamglider/streamglider
StreamGlider App/Classes/StreamDelegate.h
// // StreamDelegate.h // StreamCast // // Created by <NAME> on 7/16/10. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> @class Stream; @class Feed; @class Frame; @protocol StreamDelegate @optional - (void)titleWasChanged:(Stream*)stream; - (void)feedWasAdded:(Feed*)feed; - (void)feedWasRemoved:(Feed*)feed; - (void)feedWasMoved:(Feed*)feed fromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex; - (void)feedWasInserted:(Feed*)feed atIndex:(NSInteger)atIndex; - (void)feedWasChanged:(Feed*)feed; - (void)frameWasAdded:(Frame*)frame; - (void)frameWasRemoved:(Frame*)frame; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/DTCSSStylesheet.h
<gh_stars>1-10 // // DTCSSStylesheet.h // CoreTextExtensions // // Created by <NAME> on 9/5/11. // Copyright (c) 2011 <EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> @class DTHTMLElement; @interface DTCSSStylesheet : NSObject { NSMutableDictionary *_styles; } - (id)initWithStyleBlock:(NSString *)css; // adds styles contained in block to sheet - (void)parseStyleBlock:(NSString *)css; // returns merged style for a tag - (NSDictionary *)mergedStyleDictionaryForElement:(DTHTMLElement *)element; @end
streamglider/streamglider
StreamGlider App/Classes/OAuthCore.h
// // OAuthCore.h // StreamCast // // Created by <NAME> on 03/08/2010. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "OAuthProtocol.h" #import "OAuthDelegate.h" @class AuthorizeViewController; @class StreamCastViewController; @interface OAuthCore : NSObject <OAuthDelegate, UIAlertViewDelegate> @property (nonatomic, assign) UIViewController *viewController; @property (nonatomic, retain) AuthorizeViewController *authorizeViewController; @property (nonatomic, assign) StreamCastViewController *streamCastViewController; - (id<OAuthProtocol>)getOAuthForRealm:(NSString*)realm; + (OAuthCore*)sharedInstance; + (NSString*)getValueFromKeyChainFor:(NSString*)key; + (void)storeKeychainValue:(NSString*)value forKey:(NSString*)key; + (void)deleteKeychainValueForKey:(NSString*)key; - (void)requestAuthForRealm:(NSString*)realm withDelegate:(id<OAuthDelegate>)aDelegate viewController:(UIViewController*)vc; - (void)requestAuthForRealm:(NSString*)realm withDelegate:(id<OAuthDelegate>)aDelegate viewController:(UIViewController*)vc askUser:(BOOL)askUser reason:(NSString*)reason; - (void)clearAllTokens; - (void)clearTokenForRealm:(NSString*)realm; @end
streamglider/streamglider
StreamGlider App/Classes/SettingsController.h
// // SettingsController.h // StreamGlider // // Created by <NAME> on 05/05/2011. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "SettingsDelegate.h" #define NEW_INDICATOR_IMAGES @"settings_new_yellow.png", @"settings_new_blue.png", @"settings_new_green.png", @"settings_new_pink.png", @"settings_new_red.png", @"settings_new_white.png", nil @interface SettingsController : NSObject @property (nonatomic, assign, setter = setRemoveViewedFrames:) BOOL removeViewedFrames; @property (nonatomic, retain) NSArray *niColors; @property (nonatomic, retain) NSArray *niColorNames; @property (nonatomic, retain) NSArray *niColorImages; @property (nonatomic, assign, setter = setNiCurrentColor:) int niCurrentColor; @property (nonatomic, assign, setter = setCardsInterval:) int cardsInterval; @property (nonatomic, assign, setter = setGrayOutViewedFrames:) BOOL grayOutViewedFrames; @property (nonatomic, assign, setter = setPlusMode:) BOOL plusMode; @property (nonatomic, assign, setter = setPaginateFeeds:) BOOL paginateFeeds; + (SettingsController*)sharedInstance; - (void)addDelegate:(id<SettingsDelegate>)delegate forProperty:(SettingsPropertyType)property; - (void)removeDelegate:(id<SettingsDelegate>)delegate property:(SettingsPropertyType)property; - (void)storeDefaults; @end
streamglider/streamglider
StreamGlider App/Classes/SourceTableViewController.h
// // SourceTableViewController.h // StreamCast // // Created by <NAME> on 25/09/2010. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> @class FeedSource; @class Feed; @class Stream; @interface SourceTableViewController : UITableViewController { FeedSource *feedSource; UIBarButtonItem *doneButton; Feed *feed; Stream *stream; } @property (nonatomic, retain) FeedSource *feedSource; @property (nonatomic, retain) UIBarButtonItem *doneButton; @property (nonatomic, assign, setter = setFeed:) Feed *feed; @property (nonatomic, assign) Stream *stream; - (void)createOrEditFeed; - (void)prepopulateFields; - (void)resignEditing; @end
streamglider/streamglider
StreamGlider App/Classes/CoreDelegate.h
// // CoreDelegate.h // StreamCast // // Created by <NAME> on 7/19/10. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> @class Stream; @class FeedSource; @class PageOfStreams; @protocol CoreDelegate @optional // streams - (void)streamWasAdded:(Stream*)stream; - (void)streamWasRemoved:(Stream*)stream index:(NSInteger)index; - (void)streamWasMoved:(Stream*)stream fromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex; // feed sources - (void)sourceWasAdded:(FeedSource*)source; - (void)sourceWasRemoved:(FeedSource*)source; // pages - (void)pageWasAdded:(PageOfStreams*)page; - (void)pageWasRemoved:(PageOfStreams*)page; - (void)activePageWasChangedToPage:(PageOfStreams*)page; @end
streamglider/streamglider
StreamGlider App/Classes/YTPreviewViewController.h
<reponame>streamglider/streamglider // // YTPreviewViewController.h // StreamCast // // Created by <NAME> on 27/10/2010. // Copyright 2010 SemantiStar, Inc. All rights reserved. // #import <UIKit/UIKit.h> #import "PreviewViewController.h" @class LocalLinksWebView; @interface YTPreviewViewController : PreviewViewController <UIWebViewDelegate> { LocalLinksWebView *webView; UILabel *titleLabel; UILabel *publishedLabel; } @property (nonatomic, retain) IBOutlet LocalLinksWebView *webView; @property (nonatomic, retain) IBOutlet UILabel *titleLabel; @property (nonatomic, retain) IBOutlet UILabel *publishedLabel; @end
streamglider/streamglider
StreamGlider App/Classes/OAuth2.h
<reponame>streamglider/streamglider // // OAuth2.h // StreamCast // // Created by <NAME> on 25/09/2010. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "OAuthProtocol.h" #import "OAuthDelegate.h" @interface OAuth2 : NSObject <OAuthProtocol> @property (nonatomic, copy) NSString *clientID; @property (nonatomic, copy) NSString *redirectURI; @property (nonatomic, copy) NSString *clientSecret; @property (nonatomic, copy) NSString *accessToken; @property (nonatomic, copy) NSString *refreshToken; @property (nonatomic, copy) NSString *accessTokenUri; @property (nonatomic, copy) NSString *authorizationTokenUri; @property (nonatomic, copy) NSString *realm; @property (nonatomic, assign) id<OAuthDelegate> delegate; @end
streamglider/streamglider
StreamGlider App/Classes/Feed.h
<filename>StreamGlider App/Classes/Feed.h // // Feed.h // StreamCast // // Created by <NAME> on 7/16/10. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "FeedDelegate.h" #import "ObjectWithID.h" @class Stream; @class FeedSource; @interface Feed : ObjectWithID <NSCopying> @property (nonatomic, copy, setter=setTitle:) NSString *title; @property (nonatomic, assign) Stream* stream; @property (nonatomic, retain) NSMutableArray *tempQueue; @property (retain) NSArray *queue; @property (nonatomic, retain, setter = setSource:) FeedSource *source; @property BOOL loading; @property (nonatomic, setter = setEditing:) BOOL editing; @property (nonatomic) int currentFrameIndex; @property (assign) BOOL stopComplimenting; - (void)loadNewFrames; - (void)performLoadInBackground; - (void)loadWasFinished; - (void)addFeedDelegate:(id<FeedDelegate>)delegate; - (void)removeFeedDelegate:(id<FeedDelegate>)delegate; - (void)moveToNextFrame; - (void)makeFrameReady:(Frame*)frame; - (BOOL)hasReadyFrames; - (BOOL)allFramesWereShown; - (NSDate*)parseDate:(NSString*)date; - (NSString*)dateFormat; @end
streamglider/streamglider
StreamGlider App/Classes/SEMArticleExtractor.h
// // SEMArticleExtractor.h // Article Retriever // // Created by <NAME> on 11-12-03. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> @class HTMLParser; @class HTMLNode; @interface SEMArticleExtractor : NSObject @property (nonatomic, retain) HTMLParser *htmlParser; @property (nonatomic, retain) NSData *htmlData; - (id)initWithHTMLData:(NSData *)htmlContent error:(NSError **)error; - (id)initWithHTMLString:(NSString *)htmlString error:(NSError **)error; - (id)initWithContentsOfURL:(NSURL*)url error:(NSError**)error; - (HTMLNode *)findTextNodeContainingString:(NSString *)searchString; - (NSArray *)findNodesContainingStrings:(NSArray *)searchStrings; - (HTMLNode *)nodeContainingString:(NSString *)searchString withinTag:(NSString *)tagName; - (NSArray *)extractSearchTermsFromString:(NSString *)content minimumTermLength:(NSUInteger)length limitTerms:(NSUInteger)limit; + (NSString *)extractArticleAsString:(NSString*)description htmlString:(NSString*)htmlString; @end
streamglider/streamglider
StreamGlider App/Classes/StreamCastConstants.h
// // StreamCastConstants.h // StreamGlider // // Created by <NAME> on 11-07-11. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. // Application Information extern NSString * const APP_NAME; extern NSTimeInterval const RELEASE_DATE; extern NSString * const TAG_LINE; extern NSString * const SITE_URL; // Service Realm Identifiers extern NSString * const TWITTER_REALM; extern NSString * const FACEBOOK_REALM; extern NSString * const FLICKR_REALM; extern NSString * const YOUTUBE_REALM;
streamglider/streamglider
StreamGlider App/Classes/MagPage.h
<filename>StreamGlider App/Classes/MagPage.h // // MagPage.h // StreamGlider // // Created by <NAME> on 31/10/2011. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> @class MagPageLayout; @class Stream; @class FrameIterator; @interface MagPage : NSObject @property (nonatomic, retain) NSArray *articles; @property (nonatomic, retain) MagPageLayout *layout; @property (nonatomic, assign) Stream *stream; @property (nonatomic, assign) FrameIterator *iterator; @property (nonatomic, assign) BOOL emptyPage; - (void)prepareArticlesForOrientation:(UIInterfaceOrientation)orientation; - (void)layoutArticlesForOrientation:(UIInterfaceOrientation)orientation; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/DTTextAttachment.h
// // DTTextAttachment.h // CoreTextExtensions // // Created by Oliver on 14.01.11. // Copyright 2011 Drobnik.<EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> @class DTHTMLElement; typedef enum { DTTextAttachmentTypeImage, DTTextAttachmentTypeVideoURL, DTTextAttachmentTypeIframe, DTTextAttachmentTypeObject, DTTextAttachmentTypeGeneric } DTTextAttachmentType; @interface DTTextAttachment : NSObject { CGSize _originalSize; CGSize _displaySize; id contents; NSDictionary *_attributes; DTTextAttachmentType contentType; NSURL *_contentURL; NSURL *_hyperLinkURL; } @property (nonatomic, assign) CGSize originalSize; @property (nonatomic, assign) CGSize displaySize; @property (nonatomic, retain) id contents; @property (nonatomic, assign) DTTextAttachmentType contentType; @property (nonatomic, retain) NSURL *contentURL; @property (nonatomic, retain) NSURL *hyperLinkURL; @property (nonatomic, retain) NSDictionary *attributes; + (DTTextAttachment *)textAttachmentWithElement:(DTHTMLElement *)element options:(NSDictionary *)options; - (NSString *)dataURLRepresentation; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/DTRangedAttributesOptimizer.h
<gh_stars>1-10 // // DTRangedAttributesOptimizer.h // CoreTextExtensions // // Created by <NAME> on 7/31/11. // Copyright 2011 <EMAIL>. All rights reserved. // #import <Foundation/Foundation.h> #import "DTRangedAttribute.h" @interface DTRangedAttributesOptimizer : NSObject { NSMutableDictionary *_attributeIndex; NSMutableArray *_attributes; BOOL _didMerge; } @property (nonatomic, readonly) BOOL didMerge; - (void)addAttribute:(DTRangedAttribute *)attribute; - (void)addAttributes:(NSDictionary *)attributes range:(NSRange)range; - (NSArray *)allKeys; - (NSArray *)rangedAttributesForKey:(id)key; @end
streamglider/streamglider
StreamGlider App/Classes/FeedFactory.h
// // FeedFactory.h // StreamGlider // // Created by <NAME> on 18/08/2011. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "FeedSourceType.h" @class Feed; @class FeedSource; @interface FeedFactory : NSObject + (Feed*)createFeedForSource:(FeedSource*)src; + (FeedSourceType)typeForStringName:(NSString*)name; + (NSString*)stringNameForType:(FeedSourceType)type; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/DTWebArchive/DTWebResource.h
// // DTWebResource.h // DTWebArchive // // Created by <NAME> on 9/2/11. // Copyright 2011 Cocoanetics. All rights reserved. // #import <Foundation/Foundation.h> @interface DTWebResource : NSObject <NSKeyedUnarchiverDelegate> { NSData *_data; NSString *_frameName; NSString *_mimeType; NSURL *_url; NSString *_textEncodingName; } + (DTWebResource *)webResourceWithDictionary:(NSDictionary *)dictionary; - (id)initWithDictionary:(NSDictionary *)dictionary; - (id)initWithData:(NSData *)data URL:(NSURL *)URL MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)textEncodingName frameName:(NSString *)frameName; - (NSDictionary *)dictionaryRepresentation; - (UIImage *)image; @property(nonatomic, retain, readonly) NSData *data; @property(nonatomic, retain, readonly) NSString *frameName; @property(nonatomic, retain, readonly) NSString *mimeType; @property(nonatomic, retain, readonly) NSURL *url; @property(nonatomic, retain, readonly) NSString *textEncodingName; @end
streamglider/streamglider
StreamGlider App/Classes/IncomingViewController.h
// // IncomingViewController.h // StreamGlider // // Created by <NAME> on 31/08/2011. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> #import "APIDelegate.h" @class IncomingTableViewController; @interface IncomingViewController : UIViewController <APIDelegate> @end
streamglider/streamglider
StreamGlider App/Classes/GReaderLoader.h
// // GReaderLoader.h // StreamGlider // // Created by <NAME> on 03/05/2011. // Copyright 2011 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "GReaderProtocol.h" @class FeedSource; @class FeedSourceCategory; @interface GReaderLoader : NSObject <NSXMLParserDelegate> @property (nonatomic, assign) id<GReaderProtocol> delegate; + (GReaderLoader*)sharedInstance; - (void)getGoogleReaderSourcesForUser:(NSString*)user password:(NSString*)password; - (void)addSourcesToCategory:(FeedSourceCategory*)parent; @end
streamglider/streamglider
StreamGlider App/Classes/AuthorizeViewController.h
// // AuthorizeViewController.h // StreamCast // // Created by <NAME> on 05/08/2010. // Copyright 2010 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <UIKit/UIKit.h> #import "OAuthProtocol.h" @class OAuth; @interface AuthorizeViewController : UIViewController <UIWebViewDelegate> @property (nonatomic, assign) id<OAuthProtocol> oauth; @property (nonatomic, retain, setter = setRequest:) NSURLRequest *request; @property (nonatomic, copy) NSString *tokenName; @end
streamglider/streamglider
StreamGlider App/NSAttributedString-HTML/Classes/DTAttributedTextCell.h
<reponame>streamglider/streamglider // // DTAttributedTextCell.h // CoreTextExtensions // // Created by <NAME> on 8/4/11. // Copyright 2011 <EMAIL>. All rights reserved. // #import <UIKit/UIKit.h> @class DTAttributedTextContentView; @interface DTAttributedTextCell : UITableViewCell { NSAttributedString *_attributedString; DTAttributedTextContentView *_attributedTextContextView; NSUInteger _htmlHash; // preserved hash to avoid relayouting for same HTML } @property (nonatomic, retain) NSAttributedString *attributedString; @property (nonatomic, readonly) DTAttributedTextContentView *attributedTextContextView; - (id)initWithReuseIdentifier:(NSString *)reuseIdentifier accessoryType:(UITableViewCellAccessoryType)accessoryType; - (void)setHTMLString:(NSString *)html; @end
streamglider/streamglider
StreamGlider App/Classes/IncomingStreamsController.h
<filename>StreamGlider App/Classes/IncomingStreamsController.h // // IncomingStreamsController.h // StreamGlider // // Created by <NAME> on 08/02/2012. // Copyright (c) 2012 StreamGlider, Inc. All rights reserved. // // This program is free software if used non-commercially: you can redistribute it and/or modify // it under the terms of the BSD 4 Clause License as published by // the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // BSD 4 Clause License for more details. // // You should have received a copy of the BSD 4 Clause License // along with this program. If not, see the README.md file with this program. #import <Foundation/Foundation.h> #import "APIDelegate.h" @class ButtonWithBadge; @interface IncomingStreamsController : NSObject <APIDelegate> @property (nonatomic, retain) NSMutableArray *addedStreams; + (IncomingStreamsController*)sharedInstance; - (void)markAllViewed; - (void)addBadgeButton:(ButtonWithBadge*)bb; - (void)removeBadgeButton:(ButtonWithBadge*)bb; - (void)pauseUpdating; - (void)resumeUpdating; @end