Delphideki Stringlist Sınıfının Yeteneklerinde bir sınıf yazmaya başladım. şimdilik iş görebilir halde  daha da geliştirim inşş..

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
   /*
    *   StringList Class v1.0.0.0
    * ============================================================
    * Kodlayan: Tufan Barış YILDIRIM
    * Website : http://www.tufyta.com
    * ===================Versiyon Notları=========================
    *  v1.0.0.0
    * ========
    * -- Delphideki yetenekli gördüğüm sınıflardan biri olan StringList sınıfını yazdık hayırlı olsun
    */
  class StringList{
     
          private $Values=array();
          private $Text;
          private $Count;
          private $Lines;
         
           /**
           * StringList Sınıfının Kurucu FOnksiyonu.
           *
           * @param mixed $string Parcalamak İstediğiniz Metin.
           * @return StringList
           */
          function  StringList($string){
             
              $this->Text=$string;
              $this->Lines=explode("\n",$string);
              $Count=count($this->Lines);
             
              Foreach ($this->Lines As $LineText){
                  $EsitPos=strpos($LineText,'=');
                 $this->Values[substr($LineText,0,$EsitPos)]=substr($LineText,$EsitPos,strlen($LineText));
                 
              }
             
              return $this;
             
          }
          /**
          * Metni verir ve ya Metin verildiğinde Düzenler.
          *
          * @param mixed $SetTex
          * @return StringList
          */
          function Text($SetTex=False){
              if($SetTex){
                return $this->StringList($SetTex); 
              } else {
                  return  $this->Text;   
              }
              
          }
          /**
          * Satır Dizisi Olarak Döner ya da verdiğiniz Diziyi satırlar orak tekrar değiştirir.
          *
          * @param mixed $LinesArray
          * @return StringList
          */
          function Lines($LinesArray=false){
                 if($LinesArray){  
                return $this->StringList(implode("\n",$LinesArray)); 
              } else {
                  return  $this->Lines;   
              }
          }
         /**
         * Satur ya da Satır Dizisini Sınıfın Satırlarına Dahil eder.
         * @param mixed $LineOrLines
         */
          function Add($LineOrLines){
                  if(strstr($LineOrLines,"\n")){
                      $Lines=explode("\n",$LineOrLines);
                  }else {
                      $Lines[]=$LineOrLines;
                  }
                 
                  Foreach($Lines As $Line){
                      $this->Lines[]=$Line;
                  }
                  return $this;
          }
         
          /**
          * PROPERTIES
          */
          function Values($Name,$SetValue){
              if($SetValue){
                  foreach($this->Values AS $valName=>$valValue){
                      $Lines[]=$valName.'='.$valValue."\n";
                  }
                  $this->Lines($Lines);
              }
              else {
                   return $this->Values[$Name];
              }
          }
         
          /**
          * Bu Bölüm Sadece  PHP Editörlerde kullanım kolaylığı sağlaması içindir kullanılmaz.!
          *
          */
          private function ForPhpEditores(){
              die('Bu Fonksiyonu Kullanmayın.!');
              $this->Text=new StringList('');
              $this->Lines=new StringList('');
          }
  }
 
?>

Örnek Kullanım:

0
1
2
3
4
5
6
7
   $String="deger1=asd\ndeger2=2nindegeri\nbudadigersatir=adnasdandasdasd";
   $String=new StringList($String);
 
   $String->Text(); // verdiğimiz stringi aynen alırız.
   $String->Lines(); // Verdiğimiz Satırlar Dizi Olarak Döner.
   $String->Values('deger1'); // deger1=asd olduğundan bize asd olarak döner.
   $String->Lines()->Add('yenibirsatirdegeri=yenideger');  //satırlarımız arasına yenisini ekler.
   $String->Text("YenimetinSatir1=Ddeger1\nYeniSatir2=Deger2"); // Sınıfı Verdiğiniz Stringle Baştan İnşa eder

Leave a Reply

(required)

(required)


two + 2 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

© 2012 Tufan Suffusion theme by Sayontan Sinha